Socket
Socket
Sign inDemoInstall

ampersand-state

Package Overview
Dependencies
4
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.1 to 4.3.2

test/to-port.js

27

ampersand-state.js

@@ -484,3 +484,4 @@ var _ = require('underscore');

isState: {
value: true
get: function () { return true; },
set: function () { }
}

@@ -493,3 +494,4 @@ });

var def = object._definition[name] = {};
var type;
var type, descArray;
if (_.isString(desc)) {

@@ -500,11 +502,22 @@ // grab our type if all we've got is a string

} else {
type = object._ensureValidType(desc[0] || desc.type);
//Transform array of ['type', required, default] to object form
if (_.isArray(desc)) {
descArray = desc;
desc = {
type: descArray[0],
required: descArray[1],
default: descArray[2]
};
}
type = object._ensureValidType(desc.type);
if (type) def.type = type;
if (desc[1] || desc.required) def.required = true;
// set default if defined
def.default = !_.isUndefined(desc[2]) ? desc[2] : desc.default;
if (typeof def.default === 'object') {
if (desc.required) def.required = true;
if (typeof desc.default === 'object') {
throw new TypeError('The default value for ' + name + ' cannot be an object/array, must be a value or a function which returns a value/object/array');
}
def.default = desc.default;

@@ -511,0 +524,0 @@ def.allowNull = desc.allowNull ? desc.allowNull : false;

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

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

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

[ampersand-model](https://github.com/ampersandjs/ampersand-model) extends ampersand-state to include assumptions that you'd want if you're using models to model date from a REST API. But by itself ampersand-state is useful for anytime you want something to model state, that fires events for changes and lets you define and listen to derived properties.
[ampersand-model](https://github.com/ampersandjs/ampersand-model) extends ampersand-state to include assumptions that you'd want if you're using models to model data from a REST API. But by itself ampersand-state is useful for anytime you want something to model state, that fires events for changes and lets you define and listen to derived properties.

@@ -31,3 +31,3 @@ For further explanation see the [learn ampersand-state](http://ampersandjs.com/learn/state) guide.

To create a **State** class of your own, you extend **AmpersandState** and provide instance properties an options for your class. Typically here you will pass any properties (`props`, `session` and `derived` of your state class, and any instance methods to be attached to instances of your class.
To create a **State** class of your own, you extend **AmpersandState** and provide instance properties and options for your class. Typically here you will pass any properties (`props`, `session` and `derived` of your state class, and any instance methods to be attached to instances of your class.

@@ -125,3 +125,3 @@ **extend** correctly sets up the prototype chain, so that subclasses created with **extend** can be further extended as many times as you like.

Defines how properties that aren't defined in `props`, `session` or `derived` are handled. May be set to `'allow'`, `'reject'` or `'allow'`.
Defines how properties that aren't defined in `props`, `session` or `derived` are handled. May be set to `'allow'`, `'ignore'` or `'reject'`.

@@ -128,0 +128,0 @@ ```javascript

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc