Initial commit

This commit is contained in:
2026-04-15 17:08:39 +02:00
parent ae164c47a8
commit 47fd1c2b7a
1819 changed files with 685388 additions and 0 deletions

21
node_modules/json-stringify-pretty-compact/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014, 2016, 2017, 2019, 2021, 2022 Simon Lydell
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

57
node_modules/json-stringify-pretty-compact/README.md generated vendored Normal file
View File

@@ -0,0 +1,57 @@
# json-stringify-pretty-compact
The output of [JSON.stringify] comes in two flavors: _compact_ and _pretty._ The former is usually too compact to be read by humans, while the latter sometimes is too spacious. This module trades performance for a compromise between the two. The result is a _pretty_ compact string, where “pretty” means both “kind of” and “nice”.
<!-- prettier-ignore -->
```json
{
"bool": true,
"short array": [1, 2, 3],
"long array": [
{"x": 1, "y": 2},
{"x": 2, "y": 1},
{"x": 1, "y": 1},
{"x": 2, "y": 2}
]
}
```
While the “pretty” mode of [JSON.stringify] puts every item of arrays and objects on its own line, this module puts the whole array or object on a single line, unless the line becomes too long (the default maximum is 80 characters). Making arrays and objects multi-line is the only attempt made to enforce the maximum line length; if that doesnt help then so be it.
## Installation
```
npm install json-stringify-pretty-compact
```
```js
import stringify from "json-stringify-pretty-compact";
```
> **Note:** This is an [ESM only package]. (I havent written that gist, but its a great resource.)
>
> If you need CommonJS, install version 3.0.0. You wont be missing out on anything: This package is _done._ No more features will be added, and no bugs have been found in years.
## `stringify(obj, options = {})`
Its like `JSON.stringify(obj, options.replacer, options.indent)`, except that objects and arrays are on one line if they fit (according to `options.maxLength`).
`options`:
- indent: Defaults to 2. Works exactly like the third parameter of [JSON.stringify].
- maxLength: Defaults to 80. Lines will be tried to be kept at maximum this many characters long.
- replacer: Defaults to undefined. Works exactly like the second parameter of [JSON.stringify].
`stringify(obj, {maxLength: 0, indent: indent})` gives the exact same result as `JSON.stringify(obj, null, indent)`. (However, if you use a `replacer`, integer keys might be moved first.)
`stringify(obj, {maxLength: Infinity})` gives the exact same result as `JSON.stringify(obj)`, except that there are spaces after colons and commas.
**Want more options?** Check out [@aitodotai/json-stringify-pretty-compact]!
## License
[MIT](LICENSE).
[@aitodotai/json-stringify-pretty-compact]: https://www.npmjs.com/package/@aitodotai/json-stringify-pretty-compact
[json.stringify]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
[esm only package]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

12
node_modules/json-stringify-pretty-compact/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
declare module "json-stringify-pretty-compact" {
export default function stringify(
value: any,
options?: {
indent?: number | string;
maxLength?: number;
replacer?:
| ((this: any, key: string, value: any) => any)
| (number | string)[];
}
): string;
}

98
node_modules/json-stringify-pretty-compact/index.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
// Note: This regex matches even invalid JSON strings, but since were
// working on the output of `JSON.stringify` we know that only valid strings
// are present (unless the user supplied a weird `options.indent` but in
// that case we dont care since the output would be invalid anyway).
const stringOrChar = /("(?:[^\\"]|\\.)*")|[:,]/g;
export default function stringify(passedObj, options = {}) {
const indent = JSON.stringify(
[1],
undefined,
options.indent === undefined ? 2 : options.indent
).slice(2, -3);
const maxLength =
indent === ""
? Infinity
: options.maxLength === undefined
? 80
: options.maxLength;
let { replacer } = options;
return (function _stringify(obj, currentIndent, reserved) {
if (obj && typeof obj.toJSON === "function") {
obj = obj.toJSON();
}
const string = JSON.stringify(obj, replacer);
if (string === undefined) {
return string;
}
const length = maxLength - currentIndent.length - reserved;
if (string.length <= length) {
const prettified = string.replace(
stringOrChar,
(match, stringLiteral) => {
return stringLiteral || `${match} `;
}
);
if (prettified.length <= length) {
return prettified;
}
}
if (replacer != null) {
obj = JSON.parse(string);
replacer = undefined;
}
if (typeof obj === "object" && obj !== null) {
const nextIndent = currentIndent + indent;
const items = [];
let index = 0;
let start;
let end;
if (Array.isArray(obj)) {
start = "[";
end = "]";
const { length } = obj;
for (; index < length; index++) {
items.push(
_stringify(obj[index], nextIndent, index === length - 1 ? 0 : 1) ||
"null"
);
}
} else {
start = "{";
end = "}";
const keys = Object.keys(obj);
const { length } = keys;
for (; index < length; index++) {
const key = keys[index];
const keyPart = `${JSON.stringify(key)}: `;
const value = _stringify(
obj[key],
nextIndent,
keyPart.length + (index === length - 1 ? 0 : 1)
);
if (value !== undefined) {
items.push(keyPart + value);
}
}
}
if (items.length > 0) {
return [start, indent + items.join(`,\n${nextIndent}`), end].join(
`\n${currentIndent}`
);
}
}
return string;
})(passedObj, "", 0);
}

View File

@@ -0,0 +1,34 @@
{
"name": "json-stringify-pretty-compact",
"version": "4.0.0",
"author": "Simon Lydell",
"license": "MIT",
"description": "The best of both `JSON.stringify(obj)` and `JSON.stringify(obj, null, indent)`.",
"type": "module",
"exports": "./index.js",
"types": "index.d.ts",
"repository": "lydell/json-stringify-pretty-compact",
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"JSON",
"stringify",
"pretty",
"print",
"pretty-print",
"compact",
"indent",
"format",
"formatter"
],
"scripts": {
"test": "eslint . --report-unused-disable-directives && prettier --check . && node --test",
"prepublishOnly": "npm test"
},
"devDependencies": {
"eslint": "8.15.0",
"prettier": "2.6.2"
}
}