forked from purescript-contrib/purescript-arraybuffer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataView.js
More file actions
43 lines (33 loc) · 949 Bytes
/
DataView.js
File metadata and controls
43 lines (33 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"use strict";
// module Data.ArrayBuffer.DataView
exports.whole = function whole (b) {
return new DataView(b);
};
exports.remainderImpl = function remainderImpl (b,i) {
return new DataView(b,i);
};
exports.partImpl = function partImpl (b,i,j) {
return new DataView(b,i,j);
};
exports.buffer = function buffer (v) {
return v.buffer;
};
exports.byteOffset = function byteOffset (v) {
return v.byteOffset;
};
exports.byteLength = function byteLength (v) {
return v.byteLength;
};
exports.getterImpl = function getterImpl (data, v, o) {
return ((o + data.bytesPerValue) >>> 0) <= v.byteLength
? v[data.functionName].call(v,o,data.littleEndian)
: null;
};
exports.setterImpl = function setterImpl (data, v, o, n) {
if (((o + data.bytesPerValue) >>> 0) <= v.byteLength) {
v[data.functionName].call(v,o,n,data.littleEndian);
return true;
} else {
return false;
}
};