1.0.1 • Published 4 years ago

@feizheng/next-time-chunk v1.0.1

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

next-time-chunk

Split time to chunks for next.

npm licence

installation

npm install -S @feizheng/next-time-chunk

usage

import '@feizheng/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

Copyright and license

Code released under the MIT license.