cleanup and docs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-05-03 03:25:57 +03:00
parent 36c4202e23
commit 524dc3c3bf

View File

@ -560,6 +560,9 @@ var BaseBrowserPrototype = {
// // If true skip iterating nested items... // // If true skip iterating nested items...
// skipNested: <bool>, // skipNested: <bool>,
// //
// // XXX not yet supported...
// skipInlined: <bool>,
//
// // Reverse iteration order... // // Reverse iteration order...
// // // //
// // modes: // // modes:
@ -586,6 +589,7 @@ var BaseBrowserPrototype = {
// //
// //
// XXX can we add support for partial walks, i.e. start/end ranges??? // XXX can we add support for partial walks, i.e. start/end ranges???
// ...or abort walk and return result on user request...
// XXX can this support breadth first walking??? // XXX can this support breadth first walking???
// XXX revise protocol... // XXX revise protocol...
walk: function(func, options){ walk: function(func, options){
@ -1082,28 +1086,30 @@ var BaseBrowserPrototype = {
// XXX EXPERIMENTAL... // XXX EXPERIMENTAL...
// //
// Get focused item...
// .get() // .get()
// .get('focused')
// -> item // -> item
// -> undefined // -> undefined
// //
// .get(pattern[, options]) // Get next/prev item relative to focused...
// -> item
// -> undefined
//
// .get('prev'[, offset][, options]) // .get('prev'[, offset][, options])
// .get('next'[, offset][, options]) // .get('next'[, offset][, options])
// -> item // -> item
// -> undefined // -> undefined
// //
// pattern mostly follows the same scheme as in .select(..) so docs // Get first item matching pattern...
// for that for more info. // .get(pattern[, options])
// -> item
// -> undefined
// //
// pattern mostly follows the same scheme as in .select(..) so see
// docs for that for more info.
// //
// //
// NOTE: this is just like a lazy .search(..) that will return the // NOTE: this is just like a lazy .search(..) that will return the
// first result only. // first result only.
// //
// XXX add defaults (if no args get selected/focused...)
// XXX should we be able to get offset values relative to any match? // XXX should we be able to get offset values relative to any match?
// XXX revise return value... // XXX revise return value...
get: function(pattern, options){ get: function(pattern, options){
@ -1179,29 +1185,10 @@ var BaseBrowserPrototype = {
// XXX BROKEN... // XXX BROKEN...
// Sublist map functions... // Sublist map functions...
// //
// NOTE: there are different from .map(..) in that instead of paths // XXX NOTE: these will return a sparse array... ???
// func(..) will get indexes in the current browser...
// NOTE: these will return a sparse array...
//
// XXX this is broken because it does not account for sublists
// beyond the 0'th level...
sublists: function(func, options){ sublists: function(func, options){
var that = this return this.search({sublist: true}, func, options) },
options = Object.assign(Object.create(this.options || {}), options || {}) // XXX broken, needs support for options.skipInlined ...
var skipNested = options.skipNested
var skipInlined = options.skipInlined
var res = []
this.items
.forEach(function(elem, i){
if((!skipInlined && elem.value instanceof Browser)
|| (!skipNested && elem.sublist)){
res[i] = func ?
func.call(that, elem, i, that)
: elem
} })
return res
},
nested: function(func){ nested: function(func){
return this.sublists(func, {skipInlined: true}) }, return this.sublists(func, {skipInlined: true}) },
inlined: function(func){ inlined: function(func){