@bentobots/list
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "@bentobots/list", | ||
"description": "a collection of functions for lists", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"author": "John Rees <john@bitsushi.com>", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/bentobots/bentobots/tree/master/bots/list", |
@@ -12,3 +12,7 @@ import loopifyInGroups, { loopifyInPairs } from "./loopify_in_groups"; | ||
const array = ["a", "b", "c"]; | ||
const result = [["a", "b"], ["b", "c"], ["c", "a"]]; | ||
const result = [ | ||
["a", "b"], | ||
["b", "c"], | ||
["c", "a"] | ||
]; | ||
expect(loopifyInPairs(array)).toEqual(result); | ||
@@ -20,3 +24,7 @@ expect(loopifyInGroups(2)(array)).toEqual(result); | ||
const array = [["a"], "b", [["c"]]]; | ||
const result = [[["a"], "b"], ["b", [["c"]]], [[["c"]], ["a"]]]; | ||
const result = [ | ||
[["a"], "b"], | ||
["b", [["c"]]], | ||
[[["c"]], ["a"]] | ||
]; | ||
expect(loopifyInPairs(array)).toEqual(result); | ||
@@ -39,11 +47,21 @@ expect(loopifyInGroups(2)(array)).toEqual(result); | ||
const array = ["a", "b", "c", "d", "e", "f"]; | ||
let result = [["a", "b", "c"], ["c", "d", "e"], ["e", "f", "a"]]; | ||
let result = [ | ||
["a", "b", "c"], | ||
["c", "d", "e"], | ||
["e", "f", "a"] | ||
]; | ||
expect(loopifyInGroups(3, 1)(array)).toEqual(result); | ||
result = [["a", "b", "c"], ["d", "e", "f"]]; | ||
result = [ | ||
["a", "b", "c"], | ||
["d", "e", "f"] | ||
]; | ||
expect(loopifyInGroups(3, 2)(array)).toEqual(result); | ||
result = [["a", "b", "c"], ["e", "f", "a"]]; | ||
result = [ | ||
["a", "b", "c"], | ||
["e", "f", "a"] | ||
]; | ||
expect(loopifyInGroups(3, 3)(array)).toEqual(result); | ||
}); | ||
}); |
@@ -8,3 +8,3 @@ /** | ||
if (index < 0) { | ||
return (arrayLength + index % arrayLength) % arrayLength; | ||
return (arrayLength + (index % arrayLength)) % arrayLength; | ||
} else if (index >= arrayLength) { | ||
@@ -11,0 +11,0 @@ return index % arrayLength; |
4947
10
159