Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,14 @@ export function parse(query, options) {
return returnValue;
}

// TODO: Remove the use of `reduce`.
// eslint-disable-next-line unicorn/no-array-reduce
return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {
const sortedKeys = options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort);
const result = Object.create(null);
for (const key of sortedKeys) {
const value = returnValue[key];
result[key] = Boolean(value) && typeof value === 'object' && !Array.isArray(value) ? keysSorter(value) : value;
return result;
}, Object.create(null));
}

return result;
}

export function stringify(object, options) {
Expand Down