1 | 'use strict'
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | exports.toString = function (opcode) {
|
9 | switch (opcode) {
|
10 | case 0: return 'QUERY'
|
11 | case 1: return 'IQUERY'
|
12 | case 2: return 'STATUS'
|
13 | case 3: return 'OPCODE_3'
|
14 | case 4: return 'NOTIFY'
|
15 | case 5: return 'UPDATE'
|
16 | case 6: return 'OPCODE_6'
|
17 | case 7: return 'OPCODE_7'
|
18 | case 8: return 'OPCODE_8'
|
19 | case 9: return 'OPCODE_9'
|
20 | case 10: return 'OPCODE_10'
|
21 | case 11: return 'OPCODE_11'
|
22 | case 12: return 'OPCODE_12'
|
23 | case 13: return 'OPCODE_13'
|
24 | case 14: return 'OPCODE_14'
|
25 | case 15: return 'OPCODE_15'
|
26 | }
|
27 | return 'OPCODE_' + opcode
|
28 | }
|
29 |
|
30 | exports.toOpcode = function (code) {
|
31 | switch (code.toUpperCase()) {
|
32 | case 'QUERY': return 0
|
33 | case 'IQUERY': return 1
|
34 | case 'STATUS': return 2
|
35 | case 'OPCODE_3': return 3
|
36 | case 'NOTIFY': return 4
|
37 | case 'UPDATE': return 5
|
38 | case 'OPCODE_6': return 6
|
39 | case 'OPCODE_7': return 7
|
40 | case 'OPCODE_8': return 8
|
41 | case 'OPCODE_9': return 9
|
42 | case 'OPCODE_10': return 10
|
43 | case 'OPCODE_11': return 11
|
44 | case 'OPCODE_12': return 12
|
45 | case 'OPCODE_13': return 13
|
46 | case 'OPCODE_14': return 14
|
47 | case 'OPCODE_15': return 15
|
48 | }
|
49 | return 0
|
50 | }
|