Last active
August 29, 2015 14:07
Revisions
-
yckart revised this gist
Oct 17, 2014 . 2 changed files with 11 additions and 11 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ ```javascript var array = [1, 2, 3, 4, 5, 6, 7, 8]; var iterator = 0; console.log( array.slice(iterator, iterator += 1) ); // => [1] console.log( array.slice(iterator, iterator += 2) ); // => [2, 3] console.log( array.slice(iterator, iterator += 3) ); // => [4, 5, 6] ``` The usage, with the utility-function below, is quite simple: ```javascript var step = stepArray([1, 2, 3, 4, 5, 6, 7, 8]); console.log( step(1) ); // => [1] console.log( step(2) ); // => [2, 3] console.log( step(3) ); // => [4, 5, 6] ``` This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ var stepArray = function (array) { var iterator = 0; return function (index) { return array.slice(iterator, iterator += index); }; }; -
yckart revised this gist
Oct 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ console.log( array.slice(index, index += 2) ); // => [2, 3] console.log( array.slice(index, index += 3) ); // => [4, 5, 6] ``` The usage, with the utility-function below, is quite simple: ```javascript var steppable = stepArray([1, 2, 3, 4, 5, 6, 7, 8]); -
yckart created this gist
Oct 17, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ ```javascript var array = [1, 2, 3, 4, 5, 6, 7, 8]; var index = 0; console.log( array.slice(index, index += 1) ); // => [1] console.log( array.slice(index, index += 2) ); // => [2, 3] console.log( array.slice(index, index += 3) ); // => [4, 5, 6] ``` The usage with the utility-function below is quite simple: ```javascript var steppable = stepArray([1, 2, 3, 4, 5, 6, 7, 8]); console.log( steppable(1) ); // => [1] console.log( steppable(2) ); // => [2, 3] console.log( steppable(3) ); // => [4, 5, 6] ``` This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ var stepArray = function (array) { var index = 0; return function (step) { return array.slice(index, index += step); }; };