From 20d0ed8741e75f39c5e8bc39ec95a77b1e80af32 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 11 Jan 2019 04:17:47 +0300 Subject: [PATCH] tweaking... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 3 ++- ui (gen4)/lib/util.js | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index 5a64b192..483d5a7d 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -794,7 +794,8 @@ var FileSystemLoaderActions = actions.Actions({ logger.emit('queued', gid)}) // XXX get this from config... - var chunk_size = 50 + //var chunk_size = 50 + var chunk_size = '100C' return this.images .map(function(gid, image){ diff --git a/ui (gen4)/lib/util.js b/ui (gen4)/lib/util.js index 2d2565b8..37c59723 100755 --- a/ui (gen4)/lib/util.js +++ b/ui (gen4)/lib/util.js @@ -231,12 +231,12 @@ var makeChunkIter = function(iter, wrapper){ var that = this var args = [...arguments] size = args[0] instanceof Function ? - (this.chunk_size || 50) + (this.CHUNK_SIZE || 50) : args.shift() size = typeof(size) == typeof('str') ? // number of chunks... - (size.endsWith('c') || size.endsWith('C') ? - Math.round(this.length / parseInt(size)) + (size.trim().endsWith('c') || size.trim().endsWith('C') ? + Math.round(this.length / (parseInt(size) || 1)) || 1 : parseInt(size)) : size func = args.shift() @@ -250,6 +250,11 @@ var makeChunkIter = function(iter, wrapper){ // ...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(){ @@ -294,7 +299,7 @@ var makeChunkIter = function(iter, wrapper){ //*/ }) } } -Array.prototype.chunk_size = 50 +Array.prototype.CHUNK_SIZE = 50 Array.prototype.mapChunks = makeChunkIter('map') Array.prototype.filterChunks = makeChunkIter('map', function(res, func, array, e){