1.0.0 • Published 5 years ago

object-prettify v1.0.0

Weekly downloads
301
License
MIT
Repository
github
Last release
5 years ago

node-object-prettify

Sort properties in an object using a template

npm Travis (.org) Coveralls github

npm

Introduction

This module can sort properties of an object using a template. That way you can have inputs of different order, and sort it how you like to have repeating structure.

Examples

const objectPrettify = require('object-prettify');

const target = { bar: '', foo: '' };
// Object to sort

const template = { foo: 1, bar: 1 };
// How the properties should be arranged (the value of the properties does not matter, but the order does)

const prettified = objectPrettify(target, select);
// The result will be { foo: '', bar: '' }

Template as an array

const objectPrettify = require('object-prettify');

const target = { bar: '', foo: '' };

const template = [ 'foo', 'bar' ];

const prettified = objectPrettify(target, select);
// The result will be { foo: '', bar: '' }