This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+44
View File
@@ -0,0 +1,44 @@
'use strict';
var isPlainObj = require('is-plain-obj');
module.exports = function (obj, opts) {
if (!isPlainObj(obj)) {
throw new TypeError('Expected a plain object');
}
opts = opts || {};
// DEPRECATED
if (typeof opts === 'function') {
opts = {compare: opts};
}
var deep = opts.deep;
var seenInput = [];
var seenOutput = [];
var sortKeys = function (x) {
var seenIndex = seenInput.indexOf(x);
if (seenIndex !== -1) {
return seenOutput[seenIndex];
}
var ret = {};
var keys = Object.keys(x).sort(opts.compare);
seenInput.push(x);
seenOutput.push(ret);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var val = x[key];
ret[key] = deep && isPlainObj(val) ? sortKeys(val) : val;
}
return ret;
};
return sortKeys(obj);
};
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.
+7
View File
@@ -0,0 +1,7 @@
'use strict';
var toString = Object.prototype.toString;
module.exports = function (x) {
var prototype;
return toString.call(x) === '[object Object]' && (prototype = Object.getPrototypeOf(x), prototype === null || prototype === Object.getPrototypeOf({}));
};
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
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.
+71
View File
@@ -0,0 +1,71 @@
{
"_args": [
[
"is-plain-obj@1.1.0",
"/home/node/nuxt"
]
],
"_from": "is-plain-obj@1.1.0",
"_id": "is-plain-obj@1.1.0",
"_inBundle": false,
"_integrity": "sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg==",
"_location": "/sort-keys/is-plain-obj",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "is-plain-obj@1.1.0",
"name": "is-plain-obj",
"escapedName": "is-plain-obj",
"rawSpec": "1.1.0",
"saveSpec": null,
"fetchSpec": "1.1.0"
},
"_requiredBy": [
"/sort-keys"
],
"_resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
"_spec": "1.1.0",
"_where": "/home/node/nuxt",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/is-plain-obj/issues"
},
"description": "Check if a value is a plain object",
"devDependencies": {
"ava": "0.0.4"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/is-plain-obj#readme",
"keywords": [
"obj",
"object",
"is",
"check",
"test",
"type",
"plain",
"vanilla",
"pure",
"simple"
],
"license": "MIT",
"name": "is-plain-obj",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/is-plain-obj.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.1.0"
}
+35
View File
@@ -0,0 +1,35 @@
# is-plain-obj [![Build Status](https://travis-ci.org/sindresorhus/is-plain-obj.svg?branch=master)](https://travis-ci.org/sindresorhus/is-plain-obj)
> Check if a value is a plain object
An object is plain if it's created by either `{}`, `new Object()` or `Object.create(null)`.
## Install
```
$ npm install --save is-plain-obj
```
## Usage
```js
var isPlainObj = require('is-plain-obj');
isPlainObj({foo: 'bar'});
//=> true
isPlainObj([1, 2, 3]);
//=> false
```
## Related
- [is-obj](https://github.com/sindresorhus/is-obj) - Check if a value is an object
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
+75
View File
@@ -0,0 +1,75 @@
{
"_args": [
[
"sort-keys@1.1.2",
"/home/node/nuxt"
]
],
"_from": "sort-keys@1.1.2",
"_id": "sort-keys@1.1.2",
"_inBundle": false,
"_integrity": "sha512-vzn8aSqKgytVik0iwdBEi+zevbTYZogewTUM6dtpmGwEcdzbub/TX4bCzRhebDCRC3QzXgJsLRKB2V/Oof7HXg==",
"_location": "/sort-keys",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "sort-keys@1.1.2",
"name": "sort-keys",
"escapedName": "sort-keys",
"rawSpec": "1.1.2",
"saveSpec": null,
"fetchSpec": "1.1.2"
},
"_requiredBy": [
"/normalize-url"
],
"_resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz",
"_spec": "1.1.2",
"_where": "/home/node/nuxt",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/sort-keys/issues"
},
"dependencies": {
"is-plain-obj": "^1.0.0"
},
"description": "Sort the keys of an object",
"devDependencies": {
"mocha": "*",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/sort-keys#readme",
"keywords": [
"sort",
"object",
"keys",
"obj",
"key",
"stable",
"deterministic",
"deep",
"recursive",
"recursively"
],
"license": "MIT",
"name": "sort-keys",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/sort-keys.git"
},
"scripts": {
"test": "xo && mocha"
},
"version": "1.1.2"
}
+60
View File
@@ -0,0 +1,60 @@
# sort-keys [![Build Status](https://travis-ci.org/sindresorhus/sort-keys.svg?branch=master)](https://travis-ci.org/sindresorhus/sort-keys)
> Sort the keys of an object
Useful to get a deterministically ordered object, as the order of keys can vary between engines.
## Install
```
$ npm install --save sort-keys
```
## Usage
```js
const sortKeys = require('sort-keys');
sortKeys({c: 0, a: 0, b: 0});
//=> {a: 0, b: 0, c: 0}
sortKeys({b: {b: 0, a: 0}, a: 0}, {deep: true});
//=> {a: 0, b: {a: 0, b: 0}}
sortKeys({c: 0, a: 0, b: 0}, {
compare: (a, b) => -a.localeCompare(b)
});
//=> {c: 0, b: 0, a: 0}
```
## API
### sortKeys(input, [options])
Returns a new object with sorted keys.
#### input
Type: `Object`
#### options
##### deep
Type: `boolean`
Recursively sort keys.
##### compare
Type: `Function`
[Compare function.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)