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

promised-models

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promised-models - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

17

lib/types/number.js

@@ -6,5 +6,19 @@ /**

module.exports = Attribute.inherit({
default: NaN,
/**
* work around with Infinity
* @override
*/
toJSON: function () {
var value = this.__base.apply(this, arguments);
if ((value === Infinity) || (value === -Infinity)) {
return String(value);
} else {
return value;
}
},
/**
* @override {Attribute}

@@ -24,4 +38,7 @@ */

parse: function (value) {
if (value === null) {
return NaN;
}
return Number(value);
}
});

2

package.json
{
"description": "promise based, typed attributes, nested models and collections",
"name": "promised-models",
"version": "0.0.19",
"version": "0.0.20",
"repository": "git@github.com:delfrrr/promised-models.git",

@@ -6,0 +6,0 @@ "keywords": [

@@ -147,2 +147,9 @@ # Promised Models

**Note:** Returned object supposed to be serializable via `JSON.parse()`. Due to this reason `NaN` and `Infinity` are serialized in this way:
```
NaN -> null
Infinity -> 'Infinity'
```
#### isChanged `model.isChanged([branch])`

@@ -149,0 +156,0 @@

@@ -1,2 +0,3 @@

var expect = require('chai').expect;
var expect = require('chai').expect,
Model = require('../lib/model');

@@ -120,2 +121,39 @@ describe('Common', function () {

});
it('should return serializable value NaN', function () {
var ModelsWithNumbers = Model.inherit({
attributes: {
n: Model.attributeTypes.Number
}
}),
model1 = new ModelsWithNumbers(),
model2 = new ModelsWithNumbers(
JSON.parse(
JSON.stringify(
model1.toJSON()
)
)
);
expect(isNaN(model2.get('n'))).to.be.equal(true);
});
it('should return serializable value Infinity', function () {
var ModelsWithNumbers = Model.inherit({
attributes: {
n: Model.attributeTypes.Number
}
}),
model1 = new ModelsWithNumbers({
n: -Infinity
}),
model2 = new ModelsWithNumbers(
JSON.parse(
JSON.stringify(
model1.toJSON()
)
)
);
expect(model2.get('n')).to.be.equal(-Infinity);
});
});

@@ -122,0 +160,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