mirror of
https://github.com/flynx/actions.js.git
synced 2025-10-29 02:10:09 +00:00
added actions.ASIS(..)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f96888c7e7
commit
29854ef2fe
@ -234,8 +234,11 @@ Root Action o---|---x
|
|||||||
- the base/root action can return any value.
|
- the base/root action can return any value.
|
||||||
**Notes:**
|
**Notes:**
|
||||||
- if undefined is returned, it will be replaced by the
|
- if undefined is returned, it will be replaced by the
|
||||||
action context/action set.
|
action context/action set,
|
||||||
- `false` and `null` are returned as-is.
|
- 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
|
- there is no distinction between root and other actions
|
||||||
other than that root action's return values are not
|
other than that root action's return values are not
|
||||||
ignored.
|
ignored.
|
||||||
|
|||||||
10
actions.js
10
actions.js
@ -15,8 +15,14 @@ var object = require('ig-object')
|
|||||||
|
|
||||||
var args2array = function(a){ return [].slice.call(a) }
|
var args2array = function(a){ return [].slice.call(a) }
|
||||||
|
|
||||||
|
var ASIS =
|
||||||
|
module.ASIS =
|
||||||
|
object.makeConstructor('ASIS', {
|
||||||
|
__init__: function(obj){ this.value = obj },
|
||||||
|
})
|
||||||
|
|
||||||
var UNDEFINED =
|
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...
|
// return context if nothing specific is returned...
|
||||||
res = res === undefined ? context
|
res = res === undefined ? context
|
||||||
: res === UNDEFINED ? undefined
|
: res instanceof ASIS ? res.value
|
||||||
// XXX returning an explicit [undefined]...
|
// XXX returning an explicit [undefined]...
|
||||||
//: res instanceof Array
|
//: res instanceof Array
|
||||||
// && res.length == 1
|
// && res.length == 1
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-actions",
|
"name": "ig-actions",
|
||||||
"version": "3.20.2",
|
"version": "3.21.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "actions.js",
|
"main": "actions.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user