|
4 | 4 |
|
5 | 5 | R = require 'ramda'
|
6 | 6 |
|
| 7 | + {add, compose, converge, curry, equals, identity, invoker, last, nth, pipe, replace, slice} = R |
| 8 | +
|
7 | 9 |
|
8 | 10 | ## Helper functions
|
9 | 11 |
|
10 |
| - buffer_to_string = R.invoker 1, 'toString' |
| 12 | + buffer_to_string = invoker 1, 'toString' |
11 | 13 |
|
12 |
| - last_is_0 = R.pipe R.last, R.equals 0 |
| 14 | + last_is_0 = pipe last, equals 0 |
13 | 15 |
|
14 |
| - strip_last_0 = R.when last_is_0, R.slice(0, -1) |
| 16 | + strip_last_0 = R.when last_is_0, slice(0, -1) |
15 | 17 |
|
16 |
| - buffer_to_ascii = R.pipe strip_last_0, buffer_to_string 'ascii' |
| 18 | + buffer_to_ascii = pipe strip_last_0, buffer_to_string 'ascii' |
17 | 19 |
|
18 |
| - swap_slashes = R.replace /\\/g, '/' |
| 20 | + swap_slashes = replace /\\/g, '/' |
19 | 21 |
|
20 | 22 |
|
21 | 23 | ## Exports
|
|
24 | 26 | ascii: buffer_to_ascii
|
25 | 27 |
|
26 | 28 | #char: R.compose String.fromCharCode, R.nth
|
27 |
| - char: R.curry (index, buffer)-> |
28 |
| - String.fromCharCode R.nth index, buffer |
| 29 | + char: curry (index, buffer)-> |
| 30 | + String.fromCharCode nth index, buffer |
29 | 31 |
|
30 |
| - file_path: R.pipe buffer_to_ascii, swap_slashes |
| 32 | + file_path: pipe buffer_to_ascii, swap_slashes |
31 | 33 |
|
32 |
| - float: R.invoker 1, 'readFloatLE' |
| 34 | + float: invoker 1, 'readFloatLE' |
33 | 35 |
|
34 |
| - int16: R.invoker 1, 'readInt16LE' |
| 36 | + int16: invoker 1, 'readInt16LE' |
35 | 37 |
|
36 |
| - label: (index)-> |
37 |
| - #R.compose buffer_to.ascii, R.apply(R.slice, R.juxt([R.identity, R.add(4)])(index)) |
38 |
| - R.compose buffer_to_ascii, R.slice(index, index + 4) |
| 38 | + label: curry (index, buffer)-> |
| 39 | + compose(buffer_to_ascii, slice(index, index + 4))(buffer) |
| 40 | + # label: pipe(converge(slice, [identity, add(4)]), buffer_to_ascii) |
| 41 | + # label: compose(buffer_to_ascii, converge(slice, [identity, add(4)])) |
39 | 42 |
|
40 |
| - uint8: R.invoker 1, 'readUInt8' |
| 43 | + uint8: invoker 1, 'readUInt8' |
41 | 44 |
|
42 |
| - uint16: R.invoker 1, 'readUInt16LE' |
| 45 | + uint16: invoker 1, 'readUInt16LE' |
43 | 46 |
|
44 |
| - uint32: R.invoker 1, 'readUInt32LE' |
| 47 | + uint32: invoker 1, 'readUInt32LE' |
0 commit comments