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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var callBound = require('call-bind/callBound');
|
---|
| 6 |
|
---|
| 7 | var $arrayBufferResizable = callBound('%ArrayBuffer.prototype.resizable%', true);
|
---|
| 8 | var $sharedArrayGrowable = callBound('%SharedArrayBuffer.prototype.growable%', true);
|
---|
| 9 |
|
---|
| 10 | var isArrayBuffer = require('is-array-buffer');
|
---|
| 11 | var isSharedArrayBuffer = require('is-shared-array-buffer');
|
---|
| 12 |
|
---|
| 13 | // https://262.ecma-international.org/15.0/#sec-isfixedlengtharraybuffer
|
---|
| 14 |
|
---|
| 15 | module.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.