extra-array
Advanced tools
Comparing version 2.0.10 to 2.0.11
19
fresh.js
@@ -69,5 +69,21 @@ // PURE FUNCTIONS | ||
/** | ||
* Splits array to elements which do, and dont satify the filter. | ||
* @param {array} x array | ||
* @param {function} fn filter function (elem, index, array) | ||
* @param {object?} ths this argument | ||
* @returns {array} pair of arrays [satisfy, dont_satisfy] | ||
*/ | ||
function partition(x, fn, ths=null) { | ||
var t = [], f = [], i = -1; | ||
for(var e of x) { | ||
if(fn.call(ths, e, ++i, x)) t.push(e); | ||
else f.push(e); | ||
} | ||
return [t, f]; | ||
} | ||
/** | ||
* Combines values from n arrays, with a function. | ||
* @param {array} xs n arrays | ||
* @param {function} fn combiner (a, b, c, ...) | ||
* @param {function} fn combine function (a, b, c, ...) | ||
* @param {object?} ths this argument | ||
@@ -115,3 +131,4 @@ * @returns {array} combined values | ||
exports.min = min; | ||
exports.partition = partition; | ||
exports.zip = zip; | ||
exports.append = append; |
{ | ||
"name": "extra-array", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "Standard utility methods for Array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
21905
553