Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sortobject

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sortobject - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0-next.1589186842.e2c82e3c11ebff2fd9d3ca975a3ace1954cecefe

68

edition-browsers/index.js

@@ -8,18 +8,17 @@ /**

export function sortArray(subject, comparator) {
const result = [];
for (let value of subject) {
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator);
}
else if (typeof value === 'object') {
/* eslint no-use-before-define:0 */
value = sortObject(value, comparator);
}
}
// Push
result.push(value);
}
return result;
const result = []
for (let value of subject) {
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator)
} else if (typeof value === 'object') {
/* eslint no-use-before-define:0 */
value = sortObject(value, comparator)
}
}
// Push
result.push(value)
}
return result
}

@@ -33,21 +32,20 @@ /**

export default function sortObject(subject, comparator) {
const result = {};
const sortedKeys = Object.keys(subject).sort(comparator);
for (let i = 0; i < sortedKeys.length; ++i) {
// Fetch
const key = sortedKeys[i];
let value = subject[key];
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator);
}
else if (typeof value === 'object') {
value = sortObject(value, comparator);
}
}
// Push
result[key] = value;
}
return result;
const result = {}
const sortedKeys = Object.keys(subject).sort(comparator)
for (let i = 0; i < sortedKeys.length; ++i) {
// Fetch
const key = sortedKeys[i]
let value = subject[key]
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator)
} else if (typeof value === 'object') {
value = sortObject(value, comparator)
}
}
// Push
result[key] = value
}
return result
}

@@ -1,3 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
'use strict'
Object.defineProperty(exports, '__esModule', { value: true })
/**

@@ -10,20 +10,19 @@ * Returns a copy of the passed array, with all nested objects within it sorted deeply by their keys, without mangling any nested arrays.

function sortArray(subject, comparator) {
const result = [];
for (let value of subject) {
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator);
}
else if (typeof value === 'object') {
/* eslint no-use-before-define:0 */
value = sortObject(value, comparator);
}
}
// Push
result.push(value);
}
return result;
const result = []
for (let value of subject) {
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator)
} else if (typeof value === 'object') {
/* eslint no-use-before-define:0 */
value = sortObject(value, comparator)
}
}
// Push
result.push(value)
}
return result
}
exports.sortArray = sortArray;
exports.sortArray = sortArray
/**

@@ -36,22 +35,21 @@ * Returns a copy of the passed object, with all nested objects within it sorted deeply by their keys, without mangling any nested arrays inside of it.

function sortObject(subject, comparator) {
const result = {};
const sortedKeys = Object.keys(subject).sort(comparator);
for (let i = 0; i < sortedKeys.length; ++i) {
// Fetch
const key = sortedKeys[i];
let value = subject[key];
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator);
}
else if (typeof value === 'object') {
value = sortObject(value, comparator);
}
}
// Push
result[key] = value;
}
return result;
const result = {}
const sortedKeys = Object.keys(subject).sort(comparator)
for (let i = 0; i < sortedKeys.length; ++i) {
// Fetch
const key = sortedKeys[i]
let value = subject[key]
// Recurse if object or array
if (value != null) {
if (Array.isArray(value)) {
value = sortArray(value, comparator)
} else if (typeof value === 'object') {
value = sortObject(value, comparator)
}
}
// Push
result[key] = value
}
return result
}
exports.default = sortObject;
exports.default = sortObject
# History
## v4.0.0 2020 May 11
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation)
- Minimum required node version changed from `node: >=6` to `node: >=10` to keep up with mandatory ecosystem changes
## v3.0.0 2019 December 18

@@ -4,0 +9,0 @@

{
"title": "Sort Object",
"name": "sortobject",
"version": "3.0.0",
"version": "4.0.0-next.1589186842.e2c82e3c11ebff2fd9d3ca975a3ace1954cecefe",
"description": "Returns a copy of an object, sorted deeply by its keys, without mangling any arrays inside of it",

@@ -17,2 +17,3 @@ "homepage": "https://github.com/bevry/sortobject",

"module",
"node",
"object",

@@ -52,3 +53,7 @@ "sort",

"wishlistURL": "https://bevry.me/wishlist",
"travisTLD": "com"
"travisTLD": "com",
"githubUsername": "bevry",
"githubRepository": "sortobject",
"githubSlug": "bevry/sortobject",
"npmPackageName": "sortobject"
}

@@ -62,9 +67,9 @@ },

"maintainers": [
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)"
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)"
],
"contributors": [
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"Serge Havas <sinewyk@gmail.com> (sinewyk.com)",
"Benjamin Lupton <b@lupton.cc> (https://github.com/balupton)",
"James Newell (http://jameslnewell.me/)",
"James Newell (http://jameslnewell.dev/)"
"James Newell (https://github.com/jameslnewell)",
"Serge Havas <sinewyk@gmail.com> (https://github.com/Sinewyk)"
],

@@ -79,3 +84,3 @@ "bugs": {

"engines": {
"node": ">=6"
"node": ">=10"
},

@@ -94,26 +99,26 @@ "editions": [

{
"description": "TypeScript compiled against ESNext for web browsers with Import for modules",
"directory": "edition-browsers",
"description": "TypeScript compiled against ESNext for Node.js with Require for modules",
"directory": "edition-esnext",
"entry": "index.js",
"tags": [
"javascript",
"import"
"esnext",
"require"
],
"engines": {
"node": false,
"browsers": "defaults"
"node": "10 || 12 || 13 || 14",
"browsers": false
}
},
{
"description": "TypeScript compiled against ESNext for Node.js with Require for modules",
"directory": "edition-esnext",
"description": "TypeScript compiled against ES2019 for web browsers with Import for modules",
"directory": "edition-browsers",
"entry": "index.js",
"tags": [
"javascript",
"esnext",
"require"
"import"
],
"engines": {
"node": "6 || 8 || 10 || 12 || 13",
"browsers": false
"node": false,
"browsers": "defaults"
}

@@ -128,16 +133,17 @@ }

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.12.0",
"@typescript-eslint/parser": "^2.12.0",
"assert-helpers": "4.10.0",
"eslint": "^6.7.2",
"eslint-config-bevry": "^2.3.0",
"eslint-config-prettier": "^6.7.0",
"@bevry/update-contributors": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^2.31.0",
"@typescript-eslint/parser": "^2.31.0",
"assert-helpers": "^6.2.0",
"eslint": "^7.0.0",
"eslint-config-bevry": "^3.4.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-prettier": "^3.1.2",
"kava": "3.2.0",
"prettier": "^1.19.1",
"projectz": "^1.19.0",
"eslint-plugin-prettier": "^3.1.3",
"kava": "^5.0.0",
"prettier": "^2.0.5",
"projectz": "^2.1.0",
"surge": "^0.21.3",
"typedoc": "^0.15.5",
"typescript": "^3.7.3",
"typedoc": "^0.17.6",
"typescript": "^3.8.3",
"valid-directory": "^1.6.0",

@@ -149,9 +155,10 @@ "valid-module": "^1.0.0"

"our:compile": "npm run our:compile:edition-browsers && npm run our:compile:edition-esnext",
"our:compile:edition-browsers": "tsc --module ESNext --target ESNext --outDir ./edition-browsers --project tsconfig.json && test -d edition-browsers/source && ( mv edition-browsers/source edition-temp && rm -Rf edition-browsers && mv edition-temp edition-browsers ) || true",
"our:compile:edition-browsers": "tsc --module ESNext --target ES2019 --outDir ./edition-browsers --project tsconfig.json && test -d edition-browsers/source && ( mv edition-browsers/source edition-temp && rm -Rf edition-browsers && mv edition-temp edition-browsers ) || true",
"our:compile:edition-esnext": "tsc --module commonjs --target ESNext --outDir ./edition-esnext --project tsconfig.json && test -d edition-esnext/source && ( mv edition-esnext/source edition-temp && rm -Rf edition-esnext && mv edition-temp edition-esnext ) || true",
"our:deploy": "echo no need for this project",
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz",
"our:meta": "npm run our:meta:contributors && npm run our:meta:docs && npm run our:meta:projectz",
"our:meta:contributors": "npx @bevry/update-contributors",
"our:meta:docs": "npm run our:meta:docs:typedoc",
"our:meta:docs:typedoc": "rm -Rf ./docs && typedoc --mode file --exclude '**/+(*test*|node_modules)' --excludeExternals --name \"$npm_package_name\" --readme ./README.md --out ./docs ./source",
"our:meta:projectz": "projectz compile",
"our:meta:docs:typedoc": "rm -Rf ./docs && npx typedoc --mode file --exclude '**/+(*test*|node_modules)' --excludeExternals --name \"$npm_package_name\" --readme ./README.md --out ./docs ./source",
"our:meta:projectz": "npx projectz compile",
"our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push",

@@ -167,7 +174,7 @@ "our:release:check-changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)",

"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:module && npm run our:verify:prettier && npm run our:verify:typescript",
"our:verify:directory": "valid-directory",
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source",
"our:verify:module": "valid-module",
"our:verify:prettier": "prettier --write ./source/**",
"our:verify:typescript": "tsc --noEmit --project tsconfig.json",
"our:verify:directory": "npx valid-directory",
"our:verify:eslint": "npx eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source",
"our:verify:module": "npx valid-module",
"our:verify:prettier": "npx prettier --write .",
"our:verify:typescript": "npx tsc --noEmit --project tsconfig.json",
"test": "node ./edition-esnext/test.js"

@@ -183,7 +190,3 @@ },

"singleQuote": true
},
"boundation": {
"minimumSupportNodeVersion": "5",
"minimumTestNodeVersion": "5"
}
}

@@ -38,2 +38,4 @@ <!-- TITLE/ -->

[Complete API Documentation.](http://master.sortobject.bevry.surge.sh/docs/globals.html)
```javascript

@@ -49,3 +51,3 @@ import sortObject from 'sortobject'

a: true,
b: null
b: null,
},

@@ -60,7 +62,7 @@ {

a: true,
b: null
}
]
}
]
b: null,
},
],
},
],
}

@@ -94,20 +96,2 @@ const actual = sortObject(fixture)

[Complete API Documentation.](http://master.sortobject.bevry.surge.sh/docs/)
<!-- INSTALL/ -->

@@ -128,3 +112,3 @@

<script type="module">
import pkg from '//cdn.pika.dev/sortobject/^3.0.0'
import pkg from '//cdn.pika.dev/sortobject/^4.0.0'
</script>

@@ -137,3 +121,3 @@ ```

<script type="module">
import pkg from '//unpkg.com/sortobject@^3.0.0'
import pkg from '//unpkg.com/sortobject@^4.0.0'
</script>

@@ -146,3 +130,3 @@ ```

<script type="module">
import pkg from '//dev.jspm.io/sortobject@3.0.0'
import pkg from '//dev.jspm.io/sortobject@4.0.0'
</script>

@@ -156,5 +140,5 @@ ```

<ul><li><code>sortobject/source/index.ts</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> source code with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>sortobject/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li>
<li><code>sortobject</code> aliases <code>sortobject/edition-esnext/index.js</code></li>
<li><code>sortobject/edition-esnext/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li></ul>
<li><code>sortobject/edition-esnext/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#ES.Next" title="ECMAScript Next">ESNext</a> for <a href="https://nodejs.org" title="Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine">Node.js</a> with <a href="https://nodejs.org/dist/latest-v5.x/docs/api/modules.html" title="Node/CJS Modules">Require</a> for modules</li>
<li><code>sortobject/edition-browsers/index.js</code> is <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a> compiled against <a href="https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_-_ECMAScript_2019" title="ECMAScript ES2019">ES2019</a> for web browsers with <a href="https://babeljs.io/docs/learn-es2015/#modules" title="ECMAScript Modules">Import</a> for modules</li></ul>

@@ -190,3 +174,3 @@ <!-- /INSTALL -->

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/sortobject/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/sortobject">view contributions</a></li></ul>
<ul><li><a href="https://github.com/balupton">Benjamin Lupton</a> — <a href="https://github.com/bevry/sortobject/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/sortobject">view contributions</a></li></ul>

@@ -197,3 +181,3 @@ <h3>Sponsors</h3>

<ul><li><a href="http://www.govests.com.au">GoVests</a></li></ul>
<ul><li><a href="https://www.govests.com.au">GoVests</a></li></ul>

@@ -216,7 +200,6 @@ Become a sponsor!

<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/sortobject/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/sortobject">view contributions</a></li>
<li><a href="sinewyk.com">Serge Havas</a> — <a href="https://github.com/bevry/sortobject/commits?author=Sinewyk" title="View the GitHub contributions of Serge Havas on repository bevry/sortobject">view contributions</a></li>
<ul><li><a href="https://github.com/balupton">Benjamin Lupton</a> — <a href="https://github.com/bevry/sortobject/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/sortobject">view contributions</a></li>
<li><a href="http://jameslnewell.me/">James Newell</a></li>
<li><a href="http://jameslnewell.dev/">James Newell</a> — <a href="https://github.com/bevry/sortobject/commits?author=jameslnewell" title="View the GitHub contributions of James Newell on repository bevry/sortobject">view contributions</a></li>
<li><a href="http://github.com/apps/dependabot-preview">dependabot-preview[bot]</a> — <a href="https://github.com/bevry/sortobject/commits?author=dependabot-preview[bot]" title="View the GitHub contributions of dependabot-preview[bot] on repository bevry/sortobject">view contributions</a></li></ul>
<li><a href="https://github.com/jameslnewell">James Newell</a> — <a href="https://github.com/bevry/sortobject/commits?author=jameslnewell" title="View the GitHub contributions of James Newell on repository bevry/sortobject">view contributions</a></li>
<li><a href="https://github.com/Sinewyk">Serge Havas</a> — <a href="https://github.com/bevry/sortobject/commits?author=Sinewyk" title="View the GitHub contributions of Serge Havas on repository bevry/sortobject">view contributions</a></li></ul>

@@ -223,0 +206,0 @@ <a href="https://github.com/bevry/sortobject/blob/master/CONTRIBUTING.md#files">Discover how you can contribute by heading on over to the <code>CONTRIBUTING.md</code> file.</a>

@@ -7,9 +7,8 @@ {

"maxNodeModuleJsDepth": 5,
"moduleResolution": "node",
"moduleResolution": "Node",
"strict": true,
"target": "esnext"
"target": "ESNext",
"lib": []
},
"include": [
"source"
]
"include": ["source"]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc