From 10faafd13853da8549a1bd9625208e5f026eb203 Mon Sep 17 00:00:00 2001 From: Jonathan Lonowski Date: Sun, 3 Apr 2016 20:35:55 -0500 Subject: [PATCH 1/2] Avoid replacing existing `toJSON` definitions. --- index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/index.js b/index.js index d92103f..8f54650 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +if (!('toJSON' in Error.prototype)) Object.defineProperty(Error.prototype, 'toJSON', { value: function () { var alt = {}; From f78f10f3a8548c2e085aa6c9baab9151ddc26ae0 Mon Sep 17 00:00:00 2001 From: Jonathan Lonowski Date: Mon, 4 Apr 2016 21:43:41 -0500 Subject: [PATCH 2/2] Revise to exit module if `toJSON` is already defined. AVVS/error-tojson#3 --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8f54650..b4af5b7 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,7 @@ -if (!('toJSON' in Error.prototype)) +if ('toJSON' in Error.prototype) { + return; +} + Object.defineProperty(Error.prototype, 'toJSON', { value: function () { var alt = {};