"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/utils/deep-sort-object.js" (8 Mar 2017, 424 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict'
    2 var sortedObject = require('sorted-object')
    3 
    4 module.exports = function deepSortObject (obj, sortBy) {
    5   if (obj == null || typeof obj !== 'object') return obj
    6   if (obj instanceof Array) {
    7     return obj.map(function (x) {
    8       return deepSortObject(x, sortBy)
    9     })
   10   }
   11   obj = sortedObject(obj)
   12   Object.keys(obj).forEach(function (key) {
   13     obj[key] = deepSortObject(obj[key], sortBy)
   14   })
   15   return obj
   16 }