Files
NapCatQQ/.pnpm-store/v3/files/9b/e6bae6e3269ac51611bf9a2f64b0240b49fe86afa33f158d61723930720d437451b37681908fef62a815f3d2a29abc66b0ce90cce39b0f98264d8330f21c90
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

33 lines
1.0 KiB
Plaintext

'use strict';
var $TypeError = require('es-errors/type');
var isObject = require('es-object-atoms/isObject');
var IsTypedArrayOutOfBounds = require('./IsTypedArrayOutOfBounds');
var MakeTypedArrayWithBufferWitnessRecord = require('./MakeTypedArrayWithBufferWitnessRecord');
var isTypedArray = require('is-typed-array');
// https://262.ecma-international.org/15.0/#sec-validatetypedarray
module.exports = function ValidateTypedArray(O, order) {
if (order !== 'SEQ-CST' && order !== 'UNORDERED') {
throw new $TypeError('Assertion failed: `order` must be ~SEQ-CST~ or ~UNORDERED~');
}
if (!isObject(O)) {
throw new $TypeError('Assertion failed: `O` must be an Object'); // step 1
}
if (!isTypedArray(O)) {
throw new $TypeError('Assertion failed: `O` must be a Typed Array'); // steps 1 - 2
}
var taRecord = MakeTypedArrayWithBufferWitnessRecord(O, order); // step 3
if (IsTypedArrayOutOfBounds(taRecord)) {
throw new $TypeError('`O` must be in-bounds and backed by a non-detached buffer'); // step 4
}
return taRecord; // step 5
};