update
This commit is contained in:
15
package/node_modules/json-stringify-nice/LICENSE
generated
vendored
Normal file
15
package/node_modules/json-stringify-nice/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
38
package/node_modules/json-stringify-nice/index.js
generated
vendored
Normal file
38
package/node_modules/json-stringify-nice/index.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
const isObj = val => !!val && !Array.isArray(val) && typeof val === 'object'
|
||||
|
||||
const compare = (ak, bk, prefKeys) =>
|
||||
prefKeys.includes(ak) && !prefKeys.includes(bk) ? -1
|
||||
: prefKeys.includes(bk) && !prefKeys.includes(ak) ? 1
|
||||
: prefKeys.includes(ak) && prefKeys.includes(bk)
|
||||
? prefKeys.indexOf(ak) - prefKeys.indexOf(bk)
|
||||
: ak.localeCompare(bk, 'en')
|
||||
|
||||
const sort = (replacer, seen) => (key, val) => {
|
||||
const prefKeys = Array.isArray(replacer) ? replacer : []
|
||||
|
||||
if (typeof replacer === 'function')
|
||||
val = replacer(key, val)
|
||||
|
||||
if (!isObj(val))
|
||||
return val
|
||||
|
||||
if (seen.has(val))
|
||||
return seen.get(val)
|
||||
|
||||
const ret = Object.entries(val).sort(
|
||||
([ak, av], [bk, bv]) =>
|
||||
isObj(av) === isObj(bv) ? compare(ak, bk, prefKeys)
|
||||
: isObj(av) ? 1
|
||||
: -1
|
||||
).reduce((set, [k, v]) => {
|
||||
set[k] = v
|
||||
return set
|
||||
}, {})
|
||||
|
||||
seen.set(val, ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
module.exports = (obj, replacer, space = 2) =>
|
||||
JSON.stringify(obj, sort(replacer, new Map()), space)
|
||||
+ (space ? '\n' : '')
|
40
package/node_modules/json-stringify-nice/package.json
generated
vendored
Normal file
40
package/node_modules/json-stringify-nice/package.json
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "json-stringify-nice",
|
||||
"version": "1.1.4",
|
||||
"description": "Stringify an object sorting scalars before objects, and defaulting to 2-space indent",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"posttest": "npm run lint",
|
||||
"snap": "tap",
|
||||
"postsnap": "npm run lintfix",
|
||||
"eslint": "eslint",
|
||||
"lint": "npm run eslint -- index.js test/**/*.js",
|
||||
"lintfix": "npm run lint -- --fix",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --follow-tags"
|
||||
},
|
||||
"tap": {
|
||||
"test-env": [
|
||||
"LC_ALL=sk"
|
||||
],
|
||||
"check-coverage": true
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.25.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-plugin-promise": "^5.1.0",
|
||||
"eslint-plugin-standard": "^5.0.0",
|
||||
"tap": "^15.0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
},
|
||||
"repository": "https://github.com/isaacs/json-stringify-nice",
|
||||
"files": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user