Skip to content

Commit

Permalink
[Fix] normalize function signature whitespace, for IE 9.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 10, 2015
1 parent d222ba0 commit 3e0df7b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ var isArray = Array.isArray || function (value) {
return toStr.call(value) === '[object Array]';
};

var normalizeFnWhitespace = function normalizeFnWhitespace(fnStr) {
// this is needed in IE 9, at least, which has inconsistencies here.
return fnStr.replace(/^function ?\(/, 'function (').replace('){', ') {');
};

module.exports = function isEqual(value, other) {
if (value === other) { return true; }
if (value == null || other == null) { return value === other; }
Expand Down Expand Up @@ -126,8 +131,8 @@ module.exports = function isEqual(value, other) {
if (functionsHaveNames && !isEqual(value.name, other.name)) { return false; }
if (!isEqual(value.length, other.length)) { return false; }

var valueStr = String(value);
var otherStr = String(other);
var valueStr = normalizeFnWhitespace(String(value));
var otherStr = normalizeFnWhitespace(String(other));
if (isEqual(valueStr, otherStr)) { return true; }

if (!valueIsGen && !valueIsArrow) {
Expand Down

0 comments on commit 3e0df7b

Please sign in to comment.