source: imaps-frontend/node_modules/es-abstract/2024/IsArrayBufferViewOutOfBounds.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: 1.0 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var IsTypedArrayOutOfBounds = require('./IsTypedArrayOutOfBounds');
6var IsViewOutOfBounds = require('./IsViewOutOfBounds');
7var MakeDataViewWithBufferWitnessRecord = require('./MakeDataViewWithBufferWitnessRecord');
8var MakeTypedArrayWithBufferWitnessRecord = require('./MakeTypedArrayWithBufferWitnessRecord');
9
10var isDataView = require('is-data-view');
11var isTypedArray = require('is-typed-array');
12
13// https://262.ecma-international.org/15.0/#sec-isarraybufferviewoutofbounds
14
15module.exports = function IsArrayBufferViewOutOfBounds(O) {
16 var isDV = isDataView(O);
17 if (!isTypedArray(O) && !isDV) {
18 throw new $TypeError('Assertion failed: `O` must be a TypedArray or DataView');
19 }
20
21 if (isDV) { // step 1
22 var viewRecord = MakeDataViewWithBufferWitnessRecord(O, 'SEQ-CST'); // step 1.a
23
24 return IsViewOutOfBounds(viewRecord); // step 1.b
25 }
26
27 var taRecord = MakeTypedArrayWithBufferWitnessRecord(O, 'SEQ-CST'); // step 2
28
29 return IsTypedArrayOutOfBounds(taRecord); // step 3
30};
Note: See TracBrowser for help on using the repository browser.