added section support + working on essential option support...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-08-23 17:00:55 +03:00
parent 33ef833a31
commit 689297d967

View File

@ -1942,15 +1942,40 @@ var BaseBrowserPrototype = {
// //
// //
// XXX add sections support... // XXX add sections support...
// XXX add i and path handling...
walk2: function(func, options){ walk2: function(func, options){
var that = this var that = this
var [func, options={}, context={}] = [...arguments] var [func, options={}, context={}] = [...arguments]
// context...
context.root = context.root || this
// options... // options...
options = Object.assign(
Object.create(this.options || {}),
options)
// options.reverse...
var handleReverse = function(lst){ var handleReverse = function(lst){
return options.reverse ? return options.reverse ?
lst.slice().reverse() lst.slice().reverse()
: lst } : lst }
// options.section...
var sections = options.section == '*' ?
(options.sections
|| ['header', 'items', 'footer'])
: options.section
// NOTE: we include sections other than 'items' only for the root context...
sections = (sections instanceof Array
&& context.root !== this)
&& sections.includes('items') ?
'items'
: (sections || 'items')
sections = sections instanceof Array ?
sections
: [sections]
// XXX iteration filtering...
var iterateNonIterable = options.iterateAll || options.iterateNonIterable
var iterateCollapsed = options.iterateAll || options.iterateCollapsed
// stopping mechanics... // stopping mechanics...
var res, StopException var res, StopException
@ -1964,7 +1989,11 @@ var BaseBrowserPrototype = {
try { try {
var map var map
return handleReverse(this.items) return handleReverse(
sections
.map(function(section){
return that[section] || [] })
.flat())
.map(map = function(elem){ .map(map = function(elem){
// XXX // XXX
var i = 0 var i = 0