From f9a4ee7e9f188c213badb367112ceaa3753ecd96 Mon Sep 17 00:00:00 2001 From: Jan Aagaard Meier Date: Sun, 28 Feb 2016 18:18:01 +0100 Subject: [PATCH] Mark the native property as non-enumerable. Closes #945 --- lib/index.js | 11 +++++++---- test/unit/client/native-property-tests.js | 7 +++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 test/unit/client/native-property-tests.js diff --git a/lib/index.js b/lib/index.js index c8b9f5385..93fee4c3d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -73,9 +73,12 @@ if(typeof process.env.NODE_PG_FORCE_NATIVE != 'undefined') { module.exports = new PG(Client); //lazy require native module...the native module may not have installed - module.exports.__defineGetter__("native", function() { - delete module.exports.native; - module.exports.native = new PG(require('./native')); - return module.exports.native; + Object.defineProperty(module.exports, 'native', { + get: function () { + delete module.exports._native; + module.exports._native = new PG(require('./native')); + return module.exports._native; + }, + enumerable: false }); } diff --git a/test/unit/client/native-property-tests.js b/test/unit/client/native-property-tests.js new file mode 100644 index 000000000..b4502cb9a --- /dev/null +++ b/test/unit/client/native-property-tests.js @@ -0,0 +1,7 @@ +var helper = require(__dirname + "/test-helper"); +var client = require(__dirname + "/../../../lib"); + +test('native property is non-enumerable', function() { + assert.equal(Object.keys(client).indexOf('native'), -1); +}); +