From 4d9e7ba3ad40f3b8c3f4b04acf8c50cf8c190e9f Mon Sep 17 00:00:00 2001 From: iX315 Date: Sun, 16 Apr 2017 23:05:42 +0200 Subject: [PATCH 1/3] version fix --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d9561e..6f46c22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "combinations", - "version": "0.1.1", + "version": "0.1.2", "description": "find all combinations from array", "main": "index.js", "repository": { From ee6385548587e1d6a2d9698db278917dd57ec15c Mon Sep 17 00:00:00 2001 From: iX315 Date: Sun, 16 Apr 2017 23:06:14 +0200 Subject: [PATCH 2/3] bugfix --- index.js | 3 +-- package.json | 2 +- test/combo.test.js | 6 ++++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 0e616bf..eacb354 100644 --- a/index.js +++ b/index.js @@ -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; diff --git a/package.json b/package.json index 6f46c22..2ae8496 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "combinations", - "version": "0.1.2", + "version": "0.1.3", "description": "find all combinations from array", "main": "index.js", "repository": { diff --git a/test/combo.test.js b/test/combo.test.js index 95d4771..19d5280 100644 --- a/test/combo.test.js +++ b/test/combo.test.js @@ -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' ] ]); + }); + }); From 86282116469869cb9e17e6477719fa06f12d11f8 Mon Sep 17 00:00:00 2001 From: iX315 Date: Wed, 19 Apr 2017 18:44:33 +0200 Subject: [PATCH 3/3] rollback --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ae8496..3d9561e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "combinations", - "version": "0.1.3", + "version": "0.1.1", "description": "find all combinations from array", "main": "index.js", "repository": {