diff --git a/index.js b/index.js index 41b65d3..ce507da 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ var whichTypedArray = require('which-typed-array'); var taSlice = require('typedarray.prototype.slice'); +var gopd = require('gopd'); // TODO: use call-bind, is-date, is-regex, is-string, is-boolean-object, is-number-object function toS(obj) { return Object.prototype.toString.call(obj); } @@ -58,8 +59,11 @@ var hasOwnProperty = Object.prototype.hasOwnProperty || function (obj, key) { }; function isWritable(object, key) { - var descriptor = Object.getOwnPropertyDescriptor(object, key); - return descriptor && !descriptor.writable; + if (typeof gopd !== 'function') { + return true; + } + + return !gopd(object, key).writable; } function copy(src) { diff --git a/package.json b/package.json index 88305b1..223335e 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ ] }, "dependencies": { + "gopd": "^1.0.1", "typedarray.prototype.slice": "^1.0.2", "which-typed-array": "^1.1.15" },