From f3dab4c3d38f59f44eda62b20c13f6255530c538 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 7 Aug 2017 00:16:31 +0300 Subject: [PATCH] now .aliases list only own aliases + docs... Signed-off-by: Alex A. Naanou --- actions.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- package.json | 2 +- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/actions.js b/actions.js index ed77639..c825c8d 100755 --- a/actions.js +++ b/actions.js @@ -83,6 +83,14 @@ module.UNDEFINED = ['undefined placeholder'] // - post action handlers will get the root action result as first // argument succeeded by the action arguments. // +// Alias +// - an action created by Alias(..), +// - identical to an action with one key difference: instead of a +// function Alias(..) expects a string/code, +// - code syntax is configurable, defaulting to the defined by +// parseActionCall(..) +// - aliases are designed to be defined and managed in runtime while +// actions are mainly load-time entities. // // // The action system main protocols: @@ -240,6 +248,40 @@ module.UNDEFINED = ['undefined placeholder'] // // // +// Alias protocols: +// +// 1) Defining aliases in runtime (MetaActions) +// +// .alias('alias', 'action: args') +// .alias('alias', .., 'action: args') +// -> +// +// NOTE: .alias(..) is signature compatible to Action(..) / Alias(..), +// supporting all the documentation and attribute definition. +// +// +// 2) Deleting aliases in runtime (MetaActions) +// +// .alias('alias', null) +// .alias('alias', false) +// -> +// +// NOTE: only own aliases can be deleted via .alias(.., null|false) +// +// +// 3) Documentation generation and introspection (MetaActions, Alias) +// +// Alias code... +// .alias +// .toString() +// -> +// +// List own aliases... +// .aliases +// -> +// +// +// /*********************************************************************/ // helpers... @@ -774,13 +816,14 @@ module.MetaActions = { }, // List aliases... - // XXX should the check be deep??? - // ...i.e. we can extend an alias with an action, does this make - // the extending action an alias??? + // + // NOTE: this will only show the aliases local to this. get aliases(){ var that = this return this.actions - .filter(function(n){ return that[n] instanceof Alias }) }, + .filter(function(n){ + return Object.hasOwnProperty(this, n) + && that[n] instanceof Alias }) }, // XXX move this to the right spot... diff --git a/package.json b/package.json index a38ca66..58c5bab 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-actions", - "version": "3.5.2", + "version": "3.5.3", "description": "", "main": "actions.js", "scripts": {