Socket
Socket
Sign inDemoInstall

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.15 to 4.4.0

13

ampersand-state.js

@@ -188,3 +188,3 @@ /*$AMPERSAND_VERSION*/

if (def.values && !_.contains(def.values, newVal)) {
throw new TypeError('Property \'' + attr + '\' must be one of values: ' + def.values.join(', '));
throw new TypeError('Property \'' + attr + '\' must be one of values: ' + def.values.join(', ') + '. Tried to set ' + newVal);
}

@@ -589,6 +589,9 @@

try {
newVal = new Date(parseInt(newVal, 10));
if (!_.isDate(newVal)) throw TypeError;
newVal = newVal.valueOf();
if (_.isNaN(newVal)) throw TypeError;
var dateVal = new Date(newVal).valueOf();
if (isNaN(dateVal)) {
// If the newVal cant be parsed, then try parseInt first
dateVal = new Date(parseInt(newVal, 10)).valueOf();
if (isNaN(dateVal)) throw TypeError;
}
newVal = dateVal;
newType = 'date';

@@ -595,0 +598,0 @@ } catch (e) {

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

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

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

var me = new Person({ personID: 123, name: 'Phil' });
var me = new Person({ personID: 123, name: 'Phil' },{ parse: true});

@@ -422,0 +422,0 @@ console.log(me.id) //=> 123

@@ -267,2 +267,5 @@ var tape = require('tape');

new Foo({today: '1397631169892'});
new Foo({today: '2014-11-13'});
new Foo({today: '2014-11-13T21:01Z'});
new Foo({today: '2014-11-13T21:01:28.752Z'});
});

@@ -1424,1 +1427,41 @@ t.throws(function () {

});
test("#99 #101 - string dates can be parsed", function(t) {
var Today = State.extend({
props: {
today: 'date'
}
});
var isDate = function (obj) { return Object.prototype.toString.call(obj) === '[object Date]'; };
var isoString = '2014-04-16T06:52:49.892Z';
var date = new Date(isoString);
var model = new Today();
model.today = 1397631169892;
t.ok(isDate(model.today));
t.equal(model.today.valueOf(), date.valueOf(), 'date should accept an integer');
model.today = '1397631169892';
t.ok(isDate(model.today));
t.equal(model.today.valueOf(), date.valueOf(), 'date should accept a string which will be parsed to an integer');
model.today = isoString;
t.ok(isDate(model.today));
t.equal(model.today.toJSON(), isoString, 'date should accept an iso string');
model.today = new Date(isoString);
t.ok(isDate(model.today));
t.equal(model.today.toJSON(), isoString, 'date should accept a native date object');
model.today = '2014-11-13';
t.ok(isDate(model.today));
t.equal(model.today.toJSON(), '2014-11-13T00:00:00.000Z', 'date should accept YYYY-MM-DD');
model.today = '2014-11-13T21:01Z';
t.ok(isDate(model.today));
t.equal(model.today.toJSON(), '2014-11-13T21:01:00.000Z', 'date should accept YYYY-MM-DDTHH:MMZ');
t.end();
});
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