1.0.0 • Published 5 years ago

@jswork/next-time-chunk v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

next-time-chunk

Split time to chunks for next.

version license size download

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

license

Code released under the MIT license.