Comparing version 1.0.1 to 1.1.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [1.1.0](https://github.com/nuxt-contrib/destr/compare/v1.0.1...v1.1.0) (2021-01-21) | ||
### Features | ||
* **pkg:** expose mjs format ([104fe6c](https://github.com/nuxt-contrib/destr/commit/104fe6c2ae4e602cadfb1b66271f2352c1e2acf4)) | ||
### [1.0.1](https://github.com/nuxt-contrib/destr/compare/v1.0.0...v1.0.1) (2020-11-08) | ||
@@ -7,0 +14,0 @@ |
@@ -1,1 +0,3 @@ | ||
export default function destr(val: any): any; | ||
declare function destr(val: any): any; | ||
export default destr; |
'use strict'; | ||
// https://github.com/fastify/secure-json-parse | ||
// https://github.com/hapijs/bourne | ||
var suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/; | ||
var suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/; | ||
var JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/; | ||
const suspectProtoRx = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/; | ||
const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/; | ||
const JsonSigRx = /^["{[]|^-?[0-9][0-9.]{0,14}$/; | ||
function jsonParseTransform(key, value) { | ||
if (key === '__proto__' || key === 'constructor') { | ||
if (key === "__proto__" || key === "constructor") { | ||
return; | ||
} | ||
return value; | ||
} | ||
function destr(val) { | ||
if (typeof val !== 'string') { | ||
if (typeof val !== "string") { | ||
return val; | ||
} | ||
var _lval = val.toLowerCase(); | ||
if (_lval === 'true') { | ||
const _lval = val.toLowerCase(); | ||
if (_lval === "true") { | ||
return true; | ||
} | ||
if (_lval === 'false') { | ||
if (_lval === "false") { | ||
return false; | ||
} | ||
if (_lval === 'null') { | ||
if (_lval === "null") { | ||
return null; | ||
} | ||
if (_lval === 'nan') { | ||
if (_lval === "nan") { | ||
return NaN; | ||
} | ||
if (_lval === 'infinity') { | ||
if (_lval === "infinity") { | ||
return Infinity; | ||
} | ||
if (_lval === 'undefined') { | ||
return undefined; | ||
if (_lval === "undefined") { | ||
return void 0; | ||
} | ||
if (!JsonSigRx.test(val)) { | ||
return val; | ||
} | ||
try { | ||
@@ -56,3 +42,2 @@ if (suspectProtoRx.test(val) || suspectConstructorRx.test(val)) { | ||
} | ||
return JSON.parse(val); | ||
@@ -59,0 +44,0 @@ } catch (_e) { |
{ | ||
"name": "destr", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A faster, secure and convenient alternative for JSON.parse", | ||
@@ -8,2 +8,3 @@ "repository": "nuxt-contrib/destr", | ||
"main": "dist/index.js", | ||
"module": "dist/index.mjs", | ||
"types": "dist/index.d.ts", | ||
@@ -15,3 +16,3 @@ "files": [ | ||
"bench": "yarn build && node ./bench.js", | ||
"build": "bili src/index.ts", | ||
"build": "siroc build", | ||
"lint": "eslint --ext .ts .", | ||
@@ -22,9 +23,9 @@ "release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish", | ||
"devDependencies": { | ||
"@hapi/bourne": "^2.0.0", | ||
"@hapi/bourne": "latest", | ||
"@nuxtjs/eslint-config-typescript": "latest", | ||
"benchmark": "latest", | ||
"bili": "latest", | ||
"eslint": "latest", | ||
"rollup-plugin-typescript2": "latest", | ||
"secure-json-parse": "^2.1.0", | ||
"secure-json-parse": "latest", | ||
"siroc": "latest", | ||
"standard-version": "latest", | ||
@@ -31,0 +32,0 @@ "typescript": "latest" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9561
7
93