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
41 lines (32 loc) · 817 Bytes
/
DataView.js
File metadata and controls
41 lines (32 loc) · 817 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
// module Data.ArrayBuffer.DataView
export function whole(b) {
return new DataView(b);
}
export function remainderImpl(b, i) {
return new DataView(b,i);
}
export function partImpl(b, i, j) {
return new DataView(b,i,j);
}
export function buffer(v) {
return v.buffer;
}
export function byteOffset(v) {
return v.byteOffset;
}
export function byteLength(v) {
return v.byteLength;
}
export function getterImpl(data, v, o) {
return ((o + data.bytesPerValue) >>> 0) <= v.byteLength
? v[data.functionName].call(v,o,data.littleEndian)
: null;
}
export 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;
}
}