Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "chunk", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Chunk converts arrays like `[1,2,3,4,5]` into arrays of arrays like `[[1,2], [3,4], [5]]`.", | ||
@@ -17,8 +17,9 @@ "main": "src/chunk.js", | ||
"devDependencies": { | ||
"mocha": "^1.21.4", | ||
"should": "^4.0.4" | ||
"mocha": "^8.1.1", | ||
"prettier": "^2.0.5", | ||
"should": "^13.2.3" | ||
}, | ||
"scripts": { | ||
"test": "mocha --reporter spec --timeout 10000 test/tests.js" | ||
"test": "mocha --reporter spec test/tests.js" | ||
} | ||
} |
@@ -0,1 +1,4 @@ | ||
![Build](https://github.com/ryancole/chunk/workflows/Build/badge.svg) | ||
![Release](https://github.com/ryancole/chunk/workflows/Release/badge.svg) | ||
Chunk converts arrays like `[1,2,3,4,5]` into arrays of arrays like `[[1,2], [3,4], [5]]`. | ||
@@ -5,3 +8,3 @@ | ||
You can install chunk using npm. | ||
You can install chunk using npm ... | ||
@@ -12,2 +15,8 @@ ``` | ||
or bower ... | ||
``` | ||
bower install chunk | ||
``` | ||
## Examples | ||
@@ -14,0 +23,0 @@ |
"use strict"; | ||
(function () { | ||
function chunk(collection, size) { | ||
var result = []; | ||
function chunk (collection, size) { | ||
var result = []; | ||
// default size to two item | ||
size = parseInt(size) || 2; | ||
// add each chunk to the result | ||
for (var x = 0; x < Math.ceil(collection.length / size); x++) { | ||
var start = x * size; | ||
var end = start + size; | ||
result.push(collection.slice(start, end)); | ||
} | ||
return result; | ||
}; | ||
// default size to two item | ||
size = parseInt(size) || 2; | ||
// export in node or browser | ||
if (typeof exports !== 'undefined') { | ||
if (typeof module !== 'undefined' && module.exports) { | ||
exports = module.exports = chunk; | ||
} | ||
exports.chunk = chunk; | ||
} else { | ||
this.chunk = chunk; | ||
// add each chunk to the result | ||
for (var x = 0; x < Math.ceil(collection.length / size); x++) { | ||
var start = x * size; | ||
var end = start + size; | ||
result.push(collection.slice(start, end)); | ||
} | ||
return result; | ||
} | ||
// export in node or browser | ||
if (typeof exports !== "undefined") { | ||
if (typeof module !== "undefined" && module.exports) { | ||
exports = module.exports = chunk; | ||
} | ||
exports.chunk = chunk; | ||
} else { | ||
this.chunk = chunk; | ||
} | ||
}.call(this)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3760
8
40
3
36