mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-06 14:20:42 +02:00
modified
This commit is contained in:
-26
@@ -1,26 +0,0 @@
|
||||
extends: eslint:recommended
|
||||
env:
|
||||
node: true
|
||||
browser: true
|
||||
rules:
|
||||
block-scoped-var: 2
|
||||
callback-return: 2
|
||||
dot-notation: 2
|
||||
indent: 2
|
||||
linebreak-style: [2, unix]
|
||||
new-cap: 2
|
||||
no-console: [2, allow: [warn, error]]
|
||||
no-else-return: 2
|
||||
no-eq-null: 2
|
||||
no-fallthrough: 2
|
||||
no-invalid-this: 2
|
||||
no-return-assign: 2
|
||||
no-shadow: 1
|
||||
no-trailing-spaces: 2
|
||||
no-use-before-define: [2, nofunc]
|
||||
quotes: [2, single, avoid-escape]
|
||||
semi: [2, always]
|
||||
strict: [2, global]
|
||||
valid-jsdoc: [2, requireReturn: false]
|
||||
no-control-regex: 0
|
||||
no-useless-escape: 2
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8"
|
||||
- "10"
|
||||
- "12"
|
||||
- "13"
|
||||
after_script:
|
||||
- coveralls < coverage/lcov.info
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Copyright (c) 2017 Evgeny Poberezkin
|
||||
Copyright (c) 2013 James Halliday
|
||||
|
||||
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.
|
||||
-131
@@ -1,131 +0,0 @@
|
||||
# fast-json-stable-stringify
|
||||
|
||||
Deterministic `JSON.stringify()` - a faster version of [@substack](https://github.com/substack)'s json-stable-strigify without [jsonify](https://github.com/substack/jsonify).
|
||||
|
||||
You can also pass in a custom comparison function.
|
||||
|
||||
[](https://travis-ci.org/epoberezkin/fast-json-stable-stringify)
|
||||
[](https://coveralls.io/github/epoberezkin/fast-json-stable-stringify?branch=master)
|
||||
|
||||
# example
|
||||
|
||||
``` js
|
||||
var stringify = require('fast-json-stable-stringify');
|
||||
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
|
||||
console.log(stringify(obj));
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
{"a":3,"b":[{"x":4,"y":5,"z":6},7],"c":8}
|
||||
```
|
||||
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var stringify = require('fast-json-stable-stringify')
|
||||
```
|
||||
|
||||
## var str = stringify(obj, opts)
|
||||
|
||||
Return a deterministic stringified string `str` from the object `obj`.
|
||||
|
||||
|
||||
## options
|
||||
|
||||
### cmp
|
||||
|
||||
If `opts` is given, you can supply an `opts.cmp` to have a custom comparison
|
||||
function for object keys. Your function `opts.cmp` 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
|
||||
var stringify = require('fast-json-stable-stringify');
|
||||
|
||||
var obj = { c: 8, b: [{z:6,y:5,x:4},7], a: 3 };
|
||||
var s = stringify(obj, function (a, b) {
|
||||
return a.key < b.key ? 1 : -1;
|
||||
});
|
||||
console.log(s);
|
||||
```
|
||||
|
||||
which results in the output string:
|
||||
|
||||
```
|
||||
{"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:
|
||||
|
||||
```
|
||||
var stringify = require('fast-json-stable-stringify');
|
||||
|
||||
var obj = { d: 6, c: 5, b: [{z:3,y:2,x:1},9], a: 10 };
|
||||
var s = stringify(obj, function (a, b) {
|
||||
return a.value < b.value ? 1 : -1;
|
||||
});
|
||||
console.log(s);
|
||||
```
|
||||
|
||||
which outputs:
|
||||
|
||||
```
|
||||
{"d":6,"c":5,"b":[{"z":3,"y":2,"x":1},9],"a":10}
|
||||
```
|
||||
|
||||
### cycles
|
||||
|
||||
Pass `true` in `opts.cycles` to stringify circular property as `__cycle__` - the result will not be a valid JSON string in this case.
|
||||
|
||||
TypeError will be thrown in case of circular object without this option.
|
||||
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install fast-json-stable-stringify
|
||||
```
|
||||
|
||||
|
||||
# benchmark
|
||||
|
||||
To run benchmark (requires Node.js 6+):
|
||||
```
|
||||
node benchmark
|
||||
```
|
||||
|
||||
Results:
|
||||
```
|
||||
fast-json-stable-stringify x 17,189 ops/sec ±1.43% (83 runs sampled)
|
||||
json-stable-stringify x 13,634 ops/sec ±1.39% (85 runs sampled)
|
||||
fast-stable-stringify x 20,212 ops/sec ±1.20% (84 runs sampled)
|
||||
faster-stable-stringify x 15,549 ops/sec ±1.12% (84 runs sampled)
|
||||
The fastest is fast-stable-stringify
|
||||
```
|
||||
|
||||
|
||||
## Enterprise support
|
||||
|
||||
fast-json-stable-stringify package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-fast-json-stable-stringify?utm_source=npm-fast-json-stable-stringify&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.
|
||||
|
||||
|
||||
## Security contact
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.
|
||||
|
||||
|
||||
# license
|
||||
|
||||
[MIT](https://github.com/epoberezkin/fast-json-stable-stringify/blob/master/LICENSE)
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
declare module 'fast-json-stable-stringify' {
|
||||
function stringify(obj: any): string;
|
||||
export = stringify;
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (data, opts) {
|
||||
if (!opts) opts = {};
|
||||
if (typeof opts === 'function') opts = { cmp: opts };
|
||||
var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
|
||||
|
||||
var cmp = opts.cmp && (function (f) {
|
||||
return function (node) {
|
||||
return function (a, b) {
|
||||
var aobj = { key: a, value: node[a] };
|
||||
var bobj = { key: b, value: node[b] };
|
||||
return f(aobj, bobj);
|
||||
};
|
||||
};
|
||||
})(opts.cmp);
|
||||
|
||||
var seen = [];
|
||||
return (function stringify (node) {
|
||||
if (node && node.toJSON && typeof node.toJSON === 'function') {
|
||||
node = node.toJSON();
|
||||
}
|
||||
|
||||
if (node === undefined) return;
|
||||
if (typeof node == 'number') return isFinite(node) ? '' + node : 'null';
|
||||
if (typeof node !== 'object') return JSON.stringify(node);
|
||||
|
||||
var i, out;
|
||||
if (Array.isArray(node)) {
|
||||
out = '[';
|
||||
for (i = 0; i < node.length; i++) {
|
||||
if (i) out += ',';
|
||||
out += stringify(node[i]) || 'null';
|
||||
}
|
||||
return out + ']';
|
||||
}
|
||||
|
||||
if (node === null) return 'null';
|
||||
|
||||
if (seen.indexOf(node) !== -1) {
|
||||
if (cycles) return JSON.stringify('__cycle__');
|
||||
throw new TypeError('Converting circular structure to JSON');
|
||||
}
|
||||
|
||||
var seenIndex = seen.push(node) - 1;
|
||||
var keys = Object.keys(node).sort(cmp && cmp(node));
|
||||
out = '';
|
||||
for (i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var value = stringify(node[key]);
|
||||
|
||||
if (!value) continue;
|
||||
if (out) out += ',';
|
||||
out += JSON.stringify(key) + ':' + value;
|
||||
}
|
||||
seen.splice(seenIndex, 1);
|
||||
return '{' + out + '}';
|
||||
})(data);
|
||||
};
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
{
|
||||
"name": "fast-json-stable-stringify",
|
||||
"version": "2.1.0",
|
||||
"description": "deterministic `JSON.stringify()` - a faster version of substack's json-stable-strigify without jsonify",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"coveralls": "^3.0.0",
|
||||
"eslint": "^6.7.0",
|
||||
"fast-stable-stringify": "latest",
|
||||
"faster-stable-stringify": "latest",
|
||||
"json-stable-stringify": "latest",
|
||||
"nyc": "^14.1.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"tape": "^4.11.0"
|
||||
},
|
||||
"scripts": {
|
||||
"eslint": "eslint index.js test",
|
||||
"test-spec": "tape test/*.js",
|
||||
"test": "npm run eslint && nyc npm run test-spec"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/epoberezkin/fast-json-stable-stringify.git"
|
||||
},
|
||||
"homepage": "https://github.com/epoberezkin/fast-json-stable-stringify",
|
||||
"keywords": [
|
||||
"json",
|
||||
"stringify",
|
||||
"deterministic",
|
||||
"hash",
|
||||
"stable"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"license": "MIT",
|
||||
"nyc": {
|
||||
"exclude": [
|
||||
"test",
|
||||
"node_modules"
|
||||
],
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user