Skip to content

NetOpWibby/order-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Make sure your Object keys are in alphabetical order

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published