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

@ungap/structured-clone

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ungap/structured-clone - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

2

cjs/deserialize.js
'use strict';
const _item = ({type, value}, info, as) => {
const _item = ([type, value], info, as) => {
switch (type) {

@@ -4,0 +4,0 @@ case 'primitive':

@@ -21,3 +21,3 @@ 'use strict';

case 'bigint':
return as({type: 'BigInt', value: value.toString()});
return as(['BigInt', value.toString()]);
case 'object':

@@ -31,3 +31,3 @@ if (value !== null) {

entries.push([key, _serialize(value[key], info)]);
return as({type, value: entries});
return as([type, entries]);
}

@@ -37,14 +37,14 @@ case 'Boolean':

case 'String':
return as({type, value: value.valueOf()});
return as([type, value.valueOf()]);
case 'Date':
return as({type, value: value.toISOString()});
return as([type, value.toISOString()]);
case 'RegExp': {
const {source, flags} = value;
return as({type, value: {source, flags}});
return as([type, {source, flags}]);
}
case 'Map': {
const map = [];
const entries = [];
for (const [key, entry] of value)
map.push([_serialize(key, info), _serialize(entry, info)]);
return as({type, value: map});
entries.push([_serialize(key, info), _serialize(entry, info)]);
return as([type, entries]);
}

@@ -55,9 +55,9 @@ case 'Array': {

arr.push(_serialize(entry, info));
return as({type, value: arr});
return as([type, arr]);
}
case 'Set': {
const set = [];
const values = [];
for (const entry of value)
set.push(_serialize(entry, info));
return as({type, value: set});
values.push(_serialize(entry, info));
return as([type, values]);
}

@@ -67,7 +67,7 @@ }

if (type.includes('Array'))
return as({type, value: [...value]});
return as([type, [...value]]);
if (type.includes('Error')) {
const {message} = value;
return as({type: 'Error', value: {name: type, message}});
return as(['Error', {name: type, message}]);
}

@@ -81,3 +81,3 @@

case 'undefined':
return as({type: 'primitive', value});
return as(['primitive', value]);
default:

@@ -84,0 +84,0 @@ throw new TypeError;

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

const _item = ({type, value}, info, as) => {
const _item = ([type, value], info, as) => {
switch (type) {

@@ -3,0 +3,0 @@ case 'primitive':

@@ -20,3 +20,3 @@ const {toString} = {};

case 'bigint':
return as({type: 'BigInt', value: value.toString()});
return as(['BigInt', value.toString()]);
case 'object':

@@ -30,3 +30,3 @@ if (value !== null) {

entries.push([key, _serialize(value[key], info)]);
return as({type, value: entries});
return as([type, entries]);
}

@@ -36,14 +36,14 @@ case 'Boolean':

case 'String':
return as({type, value: value.valueOf()});
return as([type, value.valueOf()]);
case 'Date':
return as({type, value: value.toISOString()});
return as([type, value.toISOString()]);
case 'RegExp': {
const {source, flags} = value;
return as({type, value: {source, flags}});
return as([type, {source, flags}]);
}
case 'Map': {
const map = [];
const entries = [];
for (const [key, entry] of value)
map.push([_serialize(key, info), _serialize(entry, info)]);
return as({type, value: map});
entries.push([_serialize(key, info), _serialize(entry, info)]);
return as([type, entries]);
}

@@ -54,9 +54,9 @@ case 'Array': {

arr.push(_serialize(entry, info));
return as({type, value: arr});
return as([type, arr]);
}
case 'Set': {
const set = [];
const values = [];
for (const entry of value)
set.push(_serialize(entry, info));
return as({type, value: set});
values.push(_serialize(entry, info));
return as([type, values]);
}

@@ -66,7 +66,7 @@ }

if (type.includes('Array'))
return as({type, value: [...value]});
return as([type, [...value]]);
if (type.includes('Error')) {
const {message} = value;
return as({type: 'Error', value: {name: type, message}});
return as(['Error', {name: type, message}]);
}

@@ -80,3 +80,3 @@

case 'undefined':
return as({type: 'primitive', value});
return as(['primitive', value]);
default:

@@ -83,0 +83,0 @@ throw new TypeError;

{
"name": "@ungap/structured-clone",
"version": "0.0.0",
"version": "0.0.1",
"description": "A structuredClone polyfill",

@@ -29,2 +29,2 @@ "main": "./cjs/index.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