Comparing version 0.0.19 to 0.0.20
77
fx.js
@@ -165,22 +165,63 @@ export const | ||
export const take = curry((l, iter) => { | ||
if (l === 0) return []; | ||
let res = []; | ||
iter = L.values(iter); | ||
return function recur() { | ||
let cur; | ||
while (!(cur = iter.next()).done) { | ||
const a = cur.value; | ||
if (a instanceof Promise) { | ||
return a | ||
.then(a => (res.push(a), res).length == l ? res : recur()) | ||
.catch(e => e == nop ? recur() : Promise.reject(e)); | ||
export const | ||
take = curry((l, iter) => { | ||
if (l === 0) return []; | ||
let res = []; | ||
iter = L.values(iter); | ||
return function recur() { | ||
let cur; | ||
while (!(cur = iter.next()).done) { | ||
const a = cur.value; | ||
if (a instanceof Promise) { | ||
return a | ||
.then(a => (res.push(a), res).length == l ? res : recur()) | ||
.catch(e => e == nop ? recur() : Promise.reject(e)); | ||
} | ||
res.push(a); | ||
if (res.length == l) return res; | ||
} | ||
res.push(a); | ||
if (res.length == l) return res; | ||
} | ||
return res; | ||
} (); | ||
}); | ||
return res; | ||
} (); | ||
}), | ||
takeWhile = curry((f, iter) => { | ||
let res = []; | ||
iter = L.values(iter); | ||
return function recur() { | ||
let cur; | ||
while (!(cur = iter.next()).done) { | ||
const a = cur.value; | ||
const b = go1(a, f); | ||
if (!b) return res; | ||
if (b instanceof Promise) { | ||
return b | ||
.then(async b => b ? (res.push(await a), recur()) : res) | ||
.catch(e => e == nop ? recur() : Promise.reject(e)); | ||
} | ||
res.push(a); | ||
} | ||
return res; | ||
} (); | ||
}), | ||
takeUntil = curry((f, iter) => { | ||
let res = []; | ||
iter = L.values(iter); | ||
return function recur() { | ||
let cur; | ||
while (!(cur = iter.next()).done) { | ||
const a = cur.value; | ||
const b = go1(a, f); | ||
if (b instanceof Promise) { | ||
return b | ||
.then(async b => (res.push(await a), b) ? res : recur()) | ||
.catch(e => e == nop ? recur() : Promise.reject(e)); | ||
} | ||
res.push(a); | ||
if (b) break; | ||
} | ||
return res; | ||
} (); | ||
}); | ||
export const | ||
@@ -187,0 +228,0 @@ takeAll = take(Infinity), |
{ | ||
"name": "fxjs2", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "Functional Extensions for Javascript", | ||
@@ -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
15214
379