ampersand-collection
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -304,5 +304,10 @@ var BackboneEvents = require('backbone-events-standalone'); | ||
Object.defineProperty(Collection.prototype, 'length', { | ||
get: function () { | ||
return this.models.length; | ||
Object.defineProperties(Collection.prototype, { | ||
length: { | ||
get: function () { | ||
return this.models.length; | ||
} | ||
}, | ||
isCollection: { | ||
value: true | ||
} | ||
@@ -309,0 +314,0 @@ }); |
{ | ||
"name": "ampersand-collection", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -5,0 +5,0 @@ "bugs": { |
@@ -66,2 +66,10 @@ # ampersand-collection | ||
``` | ||
## A quick note about instanceof checks | ||
With npm and browserify for module deps you can sometimes end up with a situation where, the same `collection` constructor wasn't used to build a `collection` object. As a result `instanceof` checks will fail. | ||
In order to deal with this (because sometimes this is a legitimate scenario), `collection` simply creates a read-only `isCollection` property on all collection objects that can be used to check whether or a not a given object is in fact a collection object no matter what its constructor was. | ||
<!-- starthide --> | ||
@@ -68,0 +76,0 @@ |
@@ -225,1 +225,9 @@ var test = require('tape'); | ||
}); | ||
test('Ensure `isCollection` exists and is immutable', function (t) { | ||
var c = new Collection(); | ||
t.ok(c.isCollection); | ||
c.isCollection = false; | ||
t.ok(c.isCollection); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22895
509
86