mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
.walk2(..) refining...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2bd7aa5c5b
commit
7a56564835
@ -464,7 +464,7 @@ object.mixinFlat(function(){}, {
|
|||||||
|
|
||||||
var Make =
|
var Make =
|
||||||
module.Make =
|
module.Make =
|
||||||
object.Constructor('Make', Items)
|
object.Constructor('Make', Items)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1935,11 +1935,8 @@ var BaseBrowserPrototype = {
|
|||||||
//
|
//
|
||||||
// options format:
|
// options format:
|
||||||
// {
|
// {
|
||||||
// reverse: <bool>,
|
|
||||||
//
|
|
||||||
// // XXX ???
|
|
||||||
// //reverseCall: <bool>,
|
|
||||||
//
|
//
|
||||||
|
// reverse: <bool> | 'full',
|
||||||
//
|
//
|
||||||
// iterateNonIterable: <bool>,
|
// iterateNonIterable: <bool>,
|
||||||
// iterateCollapsed: <bool>,
|
// iterateCollapsed: <bool>,
|
||||||
@ -1964,9 +1961,6 @@ var BaseBrowserPrototype = {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// XXX add i and path handling...
|
|
||||||
// XXX revise func(..) return value semantics...
|
|
||||||
// should false be treated the same as null and undefined???
|
|
||||||
walk2: function(func, options){
|
walk2: function(func, options){
|
||||||
var that = this
|
var that = this
|
||||||
var [func, options={}, path=[], context={}] = [...arguments]
|
var [func, options={}, path=[], context={}] = [...arguments]
|
||||||
@ -1980,8 +1974,6 @@ var BaseBrowserPrototype = {
|
|||||||
Object.create(this.options || {}),
|
Object.create(this.options || {}),
|
||||||
options)
|
options)
|
||||||
// options.reverse...
|
// options.reverse...
|
||||||
// XXX
|
|
||||||
var reverseCall = !!options.reverseCall
|
|
||||||
var handleReverse = function(lst){
|
var handleReverse = function(lst){
|
||||||
return options.reverse ?
|
return options.reverse ?
|
||||||
lst.slice().reverse()
|
lst.slice().reverse()
|
||||||
@ -2000,7 +1992,7 @@ var BaseBrowserPrototype = {
|
|||||||
var iterateNonIterable = !!(options.iterateAll || options.iterateNonIterable)
|
var iterateNonIterable = !!(options.iterateAll || options.iterateNonIterable)
|
||||||
var iterateCollapsed = !!(options.iterateAll || options.iterateCollapsed)
|
var iterateCollapsed = !!(options.iterateAll || options.iterateCollapsed)
|
||||||
// XXX
|
// XXX
|
||||||
var includeInlinedBlocks = !!options.includeInlinedBlocks
|
//var includeInlinedBlocks = !!options.includeInlinedBlocks
|
||||||
|
|
||||||
// stopping mechanics...
|
// stopping mechanics...
|
||||||
var res, StopException
|
var res, StopException
|
||||||
@ -2034,24 +2026,29 @@ var BaseBrowserPrototype = {
|
|||||||
: elems }
|
: elems }
|
||||||
|
|
||||||
// handle item...
|
// handle item...
|
||||||
var item =
|
// skip non-iterable and inlined block items...
|
||||||
// skip non-iterable...
|
var handleItem = !((!iterateNonIterable && elem.noniterable)
|
||||||
(!iterateNonIterable && elem.noniterable) ?
|
|| (elem instanceof Array || elem instanceof BaseBrowser))
|
||||||
[]
|
var p = handleItem ?
|
||||||
: [(elem instanceof Array || elem instanceof BaseBrowser) ?
|
path.concat(elem.id)
|
||||||
// skip inlined block items...
|
: p
|
||||||
[]
|
var item
|
||||||
: func.call(that, elem,
|
// NOTE: this will handle the item once and then re-return the value...
|
||||||
context.index++,
|
var getItem = function(){
|
||||||
// NOTE: path will be updated ONLY for non-inlined items...
|
return (item =
|
||||||
p = path.concat(elem.id),
|
item !== undefined ?
|
||||||
next, stop) || []]
|
item
|
||||||
.flat()
|
: handleItem ?
|
||||||
|
[ func.call(that, elem, context.index++, p, next, stop) ].flat()
|
||||||
|
: []) }
|
||||||
|
// pre-call the item if options.reverse is not set to 'full'...
|
||||||
|
options.reverse == 'full'
|
||||||
|
|| getItem()
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// item...
|
// item...
|
||||||
...!options.reverse ?
|
...!options.reverse ?
|
||||||
item
|
getItem()
|
||||||
: [],
|
: [],
|
||||||
// children...
|
// children...
|
||||||
...children instanceof Array ?
|
...children instanceof Array ?
|
||||||
@ -2064,7 +2061,7 @@ var BaseBrowserPrototype = {
|
|||||||
: [],
|
: [],
|
||||||
// item (in reverse)...
|
// item (in reverse)...
|
||||||
...options.reverse ?
|
...options.reverse ?
|
||||||
item
|
getItem()
|
||||||
: [], ] } }
|
: [], ] } }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user