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

flatted

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatted - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

28

cjs/index.js

@@ -1,2 +0,2 @@

var Flatted = (function (String) {
var Flatted = (function (Primitive, primitive) {

@@ -24,3 +24,3 @@ /*!

parse: function parse(text) {
var input = JSON.parse(text, Strings).map(strings);
var input = JSON.parse(text, Primitives).map(primitives);
var value = input[0];

@@ -34,12 +34,12 @@ return typeof value === 'object' && value ?

firstRun,
i = 0,
known = new Map,
output = (known.set(value, String(i)), []),
input = [value],
input = [],
output = [],
i = +set(known, input, value),
replace = function (key, value) {
if (firstRun) return (firstRun = !firstRun), value;
switch (typeof value) {
case "object":
case 'object':
if (value === null) return value;
case "string":
case primitive:
return known.get(value) || set(known, input, value);

@@ -65,3 +65,3 @@ }

var value = output[key];
if (value instanceof String) {
if (value instanceof Primitive) {
var tmp = input[value];

@@ -82,3 +82,3 @@ if (typeof tmp === 'object' && !parsed.has(tmp)) {

function set(known, input, value) {
var index = String(input.push(value) - 1);
var index = Primitive(input.push(value) - 1);
known.set(value, index);

@@ -88,11 +88,11 @@ return index;

function strings(value) {
return value instanceof String ? String(value) : value;
function primitives(value) {
return value instanceof Primitive ? Primitive(value) : value;
}
function Strings(key, value) {
return typeof value === 'string' ? new String(value) : value;
function Primitives(key, value) {
return typeof value === primitive ? new Primitive(value) : value;
}
}(String));
}(String, 'string'));
module.exports = Flatted;

@@ -1,2 +0,2 @@

var Flatted = (function (String) {
var Flatted = (function (Primitive, primitive) {

@@ -24,3 +24,3 @@ /*!

parse: function parse(text) {
var input = JSON.parse(text, Strings).map(strings);
var input = JSON.parse(text, Primitives).map(primitives);
var value = input[0];

@@ -34,12 +34,12 @@ return typeof value === 'object' && value ?

firstRun,
i = 0,
known = new Map,
output = (known.set(value, String(i)), []),
input = [value],
input = [],
output = [],
i = +set(known, input, value),
replace = function (key, value) {
if (firstRun) return (firstRun = !firstRun), value;
switch (typeof value) {
case "object":
case 'object':
if (value === null) return value;
case "string":
case primitive:
return known.get(value) || set(known, input, value);

@@ -65,3 +65,3 @@ }

var value = output[key];
if (value instanceof String) {
if (value instanceof Primitive) {
var tmp = input[value];

@@ -82,3 +82,3 @@ if (typeof tmp === 'object' && !parsed.has(tmp)) {

function set(known, input, value) {
var index = String(input.push(value) - 1);
var index = Primitive(input.push(value) - 1);
known.set(value, index);

@@ -88,13 +88,13 @@ return index;

function strings(value) {
return value instanceof String ? String(value) : value;
function primitives(value) {
return value instanceof Primitive ? Primitive(value) : value;
}
function Strings(key, value) {
return typeof value === 'string' ? new String(value) : value;
function Primitives(key, value) {
return typeof value === primitive ? new Primitive(value) : value;
}
}(String));
}(String, 'string'));
export default Flatted;
export const parse = Flatted.parse;
export const stringify = Flatted.stringify;

@@ -1,2 +0,2 @@

var Flatted = (function (String) {
var Flatted = (function (Primitive, primitive) {

@@ -24,3 +24,3 @@ /*!

parse: function parse(text) {
var input = JSON.parse(text, Strings).map(strings);
var input = JSON.parse(text, Primitives).map(primitives);
var value = input[0];

@@ -34,12 +34,12 @@ return typeof value === 'object' && value ?

firstRun,
i = 0,
known = new Map,
output = (known.set(value, String(i)), []),
input = [value],
input = [],
output = [],
i = +set(known, input, value),
replace = function (key, value) {
if (firstRun) return (firstRun = !firstRun), value;
switch (typeof value) {
case "object":
case 'object':
if (value === null) return value;
case "string":
case primitive:
return known.get(value) || set(known, input, value);

@@ -65,3 +65,3 @@ }

var value = output[key];
if (value instanceof String) {
if (value instanceof Primitive) {
var tmp = input[value];

@@ -82,3 +82,3 @@ if (typeof tmp === 'object' && !parsed.has(tmp)) {

function set(known, input, value) {
var index = String(input.push(value) - 1);
var index = Primitive(input.push(value) - 1);
known.set(value, index);

@@ -88,10 +88,10 @@ return index;

function strings(value) {
return value instanceof String ? String(value) : value;
function primitives(value) {
return value instanceof Primitive ? Primitive(value) : value;
}
function Strings(key, value) {
return typeof value === 'string' ? new String(value) : value;
function Primitives(key, value) {
return typeof value === primitive ? new Primitive(value) : value;
}
}(String));
}(String, 'string'));
/*! (c) 2018, Andrea Giammarchi, (ISC) */
var Flatted=function(c){return{parse:function(n){var t=JSON.parse(n,i).map(r),e=t[0];return"object"==typeof e&&e?function i(u,f,n){return Object.keys(n).reduce(function(n,t){var e=n[t];if(e instanceof c){var r=u[e];"object"!=typeof r||f.has(r)?n[t]=r:(f.add(r),n[t]=i(u,f,r))}return n},n)}(t,new Set,e):e},stringify:function(n){for(var u,t=0,f=new Map,e=(f.set(n,c(t)),[]),o=[n],r=function(n,t){if(u)return u=!u,t;switch(typeof t){case"object":if(null===t)return t;case"string":return f.get(t)||(e=f,i=c(o.push(r=t)-1),e.set(r,i),i)}var e,r,i;return t};t<o.length;t++)u=!0,e[t]=JSON.stringify(o[t],r);return"["+e.join(",")+"]"}};function r(n){return n instanceof c?c(n):n}function i(n,t){return"string"==typeof t?new c(t):t}}(String);
var Flatted=function(o,c){return{parse:function(n){var t=JSON.parse(n,u).map(e),r=t[0];return"object"==typeof r&&r?function u(i,f,n){return Object.keys(n).reduce(function(n,t){var r=n[t];if(r instanceof o){var e=i[r];"object"!=typeof e||f.has(e)?n[t]=e:(f.add(e),n[t]=u(i,f,e))}return n},n)}(t,new Set,r):r},stringify:function(n){for(var r,e=new Map,u=[],t=[],i=+a(e,u,n),f=function(n,t){if(r)return r=!r,t;switch(typeof t){case"object":if(null===t)return t;case c:return e.get(t)||a(e,u,t)}return t};i<u.length;i++)r=!0,t[i]=JSON.stringify(u[i],f);return"["+t.join(",")+"]"}};function a(n,t,r){var e=o(t.push(r)-1);return n.set(r,e),e}function e(n){return n instanceof o?o(n):n}function u(n,t){return typeof t===c?new o(t):t}}(String,"string");
{
"name": "flatted",
"version": "0.2.0",
"version": "0.2.1",
"description": "A fast and minimal circular JSON parser.",

@@ -9,2 +9,3 @@ "browser": "min.js",

"scripts": {
"bench": "node test/bench.js",
"build": "npm run cjs && npm test && npm run esm && npm run min && npm run size",

@@ -36,2 +37,5 @@ "coveralls": "cat ./coverage/lcov.info | coveralls",

"devDependencies": {
"circular-json": "latest",
"circular-json-es6": "latest",
"jsan": "latest",
"uglify-js": "^3.3.22"

@@ -38,0 +42,0 @@ },

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