generate pairings for n-many sets
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example working example Aug 1, 2013
test failing test with array elements Aug 1, 2013
.travis.yml badges Aug 1, 2013
LICENSE package.json etc Aug 1, 2013
index.js fix for array elements, test passes Aug 1, 2013
package.json badges Aug 1, 2013
readme.markdown badges Aug 1, 2013

readme.markdown

n-pair

generate pairings for n-many sets

testling badge

build status

example

var npair = require('n-pair');

npair([['a','b','c'],[1,2,3,4,5],['y','z']], function (x) {
    console.dir(x);
});

output:

[ 'a', 1, 'y' ]
[ 'a', 1, 'z' ]
[ 'a', 2, 'y' ]
[ 'a', 2, 'z' ]
[ 'a', 3, 'y' ]
[ 'a', 3, 'z' ]
[ 'a', 4, 'y' ]
[ 'a', 4, 'z' ]
[ 'a', 5, 'y' ]
[ 'a', 5, 'z' ]
[ 'b', 1, 'y' ]
[ 'b', 1, 'z' ]
[ 'b', 2, 'y' ]
[ 'b', 2, 'z' ]
[ 'b', 3, 'y' ]
[ 'b', 3, 'z' ]
[ 'b', 4, 'y' ]
[ 'b', 4, 'z' ]
[ 'b', 5, 'y' ]
[ 'b', 5, 'z' ]
[ 'c', 1, 'y' ]
[ 'c', 1, 'z' ]
[ 'c', 2, 'y' ]
[ 'c', 2, 'z' ]
[ 'c', 3, 'y' ]
[ 'c', 3, 'z' ]
[ 'c', 4, 'y' ]
[ 'c', 4, 'z' ]
[ 'c', 5, 'y' ]
[ 'c', 5, 'z' ]

methods

var npair = require('n-pair')

npair(sets, cb)

Pair each array in the array sets together in all the possible combinations, calling cb(pairing) with each possible pairing.

install

With npm do:

npm install n-pair

license

MIT