Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

autonomy

clux7.2kMIT2.1.0

Lightweight functional utility library complementing ES6

utility, functional, haskell, curry, zipWith, FP, ES6

readme

Autonomy

npm status build status dependency status coverage status

Autonomy is a lightweight functional helper library. It is meant to complement an ES6 style with curried helpers, math helpers, curried accessors and higher order looping constructs.

These library is partly inspired by Haskell's Prelude.

Usage

Use it with qualified imports with the yet unfinished module import syntax or attach it to the short variable of choice. For selling points, here's how it will look with ES7 modules.

import { not, any, gcd, elem, even, range, replicate, zip3, zipWith2, reduce } from 'autonomy'

var partition = (p, xs) => [xs.filter(p), xs.filter(not(p))];
partition((x) => x > 5, [8,3,4,5,6]); // [ [ 8, 6 ], [ 3, 4, 5 ] ]

[[3,4,5], [4,5,6]].filter(any(elem([6, 7]))); // [ [ 4, 5, 6 ] ]

range(10).filter(even); // [ 2, 4, 6, 8, 10 ]

replicate(5).forEach(cluster.fork); // calls a function with undefined arguments

zip3(range(5), [1,2], [3,2,5]); // [ [ 1, 1, 3 ], [ 2, 2, 2 ] ]
zipWith2(gcd, [5, 10, 15], range(5)); // [ 1, 2, 3 ]

var product = reduce((x, y) => x * y, 1);
var factorial = (n) => product(range(n));
factorial(4); // 24

Read the read the API.

This modules makes up the core part of the larger utility library interlude.

Installation

$ npm install autonomy

License

MIT-Licensed. See LICENSE file for details.

changelog

2.1.0 / 2016-01-27

  • Add interval function (two argument version of old range)

2.0.0 / 2016-01-27

  • Rewrite for ES6
  • range now only works with a single argument version
  • invoke removed (more complex than native ES6)
  • scan removed
  • get removed (pointless in ES6)
  • main composition function $(f, g[, h, []]) removed (generally bad style)
  • extend is now just Object.assign (which makes is better)
  • copy removed (pointless variadic thing almost never used)
  • constant removed (pointless with arrow functions)
  • replicate now takes a lenght and a fn as arguments (avoids copy)

1.0.1 / 2015-11-15

  • Added .npmignore

1.0.0 / 2014-09-30

  • Add $.copy to shallow copy an element
  • $.constant(n) now uses $.copy
  • $.replicate(o) now uses $.copy (thus will additionally copy objects)

0.5.2 / 2014-09-02

  • Move coverage to tests area to avoid confusing browserify

0.5.1 / 2014-07-10

  • Better documentation and test coverage

0.5.0 / 2012-11-11

  • $(..fns) now calls $.seq
  • $.seq still maintained for backwards compatibility in interlude for now.

0.4.2 / 2012-10-20

  • get is now variadic and can do what getDeep could

0.4.1 / 2012-10-20

  • replicate has been reinstated with an Array safe version

0.4.0 / 2012-10-20

  • has removed as Object.create(null) fills the void
  • seq2, seq3, seq4 variants removed - bad premature optimization
  • getDeep removed, bad to encourage that inefficiency over creating a more readable fn
  • replicate removed, faulty (assign by reference on arrays and object)

0.3.0 / 2012-07-04

  • scan arguments now model $.iterate

0.2.0 / 2012-06-30

  • First quite stable API release outside interlude
  • Moved pow/log to the operators module
  • Added a simple extend