Comparing version 0.12.2 to 1.0.0
{ | ||
"name": "clank", | ||
"version": "0.12.2", | ||
"description": "lightweight inhertiance and compositional object model. mostly just helpers", | ||
"version": "1.0.0", | ||
"description": "lightweight inheritance and compositional object model; mostly just helpers", | ||
"main": "index.js", | ||
@@ -36,5 +36,5 @@ "scripts": { | ||
"dependencies": { | ||
"lodash": "~2.4.1", | ||
"cobble": "~0.16.3" | ||
"lodash": "^2.4.1", | ||
"cobble": "^1.0.0" | ||
} | ||
} |
@@ -6,7 +6,7 @@ Clank | ||
It is _highly_ recommended that you take a look at the tests (`./test/class.js`) for a far more extensive demostration of the functionality of Clank. | ||
It is _highly_ recommended that you take a look at the [tests (`./test/class.js`)](https://github.com/theporchrat/clank/blob/master/test/class.js) for a far more extensive demostration of the functionality of Clank. | ||
## Support | ||
## Browser Support | ||
works fine in IE8 but does expect certain es5 functions, include es5 shim and sham in IE8 and everything will work fine, with a single caveat: object constructors are assigned a non-enumerable property `__META__`, which in IE8 _is_ enumerable, so keep that in mind. | ||
Works fine in IE8 but does expect certain es5 functions, include es5 shim and sham in IE8 and everything will work fine, with a single caveat: object constructors are assigned a non-enumerable property `__META__`, which in IE8 _is_ enumerable, so keep that in mind, when using `Object.assign` and other "extend" functions. | ||
@@ -41,4 +41,6 @@ ## API | ||
you can also you compositional descriptors to handle overrides and super calls. __See the cobble documentation for more information on descriptors__ | ||
This effectively means taht you can specify mixin objects before your prototype spec. | ||
You can also use cobble's descriptors to handle overrides and super calls. __See the cobble documentation for more information on descriptors__ | ||
var EnglishSpeaker = Clank.Object.extend({ greet: function(){ return "hello" } }) | ||
@@ -60,7 +62,31 @@ | ||
person.greet() // => "hello and hola and guten morgen" | ||
// Super calls with Constructors | ||
// --------- | ||
var Machine = Clank.Object.extend({ | ||
constructor: function(){ | ||
Clank.Object.call(this) //call the super constructor in the traditional way | ||
this.greeting = (this.greeting || '') + 'whizz' | ||
} | ||
}) | ||
var Toaster = Machine.extend({ | ||
// call the super Toaster constructor after the Toaster constructor using a Descriptor | ||
constructor: Clank.before(function(){ | ||
this.greeting = 'whorl' | ||
}) | ||
}) | ||
### .reopen(...spec) | ||
`.reopen` is like `.extend` but instead of creating a new Class it alters the current class prototype. Changes made to the prototype will cascade throguh the object heirarchy. `.reopen` has the same signature as `.extend`. | ||
`.reopen` is like `.extend` but instead of creating a new Class it alters the current class prototype. Changes made to the prototype will cascade throguh the object heirarchy. | ||
`.reopen` has the same signature as `.extend`. | ||
var Person = Clank.Object.extend({ species: 'homo sapien'}) | ||
@@ -85,3 +111,3 @@ , Man = Person.extend({ gender: 'male' }); | ||
Returns an instance of the object with instance properties set to the passed in object, or array of objects. `.create` also has teh same signature as `.extend()` so you can use descriptors as well to compose properties. | ||
Returns an instance of the object with instance properties set to the passed in object, or array of objects. `.create` also has the same signature as `.extend()` so you can use descriptors as well to compose properties. | ||
@@ -101,7 +127,7 @@ var Person = Clank.Object.extend({ greeting: 'guten tag' }); | ||
In certain cases you may want to create an object Class with a default composition behaviour when extending or creating instances. Clank provides the `Constructor.setCompositionStrategy(spec)` method for doing just this. The provided `spec` should be an object that will be mixed into the instance or extension after all user provided compositions. | ||
In certain cases you may want to create an object Class with a default composition behaviour when extending or creating instances. Clank provides the `Constructor.setCompositionStrategy(spec)` method for doing just this. The provided `spec` should be an object of `Descriptors` that will be mixed into the instance or extension after all user provided compositions. | ||
var Person = Clank.Object.extend({ traits: [ 'biped', 'hair'] }); | ||
//in the future traits will be concated together | ||
// in the future traits will be concated together | ||
Person.setCompositionStrategy({ | ||
@@ -140,4 +166,6 @@ traits: Clank.concat() | ||
Clank _does_ have a "proper" `super` implementation but you probably don't need it. The majority of super use-cases, can be solved by simple doing `Parent.prototype[method].call(this, [args]` or using the descriptors. For a bunch of reasons, using `_super` is going to be less preformant then a static reference (either method). __Note: super also makes use of `Function.caller`, a depreciated lang feature, internally.__ | ||
Clank _does_ have a "proper" `super` implementation but you probably don't need it. The majority of super use-cases, can be solved by simple doing `Parent.prototype[method].call(this, [args]` or by using a Descriptor. Overuse of the super keyword can lead to bad patterns (like calling `_super` in a mixin object), and should be saved for situations when you cannot use a static reference, or you know the super method may change. | ||
In a few cases where you need to dynamically reference the super class, super han be accessed by `this._super([method]) => returns the method` inside a class method, however, there are a bunch of pitfalls and caveats related to its use, which is why it is __underscored__. Consult the super tests for insight into the limitations of this method. | ||
For a bunch of reasons, using `_super` is going to be less performant than a static reference (either method). __Note: super also makes use of `Function.caller`, a depreciated js feature, internally.__ | ||
In a few cases where you need to dynamically reference the super class, super han be accessed by `this._super([method]) => returns the method` inside a class method, however, there are a bunch of pitfalls and caveats related to its use, which is why it is __underscored__. Consult the tests for insight into the limitations of this method. |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
26636
0
166
+ Addedcobble@1.1.3(transitive)
- Removedcobble@0.16.3(transitive)
Updatedcobble@^1.0.0
Updatedlodash@^2.4.1