mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
20d0ed8741
commit
b5f28773dd
@ -245,17 +245,6 @@ var makeChunkIter = function(iter, wrapper){
|
||||
var _wrapper = wrapper.bind(this, res, func, this)
|
||||
|
||||
return new Promise(function(resolve, reject){
|
||||
|
||||
// XXX recursive version...
|
||||
// ...I do not like the idea of using recursion
|
||||
// here because of the stack size issue which would
|
||||
// break the code on very large arrays...
|
||||
// ...this might not be the case as on setTimeout(..)
|
||||
// we should be dropping the frame, the only thing that
|
||||
// may keep in memory is the closure, but in theory the
|
||||
// calling function will return by the time the next is
|
||||
// called (test!)
|
||||
// ...is there a different way to do this?
|
||||
var next = function(chunks){
|
||||
setTimeout(function(){
|
||||
res.push(
|
||||
@ -274,29 +263,6 @@ var makeChunkIter = function(iter, wrapper){
|
||||
// rest...
|
||||
: c.push([i, e])
|
||||
return res }, [[]]))
|
||||
/*/ // XXX iterative...
|
||||
// ...this on can flood the system with timeouts on
|
||||
// very large arrays...
|
||||
that
|
||||
// split the array into chunks...
|
||||
.reduce(function(res, e, i){
|
||||
var c = res.slice(-1)[0]
|
||||
c.length >= size ?
|
||||
// initial element in chunk...
|
||||
res.push([[i, e]])
|
||||
// rest...
|
||||
: c.push([i, e])
|
||||
return res
|
||||
}, [[]])
|
||||
// go through each chunk async...
|
||||
.forEach(function(chunk, i, chunks){
|
||||
setTimeout(function(){
|
||||
res.push(chunk[iter](_wrapper, ...rest))
|
||||
|
||||
i >= chunks.length-1
|
||||
&& resolve(res.flat(2))
|
||||
}, 0) })
|
||||
//*/
|
||||
}) } }
|
||||
|
||||
Array.prototype.CHUNK_SIZE = 50
|
||||
@ -330,6 +296,7 @@ Set.prototype.subtract = function(other){
|
||||
.filter(function(e){ return !other.has(e) })) }
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// RegExp...
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user