UNPKG

json-order

Version:

Control the order of properties in JSON via a lookup object - including nested properties.

12 lines (11 loc) 552 B
import { PropertyMap } from './models'; /** * Duplicate a JS object but containing a particular property order * * @param sourceObject an object with the properties in any order * @param map the `PropertyMap` generated by the `parse` method * @param separator a non-empty `string` that controls what the key separator is in the generated map. Defaults to `~`. * @returns the source object ordered as per the map */ declare const order: <T extends object>(sourceObject: T, map: PropertyMap | null, separator?: string) => T; export default order;