@jswork/next-time-chunk
v1.0.0
Published
Split time to chunks for next.
Downloads
22
Readme
next-time-chunk
Split time to chunks for next.
installation
npm install -S @jswork/next-time-chunk
usage
import '@jswork/next-time-chunk';
const fetchApi = (item) => {
return new Promise((resolve) => {
setTimeout(() => {
console.log('data:', item);
resolve(item);
}, 1000);
});
};
nx.timeChunk(
[1, 2, 3, 4, 5],
{
callback: (data) => {
return fetchApi(data);
},
chunk: 2
}
).then(res => {
console.log(res);
});
// data: 1
// data: 2
// data: 3
// data: 4
// data: 5
// [ 1, 2, 3, 4, 5 ]
resources
- https://www.cnblogs.com/ahthw/p/5117570.html
license
Code released under the MIT license.