source: imaps-frontend/node_modules/es-abstract/2017/ValidateAtomicAccess.js

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 900 bytes
Line 
1'use strict';
2
3var $RangeError = require('es-errors/range');
4var $TypeError = require('es-errors/type');
5
6var ToIndex = require('./ToIndex');
7
8var isTypedArray = require('is-typed-array');
9var typedArrayLength = require('typed-array-length');
10
11// https://262.ecma-international.org/8.0/#sec-validateatomicaccess
12
13module.exports = function ValidateAtomicAccess(typedArray, requestIndex) {
14 if (!isTypedArray(typedArray)) {
15 throw new $TypeError('Assertion failed: `typedArray` must be a TypedArray'); // step 1
16 }
17
18 var accessIndex = ToIndex(requestIndex); // step 2
19
20 var length = typedArrayLength(typedArray); // step 3
21
22 /*
23 // this assertion can never be reached
24 if (!(accessIndex >= 0)) {
25 throw new $TypeError('Assertion failed: accessIndex >= 0'); // step 4
26 }
27 */
28
29 if (accessIndex >= length) {
30 throw new $RangeError('index out of range'); // step 5
31 }
32
33 return accessIndex; // step 6
34};
Note: See TracBrowser for help on using the repository browser.