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

d3-state-visualizer

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-state-visualizer - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

30

lib/charts/tree/sortAndSerialize.js

@@ -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);
}

3

package.json
{
"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

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