index.js 531 B

12345678910111213141516171819
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var callBound = require('call-bind/callBound');
  5. var $typedArrayBuffer = callBound('TypedArray.prototype.buffer', true);
  6. var isTypedArray = require('is-typed-array');
  7. // node <= 0.10, < 0.11.4 has a nonconfigurable own property instead of a prototype getter
  8. module.exports = $typedArrayBuffer || function typedArrayBuffer(x) {
  9. if (!isTypedArray(x)) {
  10. throw new $TypeError('Not a Typed Array');
  11. }
  12. return x.buffer;
  13. };