|
3 | 3 | // module Data.ArrayBuffer.DataView |
4 | 4 |
|
5 | 5 |
|
6 | | -exports.whole = function(b) { |
7 | | - return new DataView(b); |
8 | | -} |
9 | | - |
10 | | -exports.sliceImpl = function(just, nothing, s, l, b) { |
11 | | - return ((s + l)>>>0) <= b.byteLength ? just(new DataView(b, s, l)) : nothing; |
12 | | -} |
13 | | - |
14 | | -exports.buffer = function(v) { |
15 | | - return v.buffer; |
16 | | -} |
17 | | - |
18 | | -exports.byteOffset = function(v) { |
19 | | - return v.byteOffset; |
20 | | -} |
21 | | - |
22 | | -exports.byteLength = function(v) { |
23 | | - return v.byteLength; |
24 | | -} |
25 | | - |
26 | | -exports.getterImpl = function(just, nothing, s, l, e, v, o) { |
27 | | - return function() { |
28 | | - return ((o + l)>>>0) <= v.byteLength? just(v[s].call(v,o,e)) : nothing; |
29 | | - }; |
30 | | -} |
31 | | - |
32 | | -exports.setter = function(s) { |
33 | | - return function(e) { |
34 | | - return function(v) { |
35 | | - var f = v[s]; |
36 | | - return function(n) { |
37 | | - return function(o) { |
38 | | - return function() { |
39 | | - f.call(v,o,n,e); |
40 | | - }; |
41 | | - }; |
42 | | - }; |
43 | | - }; |
44 | | - }; |
45 | | -} |
| 6 | +exports.whole = function whole (b) { |
| 7 | + return new DataView(b); |
| 8 | +}; |
| 9 | + |
| 10 | +exports.remainderImpl = function remainderImpl (b,i) { |
| 11 | + return new DataView(b,i); |
| 12 | +}; |
| 13 | + |
| 14 | +exports.partImpl = function partImpl (b,i,j) { |
| 15 | + return new DataView(b,i,j); |
| 16 | +}; |
| 17 | + |
| 18 | +exports.buffer = function buffer (v) { |
| 19 | + return v.buffer; |
| 20 | +}; |
| 21 | + |
| 22 | +exports.byteOffset = function byteOffset (v) { |
| 23 | + return v.byteOffset; |
| 24 | +}; |
| 25 | + |
| 26 | +exports.byteLength = function byteLength (v) { |
| 27 | + return v.byteLength; |
| 28 | +}; |
| 29 | + |
| 30 | +exports.getterImpl = function getterImpl (data, v, o) { |
| 31 | + return ((o + data.bytesPerValue) >>> 0) <= v.byteLength |
| 32 | + ? v[data.functionName].call(v,o,data.littleEndian) |
| 33 | + : null; |
| 34 | +}; |
| 35 | + |
| 36 | +exports.setterImpl = function setterImpl (data, v, o, n) { |
| 37 | + if (((o + data.bytesPerValue) >>> 0) <= v.byteLength) { |
| 38 | + v[data.functionName].call(v,o,n,data.littleEndian); |
| 39 | + return true; |
| 40 | + } else { |
| 41 | + return false; |
| 42 | + } |
| 43 | +}; |
0 commit comments