source: imaps-frontend/node_modules/es-abstract/2024/IsFixedLengthArrayBuffer.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 966 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var callBound = require('call-bind/callBound');
6
7var $arrayBufferResizable = callBound('%ArrayBuffer.prototype.resizable%', true);
8var $sharedArrayGrowable = callBound('%SharedArrayBuffer.prototype.growable%', true);
9
10var isArrayBuffer = require('is-array-buffer');
11var isSharedArrayBuffer = require('is-shared-array-buffer');
12
13// https://262.ecma-international.org/15.0/#sec-isfixedlengtharraybuffer
14
15module.exports = function IsFixedLengthArrayBuffer(arrayBuffer) {
16 var isAB = isArrayBuffer(arrayBuffer);
17 var isSAB = isSharedArrayBuffer(arrayBuffer);
18 if (!isAB && !isSAB) {
19 throw new $TypeError('Assertion failed: `arrayBuffer` must be an ArrayBuffer or SharedArrayBuffer');
20 }
21
22 if (isAB && $arrayBufferResizable) {
23 return !$arrayBufferResizable(arrayBuffer); // step 1
24 }
25 if (isSAB && $sharedArrayGrowable) {
26 return !$sharedArrayGrowable(arrayBuffer); // step 1
27 }
28 return true; // step 2
29};
Note: See TracBrowser for help on using the repository browser.