Comparing version 0.1.0 to 0.1.1
41
fx.js
@@ -104,7 +104,25 @@ export const | ||
L.flat = L.flatten = function *(iter) { | ||
for (const a of iter) { | ||
if (hasIter(a)) yield *a; | ||
else yield a; | ||
} | ||
L.flat = L.flatten = function(iter) { | ||
iter = iter[Symbol.iterator](); | ||
let flatting = null; | ||
return { | ||
next() { | ||
if (flatting) { | ||
const cur = flatting.next(); | ||
if (!cur.done) return cur; | ||
else flatting = null; | ||
} | ||
const cur = iter.next(); | ||
if (cur.done) return cur; | ||
return { | ||
value: go1(cur.value, value => { | ||
if (!hasIter(value)) return cur; | ||
flatting = value[Symbol.iterator](); | ||
return flatting.next().value; | ||
}), | ||
done: false | ||
}; | ||
}, | ||
[Symbol.iterator]() { return this; } | ||
}; | ||
}; | ||
@@ -194,3 +212,3 @@ | ||
const a = cur.value; | ||
const b = go1(a, f); | ||
const b = go1(a, a => f(a, res)); | ||
if (!b) return res; | ||
@@ -217,9 +235,5 @@ if (b instanceof Promise) { | ||
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); | ||
const b = go1(a, a => (res.push(a), f(a, res))); | ||
if (b instanceof Promise) | ||
return b.then(b => b ? res : recur()).catch(e => e == nop ? recur() : Promise.reject(e)); | ||
if (b) break; | ||
@@ -233,2 +247,3 @@ } | ||
export const | ||
@@ -235,0 +250,0 @@ takeAll = take(Infinity), |
{ | ||
"name": "fxjs2", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"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
15699
395