Saving all progress

This commit is contained in:
Luke Hagar
2025-03-19 22:47:50 -05:00
parent 5c6e8a1e4f
commit 00593b402b
14988 changed files with 2598505 additions and 1 deletions

21
node_modules/json-stringify-deterministic/LICENSE.md generated vendored Executable file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright © 2016 Kiko Beats <josefrancisco.verdu@gmail.com> (https://github.com/Kikobeats)
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.

143
node_modules/json-stringify-deterministic/README.md generated vendored Normal file
View File

@@ -0,0 +1,143 @@
# json-stringify-deterministic
![Last version](https://img.shields.io/github/tag/Kikobeats/json-stringify-deterministic.svg?style=flat-square)
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/json-stringify-deterministic.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/json-stringify-deterministic)
[![NPM Status](https://img.shields.io/npm/dm/json-stringify-deterministic.svg?style=flat-square)](https://www.npmjs.org/package/json-stringify-deterministic)
> Deterministic version of `JSON.stringify()`, so you can get a consistent hash from stringified results.
Similar to [json-stable-stringify](https://github.com/substack/json-stable-stringify) *but*:
- No Dependencies. Minimal as possible.
- Better cycles detection.
- Support serialization for object without `.toJSON` (such as `RegExp`).
- Provides built-in TypeScript declarations.
## Install
```bash
npm install json-stringify-deterministic --save
```
## Usage
```js
const stringify = require('json-stringify-deterministic')
const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 }
console.log(stringify(obj))
// => {"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}
```
## API
### stringify(&lt;obj&gt;, [opts])
#### obj
*Required*<br>
Type: `object`
The input `object` to be serialized.
#### opts
##### opts.stringify
Type: `function`
Default: `JSON.stringify`
Determinate how to stringify primitives values.
##### opts.cycles
Type: `boolean`
Default: `false`
Determinate how to resolve cycles.
Under `true`, when a cycle is detected, `[Circular]` will be inserted in the node.
##### opts.compare
Type: `function`
Custom comparison function for object keys.
Your function `opts.compare` is called with these parameters:
``` js
opts.cmp({ key: akey, value: avalue }, { key: bkey, value: bvalue })
```
For example, to sort on the object key names in reverse order you could write:
``` js
const stringify = require('json-stringify-deterministic')
const obj = { c: 8, b: [{z: 6,y: 5,x: 4}, 7], a: 3 }
const objSerializer = stringify(obj, function (a, b) {
return a.key < b.key ? 1 : -1
})
console.log(objSerializer)
// => {"c":8,"b":[{"z":6,"y":5,"x":4},7],"a":3}
```
Or if you wanted to sort on the object values in reverse order, you could write:
```js
const stringify = require('json-stringify-deterministic')
const obj = { d: 6, c: 5, b: [{ z: 3, y: 2, x: 1 }, 9], a: 10 }
const objtSerializer = stringify(obj, function (a, b) {
return a.value < b.value ? 1 : -1
})
console.log(objtSerializer)
// => {"d":6,"c":5,"b":[{"z":3,"y":2,"x":1},9],"a":10}
```
##### opts.space
Type: `string`<br>
Default: `''`
If you specify `opts.space`, it will indent the output for pretty-printing.
Valid values are strings (e.g. `{space: \t}`). For example:
```js
const stringify = require('json-stringify-deterministic')
const obj = { b: 1, a: { foo: 'bar', and: [1, 2, 3] } }
const objSerializer = stringify(obj, { space: ' ' })
console.log(objSerializer)
// => {
// "a": {
// "and": [
// 1,
// 2,
// 3
// ],
// "foo": "bar"
// },
// "b": 1
// }
```
##### opts.replacer
Type: `function`<br>
The replacer parameter is a function `opts.replacer(key, value)` that behaves
the same as the replacer
[from the core JSON object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_native_JSON#The_replacer_parameter).
## Related
- [sort-keys-recursive](https://github.com/Kikobeats/sort-keys-recursive): Sort the keys of an array/object recursively.
## License
MIT © [Kiko Beats](https://github.com/Kikobeats).

View File

@@ -0,0 +1,6 @@
module.exports = {
space: '',
cycles: false,
replacer: (k, v) => v,
stringify: JSON.stringify
}

View File

@@ -0,0 +1,46 @@
interface Options {
/**
* Determinate how to stringify primitives values.
* @default JSON.stringify
*/
stringify?: typeof JSON["stringify"];
/**
* Determinate how to resolve cycles.
* Under true, when a cycle is detected, [Circular] will be inserted in the node.
* @default false
*/
cycles?: boolean;
/**
* Custom comparison function for object keys.
* @param a first key-value pair.
* @param b second key-value pair.
* @returns a number whose sign indicates the relative order of the two elements.
*/
compare?: (a: KeyValue, b: KeyValue) => number;
/**
* Indent the output for pretty-printing.
*/
space?: string;
/**
* Replacer function that behaves the same as the replacer from the core JSON object.
*/
replacer?: (key: string, value: unknown) => unknown;
}
interface KeyValue {
key: string;
value: unknown;
}
/**
* Deterministic version of JSON.stringify(), so you can get a consistent hash from stringified results.
* @param obj The input object to be serialized.
* @param opts options.
*/
declare function stringify(obj: unknown, opts?: Options): string;
export = stringify;

87
node_modules/json-stringify-deterministic/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,87 @@
'use strict'
const DEFAULTS = require('./defaults')
const isFunction = require('./util').isFunction
const isBoolean = require('./util').isBoolean
const isObject = require('./util').isObject
const isArray = require('./util').isArray
const isRegex = require('./util').isRegex
const assign = require('./util').assign
const keys = require('./util').keys
function serialize (obj) {
if (obj === null || obj === undefined) return obj
if (isRegex(obj)) return obj.toString()
return obj.toJSON ? obj.toJSON() : obj
}
function stringifyDeterministic (obj, opts) {
opts = opts || assign({}, DEFAULTS)
if (isFunction(opts)) opts = { compare: opts }
const space = opts.space || DEFAULTS.space
const cycles = isBoolean(opts.cycles) ? opts.cycles : DEFAULTS.cycles
const replacer = opts.replacer || DEFAULTS.replacer
const stringify = opts.stringify || DEFAULTS.stringify
const compare = opts.compare && (function (f) {
return function (node) {
return function (a, b) {
const aobj = { key: a, value: node[a] }
const bobj = { key: b, value: node[b] }
return f(aobj, bobj)
}
}
})(opts.compare)
// Detect circular structure in obj and raise error efficiently.
if (!cycles) stringify(obj)
const seen = []
return (function _deterministic (parent, key, node, level) {
const indent = space ? ('\n' + new Array(level + 1).join(space)) : ''
const colonSeparator = space ? ': ' : ':'
node = serialize(node)
node = replacer.call(parent, key, node)
if (node === undefined) return
if (!isObject(node) || node === null) return stringify(node)
if (isArray(node)) {
const out = []
for (let i = 0; i < node.length; i++) {
const item = _deterministic(node, i, node[i], level + 1) || stringify(null)
out.push(indent + space + item)
}
return '[' + out.join(',') + indent + ']'
} else {
if (cycles) {
if (seen.indexOf(node) !== -1) {
return stringify('[Circular]')
} else {
seen.push(node)
}
}
const nodeKeys = keys(node).sort(compare && compare(node))
const out = []
for (let i = 0; i < nodeKeys.length; i++) {
const key = nodeKeys[i]
const value = _deterministic(node, key, node[key], level + 1)
if (!value) continue
const keyValue = stringify(key) + colonSeparator + value
out.push(indent + space + keyValue)
}
seen.splice(seen.indexOf(node), 1)
return '{' + out.join(',') + indent + '}'
}
})({ '': obj }, '', obj, 0)
}
module.exports = stringifyDeterministic

11
node_modules/json-stringify-deterministic/lib/util.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict'
module.exports = {
isArray: Array.isArray,
assign: Object.assign,
isObject: v => typeof v === 'object',
isFunction: v => typeof v === 'function',
isBoolean: v => typeof v === 'boolean',
isRegex: v => v instanceof RegExp,
keys: Object.keys
}

101
node_modules/json-stringify-deterministic/package.json generated vendored Normal file
View File

@@ -0,0 +1,101 @@
{
"name": "json-stringify-deterministic",
"description": "deterministic version of JSON.stringify() so you can get a consistent hash from stringified results.",
"homepage": "https://github.com/Kikobeats/json-stringify-deterministic",
"version": "1.0.12",
"types": "./lib/index.d.ts",
"main": "lib",
"author": {
"email": "josefrancisco.verdu@gmail.com",
"name": "Kiko Beats",
"url": "https://github.com/Kikobeats"
},
"contributors": [
{
"name": "Junxiao Shi",
"email": "sunnylandh@gmail.com"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/kikobeats/json-stringify-deterministic.git"
},
"bugs": {
"url": "https://github.com/Kikobeats/json-stringify-deterministic/issues"
},
"keywords": [
"deterministic",
"hash",
"json",
"sort",
"stable",
"stringify"
],
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@ksmithut/prettier-standard": "latest",
"c8": "latest",
"ci-publish": "latest",
"conventional-github-releaser": "latest",
"finepack": "latest",
"git-authors-cli": "latest",
"mocha": "latest",
"nano-staged": "latest",
"npm-check-updates": "latest",
"should": "latest",
"simple-git-hooks": "latest",
"standard": "latest",
"standard-markdown": "latest",
"standard-version": "latest"
},
"engines": {
"node": ">= 4"
},
"files": [
"index.js",
"lib"
],
"scripts": {
"clean": "rm -rf node_modules",
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
"coveralls": "nyc report --reporter=text-lcov | coveralls",
"lint": "standard && standard-markdown",
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
"prerelease": "npm run update:check && npm run contributors",
"pretest": "npm run lint",
"release": "standard-version -a",
"release:github": "conventional-github-releaser -p angular",
"release:tags": "git push --follow-tags origin HEAD:master",
"test": "c8 mocha --require should",
"update": "ncu -u",
"update:check": "ncu -- --error-level 2"
},
"license": "MIT",
"commitlint": {
"extends": [
"@commitlint/config-conventional"
]
},
"nano-staged": {
"*.js": [
"prettier-standard"
],
"*.md": [
"standard-markdown"
],
"package.json": [
"finepack"
]
},
"simple-git-hooks": {
"commit-msg": "npx commitlint --edit",
"pre-commit": "npx nano-staged"
},
"standard": {
"globals": [
"describe",
"it"
]
}
}