From f2a60f2fcdd7957cc7ae201165377af698e5b0ef Mon Sep 17 00:00:00 2001 From: Robert Kieffer Date: Thu, 28 Jun 2018 12:08:43 -0700 Subject: [PATCH] fix: fix #284 by setting function name in try-catch --- lib/v35.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/v35.js b/lib/v35.js index 1f05d38d..7e1af903 100644 --- a/lib/v35.js +++ b/lib/v35.js @@ -3,6 +3,7 @@ var bytesToUuid = require('./bytesToUuid'); function uuidToBytes(uuid) { // Note: We assume we're being passed a valid uuid string var bytes = []; + const el = uuid.replace(/[a-fA-F0-9]{2}/g, function(hex) { bytes.push(parseInt(hex, 16)); }); @@ -43,9 +44,10 @@ 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}); + // Function#name is not settable on some platforms (#270) + try { + generateUUID.name = name; + } catch (err) { } // Pre-defined namespaces, per Appendix C