Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

JavaScript operators as functions

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .npmignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 History.md
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 api.md
Octocat-spinner-32 operators.js
Octocat-spinner-32 package.json
README.md

Operators

Build Status Dependency Status stable

Operators provides the JavaScript operators as functions. It provides a standard, short, and easy to remember interface for addition, multiplication, concatenation, and-ing, or-ing, as well as several two parameter lambdas for non-associative operators, and curried versions of the binary operators for quick creation of the functions that you end up writing for filter all the time.

Usage

Attach it to the short variable of choice:

var $ = require('operators');
[1,3,2,6,5,4].filter($.gt(4));
// [ 6, 5 ]

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

[1,2,3,4].map($.pow(2)); // [ 1, 4, 9, 16 ]

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

[ [1,2], [3,4] ].map($.prepend([0])); // [ [ 0, 1, 2 ], [ 0, 3, 4 ] ]

Read the API.

We advocate using this module with one of the utility libraries it was made for:

  • autonomy a super-lightweight utility library
  • interlude a bigger utility library containing autonomy

But they will obviously work well by themselves.

Installation

$ npm install operators

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.