This is an initial attempt to port some of Python's itertools functions to node.js.
var itertools = require("itertools");
var fruitBaskets = itertools.permutationsSync(["Apple", "Orange", "Banana"], 2);
// fruitBaskets = [['Apple', 'Orange'], ['Apple', 'Banana'], ['Orange', 'Apple'], ['Orange', 'Banana'], ['Banana', 'Apple'], ['Banana', 'Orange']]
var pairs = itertools.combinationsSync([1, 2, 3], 2);
// pairs = [[1, 2], [1, 3], [2, 3]]
$ npm install itertools
OR
$ git clone git://github.com/thegoleffect/node-itertools.git
THEN
var itertools = require('itertools');
Since this is a new port, these are the only functions completed thus far:
itertools.permutationsSync(_iterable[, r]_)
Returns list of r length permutations of elements in the iterable.
itertools.combinationsSync(_iterable_, r)
Returns list of r length combinations (without repetitions) of elements in the iterable.