Last commit july 5th

This commit is contained in:
2024-07-05 13:46:23 +02:00
parent dad0d86e8c
commit b0e4dfbb76
24982 changed files with 2621219 additions and 413 deletions

15
spa/node_modules/json-stringify-nice/LICENSE generated vendored Normal file
View 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.

105
spa/node_modules/json-stringify-nice/README.md generated vendored Normal file
View File

@@ -0,0 +1,105 @@
# json-stringify-nice
Stringify an object sorting scalars before objects, and defaulting to
2-space indent.
Sometimes you want to stringify an object in a consistent way, and for
human legibility reasons, you may want to put any non-object properties
ahead of any object properties, so that it's easier to track the nesting
level as you read through the object, but you don't want to have to be
meticulous about maintaining object property order as you're building up
the object, since it doesn't matter in code, it only matters in the output
file. Also, it'd be nice to have it default to reasonable spacing without
having to remember to add `, null, 2)` to all your `JSON.stringify()`
calls.
If that is what you want, then this module is for you, because it does
all of that.
## USAGE
```js
const stringify = require('json-stringify-nice')
const obj = {
z: 1,
y: 'z',
obj: { a: {}, b: 'x' },
a: { b: 1, a: { nested: true} },
yy: 'a',
}
console.log(stringify(obj))
/* output:
{
"y": "z", <-- alphabetical sorting like whoa!
"yy": "a",
"z": 1,
"a": { <-- a sorted before obj, because alphabetical, and both objects
"b": 1,
"a": { <-- note that a comes after b, because it's an object
"nested": true
}
},
"obj": {
"b": "x",
"a": {}
}
}
*/
// specify an array of keys if you have some that you prefer
// to be sorted in a specific order. preferred keys come before
// any other keys, and in the order specified, but objects are
// still sorted AFTER scalars, so the preferences only apply
// when both values are objects or both are non-objects.
console.log(stringify(obj, ['z', 'yy', 'obj']))
/* output
{
"z": 1, <-- z comes before other scalars
"yy": "a", <-- yy comes after z, but before other scalars
"y": "z", <-- then all the other scalar values
"obj": { <-- obj comes before other objects, but after scalars
"b": "x",
"a": {}
},
"a": {
"b": 1,
"a": {
"nested": true
}
}
}
*/
// can also specify a replacer or indent value like with JSON.stringify
// this turns all values with an 'a' key into a doggo meme from 2011
const replacer = (key, val) =>
key === 'a' ? { hello: '📞 yes', 'this is': '🐕', ...val } : val
console.log(stringify(obj, replacer, '📞🐶'))
/* output:
{
📞🐶"y": "z",
📞🐶"yy": "a",
📞🐶"z": 1,
📞🐶"a": {
📞🐶📞🐶"b": 1,
📞🐶📞🐶"hello": "📞 yes",
📞🐶📞🐶"this is": "🐕",
📞🐶📞🐶"a": {
📞🐶📞🐶📞🐶"hello": "📞 yes",
📞🐶📞🐶📞🐶"nested": true,
📞🐶📞🐶📞🐶"this is": "🐕"
📞🐶📞🐶}
📞🐶},
📞🐶"obj": {
📞🐶📞🐶"b": "x",
📞🐶📞🐶"a": {
📞🐶📞🐶📞🐶"hello": "📞 yes",
📞🐶📞🐶📞🐶"this is": "🐕"
📞🐶📞🐶}
📞🐶}
}
*/
```

38
spa/node_modules/json-stringify-nice/index.js generated vendored Normal file
View 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
spa/node_modules/json-stringify-nice/package.json generated vendored Normal file
View 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"
]
}