Comparing version 1.1.1-alpha.0 to 1.1.1
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function delay(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
var delay_default = delay; | ||
exports.default = delay_default; | ||
exports.delay = delay; | ||
function r(e){return new Promise(t=>setTimeout(t,e))}var o=r; | ||
exports.default = o; | ||
exports.delay = r; | ||
//# sourceMappingURL=delay.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function filter(arr, filterFn = Boolean) { | ||
const arr2 = await map(arr, async (i) => ({ | ||
i, | ||
f: filterFn(i) | ||
})); | ||
return arr2.filter((i) => i.f).map((i) => i.i); | ||
} | ||
var filter_default = filter; | ||
exports.default = filter_default; | ||
exports.filter = filter; | ||
function w(e,n,{concurrency:r=1/0}={concurrency:1/0}){if(typeof r!="number")throw new TypeError(`${String(r)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let t=n||(o=>o);return new Promise((o,y)=>{let f=0,i=0,a=0,m=new Array(e.length).fill(void 0),u=!1;function I(l){let c=e[l];Promise.resolve(t.call(c,c,l,e)).then(s=>{a--,f++,m[l]=s,p();}).catch(s=>{u=!0,y(s);});}function p(){if(!u){if(f>=e.length){o(m);return}for(;a<r&&i<e.length;)I(i),a++,i++;}}p();})}async function N(e,n=Boolean){return (await w(e,async t=>({i:t,f:n(t)}))).filter(t=>t.f).map(t=>t.i)}var A=N; | ||
exports.default = A; | ||
exports.filter = N; | ||
//# sourceMappingURL=filter.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function delay(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function filter(arr, filterFn = Boolean) { | ||
const arr2 = await map(arr, async (i) => ({ | ||
i, | ||
f: filterFn(i) | ||
})); | ||
return arr2.filter((i) => i.f).map((i) => i.i); | ||
} | ||
function mapSeries(arr, fn) { | ||
return map(arr, fn, { concurrency: 1 }); | ||
} | ||
async function props(obj, fn, options) { | ||
const isMap = obj instanceof Map; | ||
if (!Array.isArray(obj) && !isMap && typeof obj !== "object") { | ||
throw new TypeError(`input must be object, array or map, but got ${typeof obj}`); | ||
} | ||
const keys = isMap ? Array.from(obj.keys()) : Object.keys(obj); | ||
const rawValues = isMap ? Array.from(obj.values()) : Object.values(obj); | ||
const values = await map(rawValues, fn, options); | ||
const results = isMap ? | ||
new Map() : {}; | ||
keys.forEach((key, index) => { | ||
if (results instanceof Map) { | ||
results.set(key, values[index]); | ||
} else { | ||
results[key] = values[index]; | ||
} | ||
}); | ||
return results; | ||
} | ||
var src_default = { delay, map, mapSeries, filter, props }; | ||
exports.default = src_default; | ||
exports.delay = delay; | ||
exports.filter = filter; | ||
exports.map = map; | ||
exports.mapSeries = mapSeries; | ||
exports.props = props; | ||
function w(e){return new Promise(r=>setTimeout(r,e))}function n(e,r,{concurrency:i=1/0}={concurrency:1/0}){if(typeof i!="number")throw new TypeError(`${String(i)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let t=r||(s=>s);return new Promise((s,l)=>{let p=0,o=0,a=0,m=new Array(e.length).fill(void 0),y=!1;function A(u){let I=e[u];Promise.resolve(t.call(I,I,u,e)).then(c=>{a--,p++,m[u]=c,d();}).catch(c=>{y=!0,l(c);});}function d(){if(!y){if(p>=e.length){s(m);return}for(;a<i&&o<e.length;)A(o),a++,o++;}}d();})}async function O(e,r=Boolean){return (await n(e,async t=>({i:t,f:r(t)}))).filter(t=>t.f).map(t=>t.i)}function N(e,r){return n(e,r,{concurrency:1})}async function T(e,r,i){let t=e instanceof Map;if(!Array.isArray(e)&&!t&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=t?Array.from(e.keys()):Object.keys(e),l=t?Array.from(e.values()):Object.values(e),p=await n(l,r,i),o=t?new Map:{};return s.forEach((a,m)=>{o instanceof Map?o.set(a,p[m]):o[a]=p[m];}),o}var q={delay:w,map:n,mapSeries:N,filter:O,props:T}; | ||
exports.default = q; | ||
exports.delay = w; | ||
exports.filter = O; | ||
exports.map = n; | ||
exports.mapSeries = N; | ||
exports.props = T; | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
var map_default = map; | ||
exports.default = map_default; | ||
exports.map = map; | ||
function h(e,p,{concurrency:t=1/0}={concurrency:1/0}){if(typeof t!="number")throw new TypeError(`${String(t)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let c=p||(n=>n);return new Promise((n,y)=>{let l=0,r=0,i=0,u=new Array(e.length).fill(void 0),f=!1;function w(o){let a=e[o];Promise.resolve(c.call(a,a,o,e)).then(s=>{i--,l++,u[o]=s,m();}).catch(s=>{f=!0,y(s);});}function m(){if(!f){if(l>=e.length){n(u);return}for(;i<t&&r<e.length;)w(r),i++,r++;}}m();})}var d=h; | ||
exports.default = d; | ||
exports.map = h; | ||
//# sourceMappingURL=map.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
function mapSeries(arr, fn) { | ||
return map(arr, fn, { concurrency: 1 }); | ||
} | ||
var mapSeries_default = mapSeries; | ||
exports.default = mapSeries_default; | ||
exports.mapSeries = mapSeries; | ||
function c(e,t,{concurrency:r=1/0}={concurrency:1/0}){if(typeof r!="number")throw new TypeError(`${String(r)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let I=t||(n=>n);return new Promise((n,d)=>{let l=0,i=0,o=0,a=new Array(e.length).fill(void 0),m=!1;function w(s){let p=e[s];Promise.resolve(I.call(p,p,s,e)).then(u=>{o--,l++,a[s]=u,f();}).catch(u=>{m=!0,d(u);});}function f(){if(!m){if(l>=e.length){n(a);return}for(;o<r&&i<e.length;)w(i),o++,i++;}}f();})}function O(e,t){return c(e,t,{concurrency:1})}var A=O; | ||
exports.default = A; | ||
exports.mapSeries = O; | ||
//# sourceMappingURL=mapSeries.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function props(obj, fn, options) { | ||
const isMap = obj instanceof Map; | ||
if (!Array.isArray(obj) && !isMap && typeof obj !== "object") { | ||
throw new TypeError(`input must be object, array or map, but got ${typeof obj}`); | ||
} | ||
const keys = isMap ? Array.from(obj.keys()) : Object.keys(obj); | ||
const rawValues = isMap ? Array.from(obj.values()) : Object.values(obj); | ||
const values = await map(rawValues, fn, options); | ||
const results = isMap ? | ||
new Map() : {}; | ||
keys.forEach((key, index) => { | ||
if (results instanceof Map) { | ||
results.set(key, values[index]); | ||
} else { | ||
results[key] = values[index]; | ||
} | ||
}); | ||
return results; | ||
} | ||
var props_default = props; | ||
exports.default = props_default; | ||
exports.props = props; | ||
function O(e,l,{concurrency:n=1/0}={concurrency:1/0}){if(typeof n!="number")throw new TypeError(`${String(n)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let r=l||(s=>s);return new Promise((s,p)=>{let i=0,t=0,o=0,a=new Array(e.length).fill(void 0),u=!1;function w(c){let y=e[c];Promise.resolve(r.call(y,y,c,e)).then(f=>{o--,i++,a[c]=f,m();}).catch(f=>{u=!0,p(f);});}function m(){if(!u){if(i>=e.length){s(a);return}for(;o<n&&t<e.length;)w(t),o++,t++;}}m();})}async function d(e,l,n){let r=e instanceof Map;if(!Array.isArray(e)&&!r&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=r?Array.from(e.keys()):Object.keys(e),p=r?Array.from(e.values()):Object.values(e),i=await O(p,l,n),t=r?new Map:{};return s.forEach((o,a)=>{t instanceof Map?t.set(o,i[a]):t[o]=i[a];}),t}var U=d; | ||
exports.default = U; | ||
exports.props = d; | ||
//# sourceMappingURL=props.js.map |
@@ -1,6 +0,3 @@ | ||
function delay(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
var delay_default = delay; | ||
export { delay_default as default, delay }; | ||
function r(e){return new Promise(t=>setTimeout(t,e))}var u=r; | ||
export { u as default, r as delay }; | ||
//# sourceMappingURL=delay.js.map |
@@ -1,52 +0,3 @@ | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function filter(arr, filterFn = Boolean) { | ||
const arr2 = await map(arr, async (i) => ({ | ||
i, | ||
f: filterFn(i) | ||
})); | ||
return arr2.filter((i) => i.f).map((i) => i.i); | ||
} | ||
var filter_default = filter; | ||
export { filter_default as default, filter }; | ||
function w(e,n,{concurrency:r=1/0}={concurrency:1/0}){if(typeof r!="number")throw new TypeError(`${String(r)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let t=n||(o=>o);return new Promise((o,y)=>{let f=0,i=0,a=0,m=new Array(e.length).fill(void 0),u=!1;function I(l){let c=e[l];Promise.resolve(t.call(c,c,l,e)).then(s=>{a--,f++,m[l]=s,p();}).catch(s=>{u=!0,y(s);});}function p(){if(!u){if(f>=e.length){o(m);return}for(;a<r&&i<e.length;)I(i),a++,i++;}}p();})}async function h(e,n=Boolean){return (await w(e,async t=>({i:t,f:n(t)}))).filter(t=>t.f).map(t=>t.i)}var P=h; | ||
export { P as default, h as filter }; | ||
//# sourceMappingURL=filter.js.map |
@@ -1,77 +0,3 @@ | ||
function delay(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function filter(arr, filterFn = Boolean) { | ||
const arr2 = await map(arr, async (i) => ({ | ||
i, | ||
f: filterFn(i) | ||
})); | ||
return arr2.filter((i) => i.f).map((i) => i.i); | ||
} | ||
function mapSeries(arr, fn) { | ||
return map(arr, fn, { concurrency: 1 }); | ||
} | ||
async function props(obj, fn, options) { | ||
const isMap = obj instanceof Map; | ||
if (!Array.isArray(obj) && !isMap && typeof obj !== "object") { | ||
throw new TypeError(`input must be object, array or map, but got ${typeof obj}`); | ||
} | ||
const keys = isMap ? Array.from(obj.keys()) : Object.keys(obj); | ||
const rawValues = isMap ? Array.from(obj.values()) : Object.values(obj); | ||
const values = await map(rawValues, fn, options); | ||
const results = isMap ? | ||
new Map() : {}; | ||
keys.forEach((key, index) => { | ||
if (results instanceof Map) { | ||
results.set(key, values[index]); | ||
} else { | ||
results[key] = values[index]; | ||
} | ||
}); | ||
return results; | ||
} | ||
var src_default = { delay, map, mapSeries, filter, props }; | ||
export { src_default as default, delay, filter, map, mapSeries, props }; | ||
function O(e){return new Promise(r=>setTimeout(r,e))}function n(e,r,{concurrency:i=1/0}={concurrency:1/0}){if(typeof i!="number")throw new TypeError(`${String(i)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let t=r||(s=>s);return new Promise((s,u)=>{let p=0,o=0,a=0,m=new Array(e.length).fill(void 0),d=!1;function U(c){let w=e[c];Promise.resolve(t.call(w,w,c,e)).then(y=>{a--,p++,m[c]=y,I();}).catch(y=>{d=!0,u(y);});}function I(){if(!d){if(p>=e.length){s(m);return}for(;a<i&&o<e.length;)U(o),a++,o++;}}I();})}async function N(e,r=Boolean){return (await n(e,async t=>({i:t,f:r(t)}))).filter(t=>t.f).map(t=>t.i)}function T(e,r){return n(e,r,{concurrency:1})}async function A(e,r,i){let t=e instanceof Map;if(!Array.isArray(e)&&!t&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=t?Array.from(e.keys()):Object.keys(e),u=t?Array.from(e.values()):Object.values(e),p=await n(u,r,i),o=t?new Map:{};return s.forEach((a,m)=>{o instanceof Map?o.set(a,p[m]):o[a]=p[m];}),o}var z={delay:O,map:n,mapSeries:T,filter:N,props:A}; | ||
export { z as default, O as delay, N as filter, n as map, T as mapSeries, A as props }; | ||
//# sourceMappingURL=index.js.map |
@@ -1,45 +0,3 @@ | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
var map_default = map; | ||
export { map_default as default, map }; | ||
function h(e,p,{concurrency:t=1/0}={concurrency:1/0}){if(typeof t!="number")throw new TypeError(`${String(t)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let c=p||(n=>n);return new Promise((n,y)=>{let l=0,r=0,i=0,u=new Array(e.length).fill(void 0),f=!1;function w(o){let a=e[o];Promise.resolve(c.call(a,a,o,e)).then(s=>{i--,l++,u[o]=s,m();}).catch(s=>{f=!0,y(s);});}function m(){if(!f){if(l>=e.length){n(u);return}for(;i<t&&r<e.length;)w(r),i++,r++;}}m();})}var I=h; | ||
export { I as default, h as map }; | ||
//# sourceMappingURL=map.js.map |
@@ -1,48 +0,3 @@ | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
function mapSeries(arr, fn) { | ||
return map(arr, fn, { concurrency: 1 }); | ||
} | ||
var mapSeries_default = mapSeries; | ||
export { mapSeries_default as default, mapSeries }; | ||
function c(e,t,{concurrency:r=1/0}={concurrency:1/0}){if(typeof r!="number")throw new TypeError(`${String(r)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let I=t||(n=>n);return new Promise((n,d)=>{let l=0,i=0,o=0,a=new Array(e.length).fill(void 0),m=!1;function w(s){let p=e[s];Promise.resolve(I.call(p,p,s,e)).then(u=>{o--,l++,a[s]=u,f();}).catch(u=>{m=!0,d(u);});}function f(){if(!m){if(l>=e.length){n(a);return}for(;o<r&&i<e.length;)w(i),o++,i++;}}f();})}function N(e,t){return c(e,t,{concurrency:1})}var U=N; | ||
export { U as default, N as mapSeries }; | ||
//# sourceMappingURL=mapSeries.js.map |
@@ -1,64 +0,3 @@ | ||
function map(arr, fn, { concurrency = Infinity } = { concurrency: Infinity }) { | ||
if (typeof concurrency !== "number") { | ||
throw new TypeError(`${String(concurrency)} is not a number`); | ||
} | ||
if (!Array.isArray(arr)) { | ||
throw new TypeError(`arr must be collection, but got ${typeof arr}`); | ||
} | ||
const fn2 = fn || ((item) => item); | ||
return new Promise((resolve, reject) => { | ||
let completed = 0; | ||
let started = 0; | ||
let running = 0; | ||
const results = new Array(arr.length).fill(void 0); | ||
let rejected = false; | ||
function start(index) { | ||
const cur = arr[index]; | ||
Promise.resolve(fn2.call(cur, cur, index, arr)).then((result) => { | ||
running--; | ||
completed++; | ||
results[index] = result; | ||
replenish(); | ||
}).catch((err) => { | ||
rejected = true; | ||
reject(err); | ||
}); | ||
} | ||
function replenish() { | ||
if (rejected) | ||
return; | ||
if (completed >= arr.length) { | ||
resolve(results); | ||
return; | ||
} | ||
while (running < concurrency && started < arr.length) { | ||
start(started); | ||
running++; | ||
started++; | ||
} | ||
} | ||
replenish(); | ||
}); | ||
} | ||
async function props(obj, fn, options) { | ||
const isMap = obj instanceof Map; | ||
if (!Array.isArray(obj) && !isMap && typeof obj !== "object") { | ||
throw new TypeError(`input must be object, array or map, but got ${typeof obj}`); | ||
} | ||
const keys = isMap ? Array.from(obj.keys()) : Object.keys(obj); | ||
const rawValues = isMap ? Array.from(obj.values()) : Object.values(obj); | ||
const values = await map(rawValues, fn, options); | ||
const results = isMap ? | ||
new Map() : {}; | ||
keys.forEach((key, index) => { | ||
if (results instanceof Map) { | ||
results.set(key, values[index]); | ||
} else { | ||
results[key] = values[index]; | ||
} | ||
}); | ||
return results; | ||
} | ||
var props_default = props; | ||
export { props_default as default, props }; | ||
function O(e,l,{concurrency:n=1/0}={concurrency:1/0}){if(typeof n!="number")throw new TypeError(`${String(n)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let r=l||(s=>s);return new Promise((s,p)=>{let i=0,t=0,o=0,a=new Array(e.length).fill(void 0),u=!1;function w(c){let y=e[c];Promise.resolve(r.call(y,y,c,e)).then(f=>{o--,i++,a[c]=f,m();}).catch(f=>{u=!0,p(f);});}function m(){if(!u){if(i>=e.length){s(a);return}for(;o<n&&t<e.length;)w(t),o++,t++;}}m();})}async function T(e,l,n){let r=e instanceof Map;if(!Array.isArray(e)&&!r&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=r?Array.from(e.keys()):Object.keys(e),p=r?Array.from(e.values()):Object.values(e),i=await O(p,l,n),t=r?new Map:{};return s.forEach((o,a)=>{t instanceof Map?t.set(o,i[a]):t[o]=i[a];}),t}var g=T; | ||
export { g as default, T as props }; | ||
//# sourceMappingURL=props.js.map |
{ | ||
"name": "fishbird", | ||
"version": "1.1.1-alpha.0", | ||
"version": "1.1.1", | ||
"description": "Fishbird is a simple, lightweight, and fast Promise utility library", | ||
@@ -52,2 +52,2 @@ "author": "Igor Suvorov <hi@isuvorov.com> (https://github.com/isuvorov)", | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
60470
46
153