Comparing version 0.0.3 to 0.0.4
@@ -648,2 +648,7 @@ "use strict"; | ||
this.each(function (ip) { | ||
// Throw if observation value is not JSON-expressible | ||
if (!(0, _jsonExpressible.default)(ip.obs.value())) { | ||
throw new Error("NOT_SERIALIZABLE: One or more observation values is not JSON-expressible."); | ||
} | ||
var obs = [_jsontsdate.default.create(ip.start(), "ms"), ip.obs.value()]; // Is this observation contiguous with the next? | ||
@@ -656,20 +661,5 @@ | ||
jsonTs.Observations.push(obs); | ||
}); // Try to serialize - fails on circular reference | ||
}); // Success | ||
var ser; | ||
try { | ||
ser = JSON.stringify(jsonTs); | ||
} catch (e) { | ||
throw new Error("NOT_SERIALIZABLE: JSON.stringify() failed to serialize one or more observation values, likely due to a circular reference."); | ||
} // Throw if there are undefined values (JSON.stringify will omit/nullify them) | ||
// Check after circular references, which will hang chronology._isJsonExpressible() | ||
if (!(0, _jsonExpressible.default)(jsonTs)) { | ||
throw new Error("NOT_SERIALIZABLE: Time series contains one or more undefined values, which are not expressible using JSON."); | ||
} // Success | ||
return ser; | ||
return JSON.stringify(jsonTs); | ||
}; | ||
@@ -676,0 +666,0 @@ /** |
{ | ||
"name": "chronology", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A flexible library for representing and manipulating time series data.", | ||
"main": "index.js", | ||
"jsdelivr": "bundle.js", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "docs": "documentation build src/main.js -f html -o docs --access public --access private --access undefined --sort-order alpha", |
@@ -1004,3 +1004,8 @@ "use strict"; | ||
this.each(function (rp) { | ||
// Is this observation adjacent to a previous one? | ||
// Throw if observation value is not JSON-expressible | ||
if (!(0, _jsonExpressible.default)(rp.obs.value())) { | ||
throw new Error("NOT_SERIALIZABLE: One or more observation values is not JSON-expressible."); | ||
} // Is this observation adjacent to a previous one? | ||
var adjacent = false; | ||
@@ -1029,20 +1034,5 @@ | ||
} | ||
}); // Try to serialize (fails on circular reference) | ||
}); // Success | ||
var ser; | ||
try { | ||
ser = JSON.stringify(jsonTs); | ||
} catch (e) { | ||
throw new Error("NOT_SERIALIZABLE: JSON.stringify() failed to serialize one or more observation values, likely due to a circular reference."); | ||
} // Throw if there are undefined values (JSON.stringify will omit/nullify them) | ||
// Check after circular references, which will hang chronology._isJsonExpressible() | ||
if (!(0, _jsonExpressible.default)(jsonTs)) { | ||
throw new Error("NOT_SERIALIZABLE: Time series contains one or more undefined values, which are not expressible using JSON."); | ||
} // Success | ||
return ser; | ||
return JSON.stringify(jsonTs); | ||
}; // RegularPeriod objects | ||
@@ -1049,0 +1039,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1560529
3764