Comparing version 3.1.0 to 4.0.0
@@ -0,1 +1,5 @@ | ||
## version 4.0.0: 2013-06-13 | ||
* remove .mixin, and add .extend (see #18) | ||
## version 3.1.0: 2013-06-13 | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "pjs", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "A lightweight class system. It's just prototypes!", | ||
@@ -5,0 +5,0 @@ "keywords": ["class", "pjs", "P", "inheritance", "super"], |
@@ -50,6 +50,3 @@ var P = (function(prototype, ownProperty, undefined) { | ||
C.mixin = function(def) { | ||
Bare[prototype] = C[prototype] = P(C, def)[prototype]; | ||
return C; | ||
} | ||
C.extend = function(def) { return P(C, def); } | ||
@@ -56,0 +53,0 @@ return (C.open = function(def) { |
@@ -198,6 +198,6 @@ var assert = require('assert') | ||
describe('mixins', function() { | ||
describe('extend', function() { | ||
var C = P(); | ||
var count = 0; | ||
it('extends the prototype', function() { | ||
it('extends the class', function() { | ||
var mixin1 = function(proto) { | ||
@@ -211,28 +211,8 @@ proto.foo = 1; | ||
C.mixin(mixin1); | ||
assert.equal(C().foo, 1); | ||
assert.equal(C.extend(mixin1)().foo, 1); | ||
// chainable! | ||
C.mixin(mixin1).mixin(mixin2); | ||
assert.equal(C().foo, 2); | ||
assert.equal(C.extend(mixin1).extend(mixin2)().foo, 2); | ||
}); | ||
it('extends, and does not affect existing instances', function() { | ||
C.mixin({ a: 1 }); | ||
var inst = C(); | ||
C.mixin({ a: 2 }); | ||
assert.equal(inst.a, 1); | ||
}); | ||
it('calls the mixin multiple times', function() { | ||
count = 0; | ||
var mixin = function() { count += 1 }; | ||
C.mixin(mixin); | ||
assert.equal(count, 1); | ||
C.mixin(mixin); | ||
assert.equal(count, 2); | ||
}); | ||
it('suppports _super', function() { | ||
@@ -247,7 +227,5 @@ var mixin1 = function(proto) { | ||
C.mixin(mixin1).mixin(mixin2); | ||
assert.equal(C().foo(), 2); | ||
assert.equal(C.extend(mixin1).extend(mixin2)().foo(), 2); | ||
}); | ||
}); | ||
}); |
17210
257