Comparing version 1.0.4 to 1.1.0
# Change History | ||
## 1.0.04 (2014-05-17) | ||
## 1.1.0 (2014-08-28) | ||
* Allow `extends_` method to delegate to `Parent.extend` if present. This way | ||
typedef can be used with libs like [AmpersandJS](http://ampersandjs.com/) | ||
and [Backbone](http://backbonejs.org/). | ||
## 1.0.4 (2014-05-17) | ||
* Updated NPM dependencies. | ||
@@ -6,0 +12,0 @@ |
@@ -8,2 +8,5 @@ module.exports = extends_; | ||
* prototypes. | ||
* | ||
* If the `Parent` class has a `extend` method (like Backbone or Ampersand), it | ||
* will defer to that. | ||
* @param {Function} Child Child constructor function. | ||
@@ -15,2 +18,22 @@ * @param {Function} Parent Parent contrusctor function. | ||
{ | ||
if (typeof Parent.extend === 'function') { | ||
var proto = {}; | ||
// Add in all the prototype members | ||
for (var p in Child.prototype) { | ||
proto[p] = Child.prototype[p]; | ||
} | ||
proto.constructor = Child; | ||
// Delegate | ||
Parent.extend(proto); | ||
// Give static to access parent | ||
Child.Super = Parent; | ||
return; | ||
} | ||
// Drop in statics | ||
@@ -17,0 +40,0 @@ for (var key in Parent) { |
{ | ||
"name": "typedef", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Low-level type-centric utility functions for Javascript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
22719
19
357