Skip to content

Given n-arrays of varaible length, find all of the combinations using one member from each.

Notifications You must be signed in to change notification settings

brianloveswords/sandwich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sandwich Build Status

Iterator generator for getting ordered combinations of items.

install

$ npm install sandwich

example

const sandwich = require('sandwich');
const adverbs = ['very'];
const adjectives = ['woeful', 'lethargic', 'blissful'];
const animals = ['sloth', 'bear', 'hawk'];
const iter = sandwich(adverbs, adjectives, animals);

iter.next(); // [ 'very', 'woeful', 'sloth' ]
iter.next(); // [ 'very', 'lethargic', 'sloth' ]
iter.next(); // [ 'very', 'blissful', 'sloth' ]
iter.next(); // [ 'very', 'woeful', 'bear' ]
iter.next(); // [ 'very', 'lethargic', 'bear' ]
iter.next(); // [ 'very', 'blissful', 'bear' ]
iter.next(); // [ 'very', 'woeful', 'hawk' ]
iter.next(); // [ 'very', 'lethargic', 'hawk' ]
iter.next(); // [ 'very', 'blissful', 'hawk' ]
iter.next(); // null

iter.random(); // [ 'very', 'lethargic', 'sloth' ]
iter.random(); // [ 'very', 'woeful', 'sloth' ]
iter.random(); // [ 'very', 'lethargic', 'bear' ]
iter.random(); // [ 'very', 'woeful', 'bear' ]

License

MIT/X11

About

Given n-arrays of varaible length, find all of the combinations using one member from each.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published