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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var ArrayBufferByteLength = require('./ArrayBufferByteLength');
|
---|
| 6 | var IsDetachedBuffer = require('./IsDetachedBuffer');
|
---|
| 7 |
|
---|
| 8 | var dataViewBuffer = require('data-view-buffer');
|
---|
| 9 | var isDataView = require('is-data-view');
|
---|
| 10 |
|
---|
| 11 | // https://262.ecma-international.org/15.0/#sec-makedataviewwithbufferwitnessrecord
|
---|
| 12 |
|
---|
| 13 | module.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.