diff --git a/Array.js b/Array.js index 17b9f0a..850ecbf 100644 --- a/Array.js +++ b/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 }), diff --git a/package.json b/package.json index ab66ea6..6e52b6c 100644 --- a/package.json +++ b/package.json @@ -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": {