Doublescore.js is a project mainly written in JavaScript, it's free.
Python's itertools and functools implemented in JavaScript.
This library serves as an JavaScript adaptation of the itertools and functools built-in libraries of the Python language.
__.iterator will return a Python iterator inspired object. Looping through them can be done via the following:
var iterator = __.iterator(0, function(c) { return c + 1; }, function(c) { return c > 3; });
while ((c = iterator.next()) != __.stop) {
console.log(c);
}
Most of these functions can be found within Python's itertools documentation. They will be reiterated here for the sake of minor discrepencies and convienience.
Curries a function. Currying is to create a new function signature with the original function arguments prefilled with arguments
. ie:
var add = function(a, b) { return a + b; }
var addToTwo = __.partial(add, 2);
addToTwo(3); // 5
Alias for __.partial().
See Python's reduce()
Creates a true boolean from an entity (ie: nonzero)
Creates a sequence from an entity. ie:
__.iterable([1, 2, 3]); // [1, 2, 3]
__.iterable('ABCD'); // ['A', 'B', 'C', 'D']
__.iterable(1); // [1]
Constructs a range.
Reverses the order of an iterator. ie:
__.reverse([1, 2, 3]); // [3, 2, 1]
Returns a set
an sequence of unique elements.
__.set([1, 1, 2, 3, 3]); // [3, 2, 1]
Returns the iterable from iterables with the smallest length.
Like __.smallest(), but returns the largest iterable.
if (_ && _.mixin) {
_.mixin(__);
}
if ($ && $.extend) {
$.extend($, __);
}