diff --git a/README.md b/README.md index b97ef0c..c3d7792 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,6 @@ The Feature / Action couple is meta-programming library that helps with: - managing and applying sets of methods (Features) to objects (a-la _mixin_) - - ## Actions Actions are an extension to the JavaScript object model tailored for @@ -16,6 +14,32 @@ By design this tool-set promotes a _cooperative_ model and makes it hard to change/modify existing signatures / _contracts_ in _extending_ code. +### The problem: + +```javascript +var N = { + get value(){ + return this.__value || 0 + }, + set value(val){ + this.__value = val + } + + times: function(n){ + this.value *= n + } +} + +var n = Object.create(N) + +``` + +To extend this object we'll need to: + + + + + ### Functionality: - **Call _extended_ actions automatically** @@ -53,6 +77,8 @@ code. +--- + ### The main entities: ```javascript diff --git a/actions.js b/actions.js index a17075f..9d5ac83 100755 --- a/actions.js +++ b/actions.js @@ -967,7 +967,7 @@ module.MetaActions = { // NOTE: if 'all' is set them mixin all the actions available, // otherwise only mixin local actions... // NOTE: this will override existing own attributes. - inlineMmixin: function(from, all, descriptors, all_attr_types){ + inlineMixin: function(from, all, descriptors, all_attr_types){ // defaults... descriptors = descriptors || true all_attr_types = all_attr_types || false @@ -1012,14 +1012,14 @@ module.MetaActions = { return this }, - // Same as .inlineMmixin(..) but isolates a mixin in a seporate object + // Same as .inlineMixin(..) but isolates a mixin in a seporate object // in the inheritance chain... // mixin: function(from, all, descriptors, all_attr_types){ var proto = Object.create(this.__proto__) // mixinto an empty object - proto.inlineMmixin(from, all, descriptors, all_attr_types) + proto.inlineMixin(from, all, descriptors, all_attr_types) // mark the mixin for simpler removal... proto.__mixin_source = from @@ -1273,9 +1273,13 @@ function Actions(a, b){ // skip non-arrays... if(arg == null - || arg.constructor !== Array + // XXX node?: for some magical reason when running this + // from node console instanceof tests fail... + //|| !(arg instanceof Array) + || arg.constructor.name != 'Array' // and arrays the last element of which is not a function... - || !(arg[arg.length-1] instanceof Function)){ + || typeof(arg[arg.length-1]) != 'function'){ + //|| !(arg[arg.length-1] instanceof Function)){ return }