@webb/order-object
TypeScript icon, indicating that this package has built-in type declarations

2020.4.16 • Public • Published

@webb/order-object

Make sure your Object keys are in alphabetical order

Install

$ npm i @webb/order-object

Usage

// Import the default export
import orderObject from "@webb/order-object";

orderObject({ zebra: "yay", 1: "neo", horse: "neigh" });
// ^ Returns { "1": "neo", horse: "neigh", zebra: "yay" }
// Or, export the named function
import { order } from "@webb/order-object";

order({ zebra: "yay", 1: "neo", horse: "neigh" });
// ^ Returns { "1": "neo", horse: "neigh", zebra: "yay" }

API

order(suppliedObject)

suppliedObject

Type: object (required)

  • If nothing is supplied, the response is null.
  • If you supply anything that is not an object, whatever you supplied is returned unchanged.

Tests

# Run all tests, sequentially
$ npm test

# Test dependencies for latest versions
$ npm run test:dependencies

# Lint "src" directory
$ npm run test:typescript

# Test this module
$ npm run test:assert

Thanks

Maggie Shemayev has a number of useful gists and this module is inspired by one of them.

Readme

Keywords

none

Package Sidebar

Install

npm i @webb/order-object

Weekly Downloads

0

Version

2020.4.16

License

MIT

Unpacked Size

6.1 kB

Total Files

6

Last publish

Collaborators

  • netoperatorwibby