Skip to content

Commit

Permalink
simplified serialization of objects
Browse files Browse the repository at this point in the history
  • Loading branch information
erdtman committed Nov 16, 2020
1 parent 242580b commit b07733f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/canonicalize.js
Expand Up @@ -15,13 +15,11 @@ module.exports = function serialize (object) {
}, '') + ']';
}

let atFirstKey = true;
return '{' + Object.keys(object).sort().reduce((t, cv, ci) => {
if (object[cv] === undefined) {
return t;
}
const comma = atFirstKey ? '' : ',';
atFirstKey = false;
const comma = t.length === 0 ? '' : ',';
return t + comma + serialize(cv) + ':' + serialize(object[cv]);
}, '') + '}';
};

0 comments on commit b07733f

Please sign in to comment.