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

serialize-javascript

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serialize-javascript - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

22

index.js

@@ -11,3 +11,3 @@ /*

var UID = Math.floor(Math.random() * 0x10000000000).toString(16);
var PLACE_HOLDER_REGEXP = new RegExp('"@__(F|R|D|M|S)-' + UID + '-(\\d+)__@"', 'g');
var PLACE_HOLDER_REGEXP = new RegExp('"@__(F|R|D|M|S|U)-' + UID + '-(\\d+)__@"', 'g');

@@ -48,2 +48,3 @@ var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;

var sets = [];
var undefs = [];

@@ -53,3 +54,4 @@ // Returns placeholders for functions and regexps (identified by index)

function replacer(key, value) {
if (!value) {
if (!value && value !== undefined) {
return value;

@@ -85,2 +87,6 @@ }

if (type === 'undefined') {
return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
}
return value;

@@ -126,2 +132,8 @@ }

// Protects against `JSON.stringify()` returning `undefined`, by serializing
// to the literal string: "undefined".
if (obj === undefined) {
return String(obj);
}
var str;

@@ -150,3 +162,3 @@

if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0) {
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && undefs.length === 0) {
return str;

@@ -175,2 +187,6 @@ }

if (type === 'U') {
return 'undefined'
}
var fn = functions[valueIndex];

@@ -177,0 +193,0 @@

2

package.json
{
"name": "serialize-javascript",
"version": "1.8.0",
"version": "1.9.0",
"description": "Serialize JavaScript to a superset of JSON that includes regular expressions and functions.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -55,3 +55,3 @@ Serialize JavaScript

```js
'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,date:new Date("2016-04-28T22:02:17.156Z"),new Map([["hello", "world"]]),new Set([123,456]),"fn":function echo(arg) { return arg; },"re":/([^\\s]+)/g}'
'{"str":"string","num":0,"obj":{"foo":"foo"},"arr":[1,2,3],"bool":true,"nil":null,"undef":undefined,"date":new Date("2016-04-28T22:02:17.000Z"),"map":new Map([["hello","world"]]),"set":new Set([123,456]),"fn":function echo(arg) { return arg; },"re":/([^\s]+)/g}'
```

@@ -58,0 +58,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