Skip to content

Latest commit

 

History

History
67 lines (38 loc) · 1.18 KB

README.md

File metadata and controls

67 lines (38 loc) · 1.18 KB

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