Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 75 lines (48 sloc) 2.254 kb

Autonomy

Build Status Dependency Status stable

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

These library is partly inspired by Haskell's Prelude, but its exports are optimized for JavaScript semantics and performance. It does not try to make JavaScript into something it's not.

Usage

Attach it to the short variable of choice:

var $ = require('autonomy');

and get functional:

$.id(x) === x;
$.noop(x) === undefined;

var fn = $(fn1, fn2, fn3);
fn(a); // fn3(fn2(fn1(a)))

[1,3,2].map($.constant(5)); // [5, 5, 5]

[1,2,3,4,3].filter($.elem([1,3])); // [ 1, 3, 3 ]

[1,3,5,-1].some($.notElem([1,2,3,4,5])); // true

$.gcd(10, 15); // 5

[1,2,3,4,5,6].filter($.even); // [ 2, 4, 6 ]

$.range(5); // [ 1, 2, 3, 4, 5 ]

$.zip($.range(5), [1,2], [3,2,5]); // [ [ 1, 1, 3 ], [ 2, 2, 2 ] ]
$.zipWith($.gcd, [5, 10, 15], $.range(5)); // [ 1, 2, 3 ]

$.iterate(3, "ha!", function (str) {
  return "ha" + str
}); // [ 'ha!', 'haha!', 'hahaha!' ]

[[1,2], [3,4]].map($.invoke('join','w')); // [ '1w2', '3w4']

Read the read the API.

In most cases the operators module provides some almost must have additions to autonomy.

This modules makes up the core part of the larger utility library: interlude. If you find yourself co-using operators or subset, you should use interlude instead (there's also more documentation included for interlude).

Installation

$ npm install autonomy

Running tests

Install development dependencies

$ npm install

Run the tests

$ npm test

License

MIT-Licensed. See LICENSE file for details.

Something went wrong with that request. Please try again.