diff --git a/index.js b/index.js index a555619..1dd1e17 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ var LruCache = require('./cache/lru'); -var weak = require('weak-napi'); +var weak = require('./weakref'); function noop(v) { return v; } function is(v, type) { return typeof v === type; } diff --git a/package.json b/package.json index 8d4df77..bafc5ba 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Throttle depending on function arguments.", "main": "index.js", "browser": { - "weak-napi": "./browser-weakref" + "./weakref": "./weakref-browser" }, "engines": { "node": "6.x.x" diff --git a/browser-weakref.js b/weakref-browser.js similarity index 100% rename from browser-weakref.js rename to weakref-browser.js diff --git a/weakref.js b/weakref.js new file mode 100644 index 0000000..228e506 --- /dev/null +++ b/weakref.js @@ -0,0 +1,5 @@ +const nodeMajorVersion = parseInt(process.versions.node.replace(/\..*/, '')); + +module.exports = nodeMajorVersion >= 12 ? + require('./weakref-browser') : // https://github.com/node-ffi-napi/weak-napi/issues/16 + require('weak-napi');