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

devalue

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

devalue - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

4

CHANGELOG.md
# devalue changelog
## 1.0.4
* Smaller output ([#10](https://github.com/Rich-Harris/devalue/pull/10))
## 1.0.3

@@ -4,0 +8,0 @@

32

dist/devalue.esm.js

@@ -7,5 +7,3 @@ var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';

function devalue(value) {
var repeated = new Map();
var seen = new Set();
var n = 0;
var counts = new Map();
function walk(thing) {

@@ -15,7 +13,7 @@ if (typeof thing === 'function') {

}
if (seen.has(thing)) {
repeated.set(thing, getName(n++));
if (counts.has(thing)) {
counts.set(thing, counts.get(thing) + 1);
return;
}
seen.add(thing);
counts.set(thing, 1);
if (!isPrimitive(thing)) {

@@ -51,5 +49,13 @@ var type = getType(thing);

}
walk(value);
var names = new Map();
Array.from(counts)
.filter(function (entry) { return entry[1] > 1; })
.sort(function (a, b) { return b[1] - a[1]; })
.forEach(function (entry, i) {
names.set(entry[0], getName(i));
});
function stringify(thing) {
if (repeated.has(thing)) {
return repeated.get(thing);
if (names.has(thing)) {
return names.get(thing);
}

@@ -87,9 +93,8 @@ if (isPrimitive(thing)) {

}
walk(value);
var str = stringify(value);
if (repeated.size) {
if (names.size) {
var params_1 = [];
var statements_1 = [];
var values_1 = [];
repeated.forEach(function (name, thing) {
names.forEach(function (name, thing) {
params_1.push(name);

@@ -165,3 +170,6 @@ if (isPrimitive(thing)) {

return '-0';
return String(thing);
var str = String(thing);
if (typeof thing === 'number')
return str.replace(/^(-)?0\./, '$1.');
return str;
}

@@ -168,0 +176,0 @@ function getType(thing) {

@@ -13,5 +13,3 @@ (function (global, factory) {

function devalue(value) {
var repeated = new Map();
var seen = new Set();
var n = 0;
var counts = new Map();
function walk(thing) {

@@ -21,7 +19,7 @@ if (typeof thing === 'function') {

}
if (seen.has(thing)) {
repeated.set(thing, getName(n++));
if (counts.has(thing)) {
counts.set(thing, counts.get(thing) + 1);
return;
}
seen.add(thing);
counts.set(thing, 1);
if (!isPrimitive(thing)) {

@@ -57,5 +55,13 @@ var type = getType(thing);

}
walk(value);
var names = new Map();
Array.from(counts)
.filter(function (entry) { return entry[1] > 1; })
.sort(function (a, b) { return b[1] - a[1]; })
.forEach(function (entry, i) {
names.set(entry[0], getName(i));
});
function stringify(thing) {
if (repeated.has(thing)) {
return repeated.get(thing);
if (names.has(thing)) {
return names.get(thing);
}

@@ -93,9 +99,8 @@ if (isPrimitive(thing)) {

}
walk(value);
var str = stringify(value);
if (repeated.size) {
if (names.size) {
var params_1 = [];
var statements_1 = [];
var values_1 = [];
repeated.forEach(function (name, thing) {
names.forEach(function (name, thing) {
params_1.push(name);

@@ -171,3 +176,6 @@ if (isPrimitive(thing)) {

return '-0';
return String(thing);
var str = String(thing);
if (typeof thing === 'number')
return str.replace(/^(-)?0\./, '$1.');
return str;
}

@@ -174,0 +182,0 @@ function getType(thing) {

{
"name": "devalue",
"description": "Gets the job done when JSON.stringify can't",
"version": "1.0.3",
"version": "1.0.4",
"repository": "Rich-Harris/devalue",

@@ -6,0 +6,0 @@ "main": "dist/devalue.umd.js",

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