Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ampersand-state

Package Overview
Dependencies
Maintainers
4
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 4.3.12 to 4.3.13

2

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

@@ -6,0 +6,0 @@ "bugs": {

@@ -323,3 +323,3 @@ # ampersand-state

props: {
name: 'Phil'
name: 'string'
},

@@ -346,2 +346,45 @@ children: {

### collections `AmpersandState.extend({ collections: { widgets: Widgets } })`
Define child collection objects to attach to the object. Attributes passed to the constructor or to `set()` will be proxied to the collections.
```javascript
var State = require('ampersand-state');
var Collection = require('ampersand-collection');
var Widget = State.extend({
props: {
name: 'string',
funLevel: 'number'
}
});
var WidgetCollection = Collection.extend({
model: Widget
});
var Person = AmpersandState.extend({
props: {
name: 'string'
},
collections: {
widgets: WidgetCollection
}
});
var me = new Person({
name: 'Henrik',
widgets: [
{ name: 'rc car', funLevel: 8 },
{ name: 'skis', funLevel: 11 }
]
});
console.log(me.widgets.length); //=> 2
console.log(me.widgets instanceof WidgetCollection); //=> true
```
Note that currently, events *don't* bubble from collections to parent automatically. This is done for efficiency reasons. But there are discussions ongoing about how to best handle this case.
### parse

@@ -348,0 +391,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc