Package detail

operators

clux6.7kMIT1.0.0

JavaScript operators as functions

associative, binary, curried, lifted

readme

Operators

npm status build status dependency status coverage status

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 map and filter all the time.

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 { gt, plus, pow, eq, prepend } from '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.

This modules makes is a core part the larger utility library interlude.

License

MIT-Licensed. See LICENSE file for details.

changelog

1.0.0 / 2016-01-27

  • Module rewritten for ES6
  • Variadic functions are removed (add + multiply + concat)

0.1.7 / 2015-11-15

  • Added .npmignore

0.1.6 / 2014-09-02

  • Move coverage to tests area to avoid confusing browserify

0.1.5 / 2014-07-10

  • Documentation and coverage report release only

0.1.4 / 2012-10-26

  • Efficiency improvements of variadic/array functions by manually looping ( Previously used reduce.call(arguments, binOp, init) which is really nice But these functions are used everywhere.. )

0.1.3 / 2012-06-29

  • First good version outside interlude
  • Incorporates log/pow which used to be part of autonomy till now