added actions.ASIS(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-10-25 17:35:58 +03:00
parent f96888c7e7
commit 29854ef2fe
3 changed files with 14 additions and 5 deletions

View File

@ -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.

View File

@ -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

View File

@ -1,6 +1,6 @@
{
"name": "ig-actions",
"version": "3.20.2",
"version": "3.21.0",
"description": "",
"main": "actions.js",
"scripts": {