mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
testing generic-walk...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a200c41684
commit
bed990372b
@ -3,7 +3,6 @@
|
||||
*
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
var requirejs_cfg = {
|
||||
// XXX this does not work on direct filesystem access...
|
||||
//urlArgs: 'bust='+Date.now(),
|
||||
@ -20,6 +19,8 @@ var requirejs_cfg = {
|
||||
'lib/actions': 'node_modules/ig-actions/actions',
|
||||
'lib/features': 'node_modules/ig-features/features',
|
||||
//'lib/keyboard': './node_modules/ig-keyboard/keyboard',
|
||||
|
||||
'lib/walk': 'node_modules/generic-walk/walk',
|
||||
},
|
||||
map: {
|
||||
'*': {
|
||||
@ -31,6 +32,8 @@ var requirejs_cfg = {
|
||||
'ig-features': 'lib/features',
|
||||
|
||||
//'ig-keyboard': 'lib/keyboard',
|
||||
|
||||
'generic-walk': 'lib/walk',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -21,6 +21,7 @@ body {
|
||||
<script src="../jli.js"></script>
|
||||
|
||||
<script src="../../ext-lib/require.js"></script>
|
||||
<script src="../../cfg/requirejs.js"></script>
|
||||
|
||||
|
||||
<!--script src="browse-dialog.js"></script-->
|
||||
|
||||
@ -12,6 +12,10 @@ var keyboard = require('../keyboard')
|
||||
var object = require('../object')
|
||||
var widget = require('./widget')
|
||||
|
||||
// XXX
|
||||
//var walk = require('lib/walk')
|
||||
var walk = require('../../node_modules/generic-walk/walk').walk
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
@ -592,6 +596,7 @@ var BaseBrowserPrototype = {
|
||||
// ...or abort walk and return result on user request...
|
||||
// XXX can this support breadth first walking???
|
||||
// XXX revise protocol...
|
||||
// XXX use generic-walk.... (???)
|
||||
walk: function(func, options){
|
||||
var that = this
|
||||
|
||||
@ -720,7 +725,7 @@ var BaseBrowserPrototype = {
|
||||
})
|
||||
}
|
||||
|
||||
// setup some context...
|
||||
// setup iteration context...
|
||||
var inline = false
|
||||
// inline browser or array...
|
||||
if(isWalkable(elem)){
|
||||
@ -775,6 +780,49 @@ var BaseBrowserPrototype = {
|
||||
},
|
||||
|
||||
|
||||
// XXX need to make this the same as .walk(..) from the user's
|
||||
// perspective with one addition, expose the root stop(..)
|
||||
// function to func...
|
||||
// next steps:
|
||||
// - get a feeling of this running
|
||||
// - see if we need to change the API
|
||||
// - either embed into .walk(..) or reimplement...
|
||||
walk2: function(func, i, path, options){
|
||||
|
||||
i = i || 0
|
||||
path = path || []
|
||||
|
||||
return walk(
|
||||
function(state, node, next, stop){
|
||||
node.value
|
||||
&& console.log('---', i++, path, node.value)
|
||||
|
||||
return (
|
||||
// inline...
|
||||
node instanceof Array ?
|
||||
next('do', state, ...node)
|
||||
: node.walk2 instanceof Function ?
|
||||
// XXX pass stop(..) to this...
|
||||
state.concat(node.walk2(func, i, path, options))
|
||||
|
||||
// nested...
|
||||
// XXX add node to state...
|
||||
: node.sublist instanceof Array ?
|
||||
// XXX need to update path...
|
||||
next('do', state, ...node.sublist)
|
||||
: node.sublist && node.sublist.walk2 instanceof Function ?
|
||||
// XXX pass stop(..) to this...
|
||||
state.concat(node.sublist.walk2(func, i, path.concat([node.value]), options))
|
||||
|
||||
: state)
|
||||
},
|
||||
// XXX done(..)
|
||||
//function(state){ console.log('done:', state) },
|
||||
[],
|
||||
...this.items)
|
||||
},
|
||||
|
||||
|
||||
// Text render...
|
||||
//
|
||||
// This is mainly here for doc/debug purposes...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user