Comparing version 1.0.1 to 1.1.0
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function r(e){return new Promise(t=>setTimeout(t,e))}var o=r; | ||
exports.default = o; | ||
exports.delay = r; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=delay.js.map |
import delay from './delay.js'; | ||
import filter from './filter.js'; | ||
import map from './map.js'; | ||
@@ -11,5 +12,6 @@ import mapSeries from './mapSeries.js'; | ||
mapSeries: typeof mapSeries; | ||
filter: typeof filter; | ||
props: typeof props; | ||
}; | ||
export { _default as default, delay, map, mapSeries, props }; | ||
export { _default as default, delay, filter, map, mapSeries, props }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function I(e){return new Promise(r=>setTimeout(r,e))}function i(e,r,{concurrency:s=1/0}={concurrency:1/0}){if(typeof s!="number")throw new TypeError(`${String(s)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let o=r||(a=>a);return new Promise((a,l)=>{let p=0,t=0,n=0,m=new Array(e.length).fill(void 0),y=!1;function N(u){let O=e[u];Promise.resolve(o.call(O,O,u,e)).then(c=>{n--,p++,m[u]=c,d();}).catch(c=>{y=!0,l(c);});}function d(){if(!y){if(p>=e.length){a(m);return}for(;n<s&&t<e.length;)N(t),n++,t++;}}d();})}function w(e,r){return i(e,r,{concurrency:1})}async function T(e,r,s){let o=e instanceof Map;if(!Array.isArray(e)&&!o&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let a=o?Array.from(e.keys()):Object.keys(e),l=o?Array.from(e.values()):Object.values(e),p=await i(l,r,s),t=o?new Map:{};return a.forEach((n,m)=>{t instanceof Map?t.set(n,p[m]):t[n]=p[m];}),t}var $={delay:I,map:i,mapSeries:w,props:T}; | ||
exports.default = $; | ||
function I(e){return new Promise(t=>setTimeout(t,e))}function o(e,t,{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 n=t||(s=>s);return new Promise((s,l)=>{let p=0,r=0,a=0,m=new Array(e.length).fill(void 0),y=!1;function U(u){let d=e[u];Promise.resolve(n.call(d,d,u,e)).then(c=>{a--,p++,m[u]=c,O();}).catch(c=>{y=!0,l(c);});}function O(){if(!y){if(p>=e.length){s(m);return}for(;a<i&&r<e.length;)U(r),a++,r++;}}O();})}async function w(e,t,i){return (await o(e,t,i)).filter(Boolean)}function N(e,t){return o(e,t,{concurrency:1})}async function T(e,t,i){let n=e instanceof Map;if(!Array.isArray(e)&&!n&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=n?Array.from(e.keys()):Object.keys(e),l=n?Array.from(e.values()):Object.values(e),p=await o(l,t,i),r=n?new Map:{};return s.forEach((a,m)=>{r instanceof Map?r.set(a,p[m]):r[a]=p[m];}),r}var q={delay:I,map:o,mapSeries:N,filter:w,props:T}; | ||
exports.default = q; | ||
exports.delay = I; | ||
exports.map = i; | ||
exports.mapSeries = w; | ||
exports.filter = w; | ||
exports.map = o; | ||
exports.mapSeries = N; | ||
exports.props = T; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
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=out.js.map | ||
//# sourceMappingURL=map.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
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=out.js.map | ||
//# sourceMappingURL=mapSeries.js.map |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
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=out.js.map | ||
//# sourceMappingURL=props.js.map |
'use strict'; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=types.js.map |
function r(e){return new Promise(t=>setTimeout(t,e))}var u=r; | ||
export { u as default, r as delay }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=delay.js.map |
@@ -1,5 +0,3 @@ | ||
function w(e){return new Promise(r=>setTimeout(r,e))}function i(e,r,{concurrency:s=1/0}={concurrency:1/0}){if(typeof s!="number")throw new TypeError(`${String(s)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let o=r||(a=>a);return new Promise((a,u)=>{let p=0,t=0,n=0,m=new Array(e.length).fill(void 0),d=!1;function U(c){let I=e[c];Promise.resolve(o.call(I,I,c,e)).then(y=>{n--,p++,m[c]=y,O();}).catch(y=>{d=!0,u(y);});}function O(){if(!d){if(p>=e.length){a(m);return}for(;n<s&&t<e.length;)U(t),n++,t++;}}O();})}function T(e,r){return i(e,r,{concurrency:1})}async function N(e,r,s){let o=e instanceof Map;if(!Array.isArray(e)&&!o&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let a=o?Array.from(e.keys()):Object.keys(e),u=o?Array.from(e.values()):Object.values(e),p=await i(u,r,s),t=o?new Map:{};return a.forEach((n,m)=>{t instanceof Map?t.set(n,p[m]):t[n]=p[m];}),t}var k={delay:w,map:i,mapSeries:T,props:N}; | ||
export { k as default, w as delay, i as map, T as mapSeries, N as props }; | ||
//# sourceMappingURL=out.js.map | ||
function w(e){return new Promise(t=>setTimeout(t,e))}function o(e,t,{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 n=t||(s=>s);return new Promise((s,u)=>{let p=0,r=0,a=0,m=new Array(e.length).fill(void 0),O=!1;function A(c){let I=e[c];Promise.resolve(n.call(I,I,c,e)).then(y=>{a--,p++,m[c]=y,d();}).catch(y=>{O=!0,u(y);});}function d(){if(!O){if(p>=e.length){s(m);return}for(;a<i&&r<e.length;)A(r),a++,r++;}}d();})}async function N(e,t,i){return (await o(e,t,i)).filter(Boolean)}function T(e,t){return o(e,t,{concurrency:1})}async function U(e,t,i){let n=e instanceof Map;if(!Array.isArray(e)&&!n&&typeof e!="object")throw new TypeError(`input must be object, array or map, but got ${typeof e}`);let s=n?Array.from(e.keys()):Object.keys(e),u=n?Array.from(e.values()):Object.values(e),p=await o(u,t,i),r=n?new Map:{};return s.forEach((a,m)=>{r instanceof Map?r.set(a,p[m]):r[a]=p[m];}),r}var z={delay:w,map:o,mapSeries:T,filter:N,props:U}; | ||
export { z as default, w as delay, N as filter, o as map, T as mapSeries, U as props }; | ||
//# sourceMappingURL=index.js.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=out.js.map | ||
//# sourceMappingURL=map.js.map |
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=out.js.map | ||
//# sourceMappingURL=mapSeries.js.map |
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=out.js.map | ||
//# sourceMappingURL=props.js.map |
@@ -1,3 +0,1 @@ | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "fishbird", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Fishbird is a simple, lightweight, and fast Promise utility library", | ||
"author": "Igor Suvorov <hi@isuvorov.com> (https://github.com/isuvorov)", | ||
"ycmd": { | ||
"extends": "@lskjs/ycmd-config" | ||
}, | ||
"files": [ | ||
@@ -10,0 +7,0 @@ "lib", |
@@ -31,82 +31,3 @@ # Fishbird | ||
## Installation | ||
```bash | ||
npm i fishbird | ||
``` | ||
```bash | ||
yarn i fishbird | ||
``` | ||
```bash | ||
pnpm i fishbird | ||
``` | ||
## Usage | ||
### map | ||
```ts | ||
import { map } from 'fishbird'; | ||
const res = map([1 ,2, 3], async (id) => { | ||
const res = await fetch(id); | ||
return res.json(); | ||
}); | ||
// map with concurrency | ||
const res2 = map([1 ,2, 3], async (id) => { | ||
const res = await fetch(id); | ||
return res.json(); | ||
}, { concurrency: 2 }); | ||
``` | ||
### props | ||
```ts | ||
import { props } from 'fishbird'; | ||
const users = { | ||
john: { id: 1 }, | ||
bob: { id: 2 }, | ||
alice: { id: 3 }, | ||
} | ||
const res = await props(users, async ({ id }) => { | ||
const res = await fetch(id); | ||
return res.json(); | ||
}); | ||
// res = { | ||
// john: { name: 'John', ... }, | ||
// bob: { name: 'Bob', ... }, | ||
// alice: { name: 'Alice', ... }, | ||
// } | ||
// Props with concurrency and Map | ||
const users2 = new Map([ | ||
['john', { name: 'John' }], | ||
['bob', { name: 'Bob' }], | ||
['alice', { name: 'Alice' }], | ||
]); | ||
const res = await props(users, async (user) => { | ||
const res = await fetch(user.name); | ||
return res.json(); | ||
}, { concurrency: 2 }); | ||
``` | ||
## Inspired by | ||
- [Bluebird](https://github.com/petkaantonov/bluebird) | ||
<!-- ## Reading for developers | ||
- https://dev.to/orabazu/how-to-bundle-a-tree-shakable-typescript-library-with-tsup-and-publish-with-npm-3c46 | ||
- https://tsup.egoist.dev/ | ||
- https://blog.theodo.com/2021/04/library-tree-shaking/#:~:text=ESM%20is%20a%20requirement%20for,them%20both%20through%20the%20package. --> | ||
## Docs | ||
Read full docs **[here](https://github.com/isuvorov/fishbird)**. |
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
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
60006
44
113
0
33