diff --git a/index.js b/index.js index 610a915..9416ffc 100644 --- a/index.js +++ b/index.js @@ -15,5 +15,15 @@ exports.hello = require(exports.hellop); delete require.cache[require.resolve(exports.arraysp)]; const { ArrayUtil } = require(exports.arraysp); +const AU_default = ArrayUtil(!0); +Object.defineProperty(ArrayUtil, 'sample', { + value: AU_default.sample.bind(this && this.constructor === ArrayUtil ? this : AU_default), + enumerable: !0, +}); +Object.defineProperty(ArrayUtil, 'shuffle', { + value: AU_default.shuffle.bind(this && this.constructor === ArrayUtil ? this : AU_default), + enumerable: !0, +}); + exports.ArrayUtil = ArrayUtil; exports.arrays = ArrayUtil; diff --git a/package-lock.json b/package-lock.json index 3bda1de..95be9b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "nodecpp-test", - "version": "1.2.1b", + "version": "1.2.2", "lockfileVersion": 1 } diff --git a/package.json b/package.json index c24e247..467df55 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodecpp-test", - "version": "1.2.1b", + "version": "1.2.2", "description": "Some utilities written in c++", "main": "index.js", "scripts": { diff --git a/src/headers/arrayutil.hpp b/src/headers/arrayutil.hpp index 5da01a4..9409673 100644 --- a/src/headers/arrayutil.hpp +++ b/src/headers/arrayutil.hpp @@ -11,14 +11,15 @@ namespace arrays { class ArrayUtil : public node::ObjectWrap { public: static void Init(v8::Local exports); + static void Shuffle(const v8::FunctionCallbackInfo& args); + static void Sample(const v8::FunctionCallbackInfo& args); private: explicit ArrayUtil(bool safe); ~ArrayUtil(); static void New(const v8::FunctionCallbackInfo& args); - static void Shuffle(const v8::FunctionCallbackInfo& args); - static void Sample(const v8::FunctionCallbackInfo& args); + static v8::Persistent constructor; bool safe_; };