blob: 7499efc4bef53369e833674723e91535bfaabfcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
'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
}
|