From d6950885a1325f2a31fcb3e79adebff7af4d3fb5 Mon Sep 17 00:00:00 2001 From: Semigradsky Date: Tue, 5 Jul 2016 11:36:06 +0300 Subject: [PATCH] Fixed #298: RangeError: Maximum call stack size exceeded with custom validator --- src/utils.js | 2 ++ tests/Utils-spec.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/utils.js b/src/utils.js index 16cbf09..eabcc6f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -32,6 +32,8 @@ module.exports = { return false; } else if (Array.isArray(a)) { return !this.arraysDiffer(a, b); + } else if (typeof a === 'function') { + return a.toString() === b.toString(); } else if (typeof a === 'object' && a !== null && b !== null) { return !this.objectsDiffer(a, b); } diff --git a/tests/Utils-spec.js b/tests/Utils-spec.js index fdec451..3055dce 100644 --- a/tests/Utils-spec.js +++ b/tests/Utils-spec.js @@ -25,6 +25,10 @@ export default { test.equal(utils.isSame(objA, objH), false); test.equal(utils.isSame(objG, objA), false); + test.equal(utils.isSame(() => {}, () => {}), true); + test.equal(utils.isSame(objA, () => {}), false); + test.equal(utils.isSame(() => {}, objA), false); + test.done(); }