Socket
Socket
Sign inDemoInstall

ampersand-state

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-state - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

1

ampersand-state.js

@@ -493,2 +493,3 @@ var _ = require('underscore');

child.prototype._definition = _.extend({}, parent.prototype._definition);
child.prototype._collections = _.extend({}, parent.prototype._collections);

@@ -495,0 +496,0 @@ // Mix in all prototype properties to the subclass if supplied.

11

package.json
{
"name": "ampersand-state",
"description": "An observable, extensible state object with derived watchable properties.",
"version": "0.4.0",
"version": "0.4.1",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -10,11 +10,12 @@ "bugs": {

"dependencies": {
"array-next": "~0.0.1",
"backbone-events-standalone": "~0.2.1",
"underscore": "~1.6.0",
"array-next": "~0.0.1"
"underscore": "~1.6.0"
},
"devDependencies": {
"ampersand-collection": "~0.2.3",
"ampersand-registry": "0.x.x",
"precommit-hook": "~0.3.10",
"run-browser": "~1.2.0",
"tape": "~2.11.0",
"precommit-hook": "~0.3.10"
"tape": "~2.12.1"
},

@@ -21,0 +22,0 @@ "homepage": "https://github.com/ampersandjs/ampersand-state",

var tape = require('tape');
var State = require('../ampersand-state');
var AmpersandRegistry = require('ampersand-registry');
var Collection = require('ampersand-collection');
var definition, Foo, registry;

@@ -97,3 +98,8 @@

"use strict";
// detect if strict mode worked
var isStrict = (function () { return !this; })();
bar.someProperty = 'new';
// throw type error to be able to test in browsers
// that don't support strict
if (!isStrict) throw TypeError;
}, TypeError, 'Throws exception in strict mode.');

@@ -654,1 +660,57 @@ bar.someOtherProperty = 'something';

});
test('should be able to inherit for use in other objects', function (t) {
var StateObj = State.extend({
props: {
name: 'string'
}
});
function AwesomeThing() {
StateObj.apply(this, arguments);
}
AwesomeThing.prototype = Object.create(StateObj.prototype, {
constructor: AwesomeThing
});
AwesomeThing.prototype.hello = function () {
return this.name;
};
var awe = new AwesomeThing({name: 'cool'});
t.equal(awe.hello(), 'cool');
t.equal(awe.name, 'cool');
t.end();
});
test('extended state objects should maintain child collections of parents', function (t) {
var State1 = State.extend({
collections: {
myStuff: Collection
}
});
var State2 = State1.extend({
collections: {
myOtherCollection: Collection
}
});
var thing = new State2();
t.ok(thing.myStuff);
t.ok(thing.myOtherCollection);
t.end();
});
test('`initialize` should have access to initialized child collections', function (t) {
var StateObj = State.extend({
initialize: function () {
t.ok(this.myStuff);
t.equal(this.myStuff.parent, this);
t.end();
},
collections: {
myStuff: Collection
}
});
var thing = new StateObj();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc