4.0.0 • Published 10 months ago

sort-keys v4.0.0

Weekly downloads
9,323,117
License
MIT
Repository
github
Last release
10 months ago

sort-keys Build Status

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 sort-keys

Usage

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({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(object, options?)

Returns a new object with sorted keys.

object

Type: object

options

Type: object

deep

Type: boolean Default: false

Recursively sort keys, including keys of objects inside arrays.

compare

Type: Function

Compare function.


write-json-filesort-keys-length@yannick243/rw-json-filecanonical-urljsn_web2verify-javascript-sdkts-to-jsontravis-watchtweeter-clientxys_cliy-workflowwp-salts-cliwrite-json5-filewrite-pkgwrite-pkg-2yjy-rev@os33/gulp-rev@pnpm/read-importer-manifest@pnpm/read-project-manifestYworkcliappcd-pluginanything-config-fiskerxfx-gulp-rev@hvent/gulp-rev@insynergie/create@ronas-it/angular-schematics@kartotherian/assert-http@nextbook/extract-react-intl-messages@mapbox/assert-http@ngxvoice/ngx-voicelistner@howdypix/webappzjkj-md5@hollowverse/clown@mattvagni/typewriter@miop/rev@magicspace/core@ministryofjustice/fb-runner-node@marko/webpack@lettopia/extract-react-intl-messages@kikobeats/jsonsortyy-rev-top@taskr/revcbr-ratescarousel-reactcourse-vue-tplcreate-strv-app@yuku-t/gulp-rev-rails-manifestabc-gulp-revdigital-keyboard-demosdireqtorybetter-js-common-toolkitcommebabel-upgradengx-i18n-combinengx-i18n-splitmode-embed-urlmygulp-revnois-react-toastldl_revmetapakmiguelcostero-ng2-toastylazy-bee-uimanage-npm-packageparsec-gulp-revpkp-icproject-helperpublishimopublishimo-webpack-pluginpplinkpkg-opsrapid-ioreact-intl-universal-extractretrievalresettable-fileredux-undoredoresponsive-react-appsearch-input-reactsearch-list-reactscaphold-sync@angular-ru/ngx-i18n-combine@best-shot/preset-env@backtrack/core@digidem/extract-react-intl-messagessort-pkgsort-valuessimply-gulp-revsindresorhus.js@feathers-plus/commonswg-gulp-revsz-gulp-revjohn-test-upgradejsongojson-comb-corevue-compmenttypewritertypings-coretypes-localwebchen-ddkyut-runut-tools
4.0.0

10 months ago

3.0.0

1 year ago

2.0.0

3 years ago

1.1.2

4 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago

0.1.0

6 years ago