tweaking and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-04-26 02:28:58 +03:00
parent 9e79b6a0b1
commit dd03da42f6

View File

@ -538,6 +538,14 @@ var BaseBrowserPrototype = {
// //
// options format: // options format:
// { // {
// // Partial walking...
// //
// // XXX not implemented yet...
// start: <index> | <path>,
// count: <number>,
// end: <index> | <path>,
//
//
// // Iterate ALL items... // // Iterate ALL items...
// // // //
// // NOTE: this if true overrides all other iteration coverage // // NOTE: this if true overrides all other iteration coverage
@ -605,22 +613,24 @@ var BaseBrowserPrototype = {
var options = args.pop() || {} var options = args.pop() || {}
// options... // options...
options = Object.assign(Object.create(this.options || {}), options || {}) options = Object.assign(Object.create(this.options || {}), options)
/*var start = options.start || 0
var end = options.end
|| (options.count >= 0 && start + (options.count))
|| Infinity
//*/
var iterateNonIterable = options.iterateAll || options.iterateNonIterable var iterateNonIterable = options.iterateAll || options.iterateNonIterable
var iterateCollapsed = options.iterateAll || options.iterateCollapsed var iterateCollapsed = options.iterateAll || options.iterateCollapsed
var skipNested = !options.iterateAll && options.skipNested var skipNested = !options.iterateAll && options.skipNested
var reverse = options.reverse var reverse = options.reverse === true ?
reverse = reverse === true ?
(options.defaultReverse || 'tree') (options.defaultReverse || 'tree')
: reverse : options.reverse
var isWalkable = userIsWalkable ? var isWalkable = userIsWalkable ?
function(elem){ function(elem){
return elem instanceof Array return elem instanceof Array || userIsWalkable(elem) }
|| userIsWalkable(elem) }
: function(elem){ : function(elem){
return elem instanceof Array return elem instanceof Array || elem instanceof Browser }
|| elem instanceof Browser }
// level walk function... // level walk function...
var walk = function(i, path, list){ var walk = function(i, path, list){
@ -663,13 +673,12 @@ var BaseBrowserPrototype = {
: undefined : undefined
opts = args.shift() || options opts = args.shift() || options
// normalize list... // normalize...
list = list === true ? list = list === true ?
sublist sublist
: (!iterateCollapsed && elem.collapsed) ? : (!iterateCollapsed && elem.collapsed) ?
[] []
: (list || sublist) : (list || sublist)
// adjust index...
i = j != null ? j : i i = j != null ? j : i
return ( return (
@ -681,7 +690,7 @@ var BaseBrowserPrototype = {
// user-defined recursion... // user-defined recursion...
: recursion instanceof Function ? : recursion instanceof Function ?
recursion.call(that, func, i, p, list, opts) recursion.call(that, func, i, p, list, opts)
: list[recursion || 'walk'](func, i, p, opts)) : list[recursion || 'walk'](func, i, p, opts) )
.run(function(){ .run(function(){
var res = this instanceof Array ? var res = this instanceof Array ?
this this
@ -721,10 +730,9 @@ var BaseBrowserPrototype = {
// append the actual element... // append the actual element...
.concat( .concat(
// NOTE: func MUST return an array... // NOTE: func MUST return an array...
// XXX can we make this more lenient???
func.call(that, func.call(that,
// NOTE: for inline elements we do not need to // NOTE: for inline elements we do not need to
// count the header... // count the header as it's not present...
inline ? i : i++, inline ? i : i++,
p, p,
// NOTE: inlined sets have no header... // NOTE: inlined sets have no header...