index.js 394 B

12345678910111213
  1. 'use strict';
  2. var callBound = require('call-bind/callBound');
  3. var $byteLength = callBound('ArrayBuffer.prototype.byteLength', true);
  4. var isArrayBuffer = require('is-array-buffer');
  5. module.exports = function byteLength(ab) {
  6. if (!isArrayBuffer(ab)) {
  7. return NaN;
  8. }
  9. return $byteLength ? $byteLength(ab) : ab.byteLength;
  10. }; // in node < 0.11, byteLength is an own nonconfigurable property