diff --git a/README.md b/README.md index bc277a0..9c96e16 100644 --- a/README.md +++ b/README.md @@ -234,8 +234,11 @@ Root Action o---|---x - the base/root action can return any value. **Notes:** - if undefined is returned, it will be replaced by the - action context/action set. - - `false` and `null` are returned as-is. + action context/action set, + - if a function is returned it is treated as a post phase action, + - to return a reserved value (undefined, function) wrap it in + `actions.ASIS(..)` + - any other return value is returned as-is, - there is no distinction between root and other actions other than that root action's return values are not ignored. diff --git a/actions.js b/actions.js index afd517f..305517f 100755 --- a/actions.js +++ b/actions.js @@ -15,8 +15,14 @@ var object = require('ig-object') var args2array = function(a){ return [].slice.call(a) } +var ASIS = +module.ASIS = +object.makeConstructor('ASIS', { + __init__: function(obj){ this.value = obj }, +}) + var UNDEFINED = -module.UNDEFINED = ['undefined placeholder'] +module.UNDEFINED = ASIS(undefined) @@ -792,7 +798,7 @@ Action.prototype.pre = function(context, args){ // return context if nothing specific is returned... res = res === undefined ? context - : res === UNDEFINED ? undefined + : res instanceof ASIS ? res.value // XXX returning an explicit [undefined]... //: res instanceof Array // && res.length == 1 diff --git a/package.json b/package.json index 3a26c67..ccda09e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-actions", - "version": "3.20.2", + "version": "3.21.0", "description": "", "main": "actions.js", "scripts": {