Show More
Commit Commit message Age Author Refs
r3:f106bd9265c3
Upgraded deps
0
r2:aca768f133d0
Updated deps and removed private registry
0
r1:9ff7d2351428
Return 0 instead of null
0
r0:92d737840005
Initial commit
0
< 1 >

@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.