Skip to content

Commit

Permalink
Use gopd to check is writable
Browse files Browse the repository at this point in the history
  • Loading branch information
scagood committed Mar 19, 2024
1 parent 29a7311 commit 82facfc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
]
},
"dependencies": {
"gopd": "^1.0.1",
"typedarray.prototype.slice": "^1.0.2",
"which-typed-array": "^1.1.15"
},
Expand Down

0 comments on commit 82facfc

Please sign in to comment.