mirror of
https://github.com/nodejs/node.git
synced 2026-12-05 01:18:46 -05:00
PR-URL: https://github.com/nodejs/node/pull/14235 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com>
15 lines
363 B
JavaScript
15 lines
363 B
JavaScript
'use strict'
|
|
var sortedObject = require('sorted-object')
|
|
|
|
module.exports = function deepSortObject (obj) {
|
|
if (obj == null || typeof obj !== 'object') return obj
|
|
if (obj instanceof Array) {
|
|
return obj.map(deepSortObject)
|
|
}
|
|
obj = sortedObject(obj)
|
|
Object.keys(obj).forEach(function (key) {
|
|
obj[key] = deepSortObject(obj[key])
|
|
})
|
|
return obj
|
|
}
|