d3-state-visualizer
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -10,26 +10,8 @@ 'use strict'; | ||
var _isPlainObject = require('is-plain-object'); | ||
var _fclone = require('fclone'); | ||
var _isPlainObject2 = _interopRequireDefault(_isPlainObject); | ||
var _fclone2 = _interopRequireDefault(_fclone); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function isSerializable(obj) { | ||
if (obj === undefined || obj === null || (0, _ramda.is)(Boolean, obj) || (0, _ramda.is)(Number, obj) || (0, _ramda.is)(String, obj)) { | ||
return true; | ||
} | ||
if (!(0, _isPlainObject2.default)(obj) && !(0, _ramda.is)(Array, obj)) { | ||
return false; | ||
} | ||
for (var key in obj) { | ||
if (!isSerializable(obj[key])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
function sortObject(obj, strict) { | ||
@@ -48,8 +30,2 @@ if (obj instanceof Array) { | ||
var _ret = function () { | ||
if (!isSerializable(obj)) { | ||
return { | ||
v: { error: 'not serializable' } | ||
}; | ||
} | ||
var tObj = {}; | ||
@@ -71,3 +47,3 @@ Object.keys(obj).sort().forEach(function (key) { | ||
function sortAndSerialize(obj) { | ||
return JSON.stringify(sortObject(obj, true), undefined, 2); | ||
return JSON.stringify(sortObject((0, _fclone2.default)(obj), true), undefined, 2); | ||
} |
{ | ||
"name": "d3-state-visualizer", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Visualize your app state with a range of reusable charts", | ||
@@ -58,2 +58,3 @@ "main": "lib/index.js", | ||
"deepmerge": "^0.2.10", | ||
"fclone": "^1.0.8", | ||
"is-plain-object": "2.0.1", | ||
@@ -60,0 +61,0 @@ "json-pretty": "0.0.1", |
import { is } from 'ramda' | ||
import isPlainObject from 'is-plain-object' | ||
import fclone from 'fclone'; | ||
function isSerializable(obj) { | ||
if (obj === undefined || obj === null || is(Boolean, obj) || is(Number, obj) || is(String, obj)) { | ||
return true | ||
} | ||
if (!isPlainObject(obj) && !is(Array, obj)) { | ||
return false | ||
} | ||
for (const key in obj) { | ||
if (!isSerializable(obj[key])) { | ||
return false | ||
} | ||
} | ||
return true | ||
} | ||
function sortObject(obj, strict) { | ||
@@ -34,6 +16,2 @@ if (obj instanceof Array) { | ||
if (obj && typeof obj === 'object') { | ||
if (!isSerializable(obj)) { | ||
return {error: 'not serializable'} | ||
} | ||
const tObj = {} | ||
@@ -48,3 +26,3 @@ Object.keys(obj).sort().forEach(key => tObj[key] = sortObject(obj[key])) | ||
export default function sortAndSerialize(obj) { | ||
return JSON.stringify(sortObject(obj, true), undefined, 2) | ||
return JSON.stringify(sortObject(fclone(obj), true), undefined, 2) | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1001890
22351
8
+ Addedfclone@^1.0.8
+ Addedfclone@1.0.11(transitive)