mirror of
https://github.com/flynx/types.js.git
synced 2025-10-29 02:20:07 +00:00
chunk iteration now is sync for arrays smaller than a chunk...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
14ea5dca05
commit
965acefe61
10
Array.js
10
Array.js
@ -230,12 +230,22 @@ var makeChunkIter = function(iter, wrapper){
|
||||
var res = []
|
||||
var _wrapper = wrapper.bind(this, res, func, this)
|
||||
|
||||
// special case...
|
||||
// no need to setTimeout(..) if smaller than size...
|
||||
if(this.length <= size){
|
||||
var res = this[iter](_wrapper, ...rest)
|
||||
return Promise.all(
|
||||
postChunk ?
|
||||
postChunk.call(this, this, res, 0)
|
||||
: res) }
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
var next = function(chunks){
|
||||
setTimeout(function(){
|
||||
var chunk, val
|
||||
res.push(
|
||||
val = (chunk = chunks.shift())[iter](_wrapper, ...rest))
|
||||
// handle chunk...
|
||||
postChunk
|
||||
&& postChunk.call(that,
|
||||
chunk.map(function([i, v]){ return v }),
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-types",
|
||||
"version": "2.0.19",
|
||||
"version": "2.0.20",
|
||||
"description": "Generic JavaScript types and type extensions...",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user