Skip to content

Commit

Permalink
fix: handle canonicalizing Module
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobLey committed May 22, 2022
1 parent 023f548 commit 1660462
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ exports.type = function type(value) {
exports.stringify = function (value) {
var typeHint = canonicalType(value);

if (!~['object', 'array', 'function'].indexOf(typeHint)) {
if (!~['object', 'array', 'function', 'module'].indexOf(typeHint)) {
if (typeHint === 'buffer') {
var json = Buffer.prototype.toJSON.call(value);
// Based on the toJSON result
Expand Down Expand Up @@ -401,6 +401,12 @@ exports.canonicalize = function canonicalize(value, stack, typeHint) {
break;
}
/* falls through */
case 'module':
if (value[Symbol.toStringTag] === 'Module') {
canonicalizedObj = canonicalizedObj || {};
canonicalizedObj['[Symbol.toStringTag]'] = 'Module';
}
/* falls through */
case 'object':
canonicalizedObj = canonicalizedObj || {};
withStack(value, function () {
Expand Down

0 comments on commit 1660462

Please sign in to comment.