1.0.0 • Published 5 years ago
object-prettify v1.0.0
node-object-prettify
Sort properties in an object using a template
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: '' }
1.0.0
5 years ago