added exit mode to done(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-05-04 14:59:35 +03:00
parent d91fbb5c3a
commit a5ea1e9a7c
3 changed files with 4 additions and 4 deletions

View File

@ -170,8 +170,8 @@ Stop walking and return `state`. The passed `state` is directly returned from th
#### `done(..)`
`done(state) -> state`
User provided function, if given, is called by the *walker* after walking is done (no more nodes to handle). `state` is passed as argument and the return value is returned from the *walker*. This is run in the same context (`this`) as `getter(..)`.
`done(state, mode) -> state`
User provided function, if given, is called by the *walker* after walking is done (no more nodes to handle). `state` is passed as argument and the return value is returned from the *walker*. If walking was stopped via `stop(..)` mode will be `'stopped'` otherwise it is `'done'`. This is run in the same context (`this`) as `getter(..)`.
## Examples

View File

@ -1,6 +1,6 @@
{
"name": "generic-walk",
"version": "1.3.1",
"version": "1.4.0",
"description": "An extensible tree walk(..) framework...",
"main": "walk.js",
"scripts": {

View File

@ -151,7 +151,7 @@ function(getter, state, ...nodes){
// call the done handler...
res = done ?
done.call(context, res)
done.call(context, res, WalkStopException ? 'stopped': 'done')
: res
return res