From 49389d0a2f8e155ddfdab80c227cb51bce1b6da9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Thu, 18 Feb 2016 21:52:53 -0800 Subject: [PATCH] Ducktype in `_.isError` for ES6 support. --- lodash.js | 3 +-- test/test.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index 8c00fa428..854d9edae 100644 --- a/lodash.js +++ b/lodash.js @@ -9871,9 +9871,8 @@ if (!isObjectLike(value)) { return false; } - var Ctor = value.constructor; return (objectToString.call(value) == errorTag) || - (typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag); + (typeof value.message == 'string' && typeof value.name == 'string'); } /** diff --git a/test/test.js b/test/test.js index 3f7673d85..f98481ca9 100644 --- a/test/test.js +++ b/test/test.js @@ -364,7 +364,9 @@ this.message = message; } - CustomError.prototype = lodashStable.create(Error.prototype); + CustomError.prototype = lodashStable.create(Error.prototype, { + 'constructor': CustomError + }); /** * Removes all own enumerable properties from a given object.