From 282c73def50178b3aa680c977f21945a95a3e511 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Apr 2018 07:12:26 +1200 Subject: [PATCH 1/3] Replaced assignment to readonly Function.name with Object.defineProperty, as you can't assign to readonly properties in strict mode. --- lib/v35.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/v35.js b/lib/v35.js index 842c60ea..3a4f1443 100644 --- a/lib/v35.js +++ b/lib/v35.js @@ -43,7 +43,7 @@ module.exports = function(name, version, hashfunc) { return buf || bytesToUuid(bytes); }; - generateUUID.name = name; + Object.defineProperty(generateUUID, 'name', {value: name}); // Pre-defined namespaces, per Appendix C generateUUID.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; From f0e56c884ea42cd5501d9a6af2a6ce2e41a31835 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Fri, 6 Apr 2018 09:08:35 +1200 Subject: [PATCH 2/3] added check to make sure the name property is configurable before trying to configure it. This should allow compatibility with both strict mode and non-standard, pre-ES2015 implementations, such as in node 0.12.x --- lib/v35.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/v35.js b/lib/v35.js index 3a4f1443..d26e7007 100644 --- a/lib/v35.js +++ b/lib/v35.js @@ -43,7 +43,11 @@ module.exports = function(name, version, hashfunc) { return buf || bytesToUuid(bytes); }; - Object.defineProperty(generateUUID, 'name', {value: name}); + + // only attempt to set the name if's configurable (which it should be on node > 0.12) + if (Object.getOwnPropertyDescriptor(generateUUID, 'name').configurable) { + Object.defineProperty(generateUUID, 'name', {value: name}); + } // Pre-defined namespaces, per Appendix C generateUUID.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; From 904a6c1ebcd0c02fb7bab9bcac178166c9806646 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Wed, 25 Apr 2018 10:13:15 +1200 Subject: [PATCH 3/3] Removed extra blank newline. --- lib/v35.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/v35.js b/lib/v35.js index d26e7007..1f05d38d 100644 --- a/lib/v35.js +++ b/lib/v35.js @@ -43,7 +43,6 @@ module.exports = function(name, version, hashfunc) { return buf || bytesToUuid(bytes); }; - // only attempt to set the name if's configurable (which it should be on node > 0.12) if (Object.getOwnPropertyDescriptor(generateUUID, 'name').configurable) { Object.defineProperty(generateUUID, 'name', {value: name});