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 4.3.0 to 4.3.1

61

package.json
{
"name": "devalue",
"description": "Gets the job done when JSON.stringify can't",
"version": "4.3.0",
"repository": "Rich-Harris/devalue",
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./index.js",
"default": "./index.js"
}
},
"files": [
"index.js",
"src",
"types"
],
"types": "./types/index.d.ts",
"devDependencies": {
"publint": "^0.1.7",
"typescript": "^3.1.3",
"uvu": "^0.5.6"
},
"scripts": {
"build": "tsc",
"test": "uvu test",
"prepublishOnly": "npm test && publint && npm run build"
},
"license": "MIT",
"type": "module",
"packageManager": "pnpm@7.9.5"
}
"name": "devalue",
"description": "Gets the job done when JSON.stringify can't",
"version": "4.3.1",
"repository": "Rich-Harris/devalue",
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./index.js",
"default": "./index.js"
}
},
"files": [
"index.js",
"src",
"types"
],
"types": "./types/index.d.ts",
"devDependencies": {
"publint": "^0.1.7",
"typescript": "^3.1.3",
"uvu": "^0.5.6"
},
"license": "MIT",
"type": "module",
"packageManager": "pnpm@7.9.5",
"scripts": {
"build": "tsc",
"test": "uvu test"
}
}

@@ -11,3 +11,3 @@ import {

const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$';
const unsafe_chars = /[<>\b\f\n\r\t\0\u2028\u2029]/g;
const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
const reserved =

@@ -14,0 +14,0 @@ /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;

/** @type {Record<string, string>} */
export const escaped = {
'<': '\\u003C',
'>': '\\u003E',
'/': '\\u002F',
'\\': '\\\\',

@@ -12,3 +10,2 @@ '\b': '\\b',

'\t': '\\t',
'\0': '\\u0000',
'\u2028': '\\u2028',

@@ -35,3 +32,5 @@ '\u2029': '\\u2029'

const object_proto_names = Object.getOwnPropertyNames(Object.prototype)
const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
Object.prototype
)
.sort()

@@ -56,33 +55,48 @@ .join('\0');

/** @param {string} char */
function get_escaped_char(char) {
switch (char) {
case '"':
return '\\"';
case '<':
return '\\u003C';
case '\\':
return '\\\\';
case '\n':
return '\\n';
case '\r':
return '\\r';
case '\t':
return '\\t';
case '\b':
return '\\b';
case '\f':
return '\\f';
case '\u2028':
return '\\u2028';
case '\u2029':
return '\\u2029';
default:
return char < ' '
? `\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}`
: '';
}
}
/** @param {string} str */
export function stringify_string(str) {
let result = '"';
let result = '';
let last_pos = 0;
const len = str.length;
for (let i = 0; i < str.length; i += 1) {
const char = str.charAt(i);
const code = char.charCodeAt(0);
if (char === '"') {
result += '\\"';
} else if (char in escaped) {
result += escaped[char];
} else if (code <= 0x001F) {
result += `\\u${code.toString(16).toUpperCase().padStart(4, "0")}`
} else if (code >= 0xd800 && code <= 0xdfff) {
const next = str.charCodeAt(i + 1);
// If this is the beginning of a [high, low] surrogate pair,
// add the next two characters, otherwise escape
if (code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
result += char + str[++i];
} else {
result += `\\u${code.toString(16).toUpperCase()}`;
}
} else {
result += char;
for (let i = 0; i < len; i += 1) {
const char = str[i];
const replacement = get_escaped_char(char);
if (replacement) {
result += str.slice(last_pos, i) + replacement;
last_pos = i + 1;
}
}
result += '"';
return result;
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
}
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