Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ var combo = function(a, min, max) {
return;
}
var all = [];
for (var i = min; i < a.length; i++) {
for (var i = min; i <= max; i++) {
fn(i, a, [], all);
}
if(a.length == max) all.push(a);
return all;
}
module.exports = combo;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "combinations",
"version": "0.1.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json changes when we do a release, can you remove this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the version as NPM don't check the changes...
DOCS

"version": "0.1.3",
"description": "find all combinations from array",
"main": "index.js",
"repository": {
Expand Down
6 changes: 6 additions & 0 deletions test/combo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ suite('combo', function() {
assert.deepEqual(out, [ [ 'a', 'b' ], [ 'a', 'c' ], [ 'a', 'd'], [ 'b', 'c' ], [ 'b', 'd'], [ 'c', 'd' ], [ 'a', 'b', 'c' ], [ 'a', 'b', 'd' ], [ 'a', 'c', 'd' ], [ 'b', 'c', 'd' ] ]);
});

test('4 item array with min 3 and max 3 elements', function() {
var out = combo(['a', 'b', 'c', 'd'],3,3);

assert.deepEqual(out, [ [ 'a', 'b', 'c' ], [ 'a', 'b', 'd' ], [ 'a', 'c', 'd' ], [ 'b', 'c', 'd' ] ]);
});

});