source: imaps-frontend/node_modules/es-abstract/2024/MakeDataViewWithBufferWitnessRecord.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: 936 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var ArrayBufferByteLength = require('./ArrayBufferByteLength');
6var IsDetachedBuffer = require('./IsDetachedBuffer');
7
8var dataViewBuffer = require('data-view-buffer');
9var isDataView = require('is-data-view');
10
11// https://262.ecma-international.org/15.0/#sec-makedataviewwithbufferwitnessrecord
12
13module.exports = function MakeDataViewWithBufferWitnessRecord(obj, order) {
14 if (!isDataView(obj)) {
15 throw new $TypeError('MakeDataViewWithBufferWitnessRecord called with non-DataView');
16 }
17 if (order !== 'SEQ-CST' && order !== 'UNORDERED') {
18 throw new $TypeError('Assertion failed: `order` must be ~SEQ-CST~ or ~UNORDERED~');
19 }
20
21 var buffer = dataViewBuffer(obj); // step 1
22
23 var byteLength = IsDetachedBuffer(buffer) ? 'DETACHED' : ArrayBufferByteLength(buffer, order); // steps 2 - 3
24
25 return { '[[Object]]': obj, '[[CachedBufferByteLength]]': byteLength }; // step 4
26};
Note: See TracBrowser for help on using the repository browser.