Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Nov 13, 2017
1 parent dd22fc5 commit 9dbbec8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/formatter/sortObject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

export default function sortObject(value: any) {
export default function sortObject(value: any): any {
// return non-object value as is
if (value === null || typeof value !== 'object') {
return value;
Expand All @@ -11,10 +11,12 @@ export default function sortObject(value: any) {
return value;
}

// make a copy of array with each item passed through sortObject()
if (Array.isArray(value)) {
return value.map(sortObject);
}

// make a copy of object with key sorted
return Object.keys(value)
.sort()
.reduce((result, key) => {
Expand Down

0 comments on commit 9dbbec8

Please sign in to comment.