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

object-lib

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

object-lib - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

20

lib/core/json-smart-parse.js

@@ -0,1 +1,7 @@

const subs = { // table of character substitutions
'\n': '\\n',
'\r': '\\r',
'\t': '\\t'
};
export default (str) => {

@@ -7,3 +13,3 @@ let result = str;

const unescaped = [];
result = result.split('');
let escaped = false;

@@ -13,4 +19,4 @@ let quoted = false;

const char = result[i];
if (['\n', '\r', '\t'].includes(char) && quoted) {
unescaped.push(i);
if (quoted && char in subs) {
result[i] = subs[char];
}

@@ -22,11 +28,5 @@ if (!escaped && char === '"') {

}
result = result.join('');
result = result.replace(/\n/g, (m, idx) => {
if (unescaped.includes(idx)) {
return JSON.stringify(m).slice(1, -1);
}
return m;
});
return JSON.parse(result);
};
{
"name": "object-lib",
"type": "module",
"version": "4.1.0",
"version": "4.1.1",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "repository": {

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