|
13 | 13 | * @param {any} args = ([deep, ]target, source1[, ...sourceN]) |
14 | 14 | * @return {any} The result. |
15 | 15 | */ |
16 | | - let extend = (...args) => { |
| 16 | + const extend = (...args) => { |
17 | 17 | let val, |
18 | 18 | deep; |
19 | 19 | if (typeof args[0] === 'boolean') { |
|
38 | 38 | * @param {Object} data The JSON data. |
39 | 39 | * @return {DataView} The DataView of the ArrayBuffer. |
40 | 40 | */ |
41 | | - let encode = (offset, data) => { |
| 41 | + const encode = (offset, data) => { |
42 | 42 | let arr = [], |
43 | 43 | view = new DataView(new ArrayBuffer(_encode(offset, arr, data))); |
44 | 44 | arr.forEach(item => { |
45 | 45 | view[`set${item.type}`](item.offset, item.val); |
46 | 46 | }); |
47 | 47 | return view; |
48 | | - } |
| 48 | + }; |
49 | 49 |
|
50 | 50 | /** |
51 | 51 | * Inner function to Convert JSON to ArrayBuffer. |
|
54 | 54 | * @param {Object} data The JSON data. |
55 | 55 | * @return {number} The start of the next call. |
56 | 56 | */ |
57 | | - let _encode = (offset, arr, data) => { |
| 57 | + const _encode = (offset, arr, data) => { |
58 | 58 | if (data instanceof Array) { |
59 | 59 | //Here is using a Uint8 to store the length of Array, so the length of Array can only be up to 255. |
60 | 60 | arr.push({ |
|
183 | 183 | }); |
184 | 184 | } |
185 | 185 | return offset; |
186 | | - } |
| 186 | + }; |
187 | 187 |
|
188 | 188 | /** |
189 | 189 | * Revert ArrayBuffer to JSON. |
|
192 | 192 | * @param {(ArrayBuffer|Buffer|DataView)} source The ArrayBuffer, or the Buffer in Node.js, or the DataView of the ArrayBuffer. |
193 | 193 | * @return {Object} The JSON data. |
194 | 194 | */ |
195 | | - let decode = (offset, template, source) => { |
| 195 | + const decode = (offset, template, source) => { |
196 | 196 | _decode(offset, template, source); |
197 | 197 | return template; |
198 | 198 | }; |
|
204 | 204 | * @param {(ArrayBuffer|Buffer|DataView)} source The ArrayBuffer, or the Buffer in Node.js, or the DataView of the ArrayBuffer. |
205 | 205 | * @return {number} The start of the next call. |
206 | 206 | */ |
207 | | - let _decode = (offset, template, source) => { |
| 207 | + const _decode = (offset, template, source) => { |
208 | 208 | let view; |
209 | 209 | if (template instanceof Object) { |
210 | 210 | view = source instanceof DataView ? source : new DataView(source instanceof ArrayBuffer ? source : new Uint8Array(source).buffer); |
|
0 commit comments