/
serialize.bff.l32f_foo.js
61 lines (51 loc) · 1.52 KB
/
serialize.bff.l32f_foo.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
module.exports = function (object, callback) {
var inc
inc = function (buffer, start, end, index) {
var index
var bite
var next
var _foo
this.write = function (buffer, start, end) {
switch (index) {
case 0:
_foo = new ArrayBuffer(4)
new DataView(_foo).setFloat32(0, object["foo"], true)
bite = 0
index = 1
case 1:
while (bite != 4) {
if (start == end) {
return start
}
buffer[start++] = _foo[bite]
bite++
}
}
if (next = callback && callback(object)) {
this.write = next
return this.write(buffer, start, end)
}
return start
}
return this.write(buffer, start, end)
}
return function (buffer, start, end) {
var next
var _foo
if (end - start < 4) {
return inc.call(this, buffer, start, end, 0)
}
_foo = new ArrayBuffer(4)
new DataView(_foo).setFloat32(0, object["foo"], true)
buffer[start] = _foo[0]
buffer[start + 1] = _foo[1]
buffer[start + 2] = _foo[2]
buffer[start + 3] = _foo[3]
start += 4
if (next = callback && callback(object)) {
this.write = next
return this.write(buffer, start, end)
}
return start
}
}