-
Notifications
You must be signed in to change notification settings - Fork 11
/
ads-helpers.js
49 lines (41 loc) · 1.16 KB
/
ads-helpers.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
'use strict'
exports.isTimezoneType = function (adsType) {
return (adsType === "TIME" ||
adsType === "TIME_OF_DAY" ||
adsType === "TOD" ||
adsType === "DATE" ||
adsType === "DATE_AND_TIME" ||
adsType === "DT")
}
exports.isRawType = function (adsType) {
return (adsType === "RAW")
}
exports.isStringType = function (adsType) {
return (adsType === "STRING")
}
exports.isArrayType = function (adsType) {
return (adsType === "ARRAY")
}
exports.checkPort = function (node,port,def) {
if (port < 0x0000 || port > 0xFFFF) {
port = def
node.error("wrong port:",port)
}
}
const connectState = {
ERROR: -1,
DISCONNECTED: 0,
CONNECTING: 1,
CONNECTED: 2,
DISCONNECTING: 3,
fromId: function(id) {
var states = this
var state
Object.keys(states).map(function(key){if (states[key]==id) state=key})
return state
}
}
exports.connectState = connectState
exports.wildcardToRegExp = function (s) {
return new RegExp('^' + s.replace(/[|\\{}()[\]^$+.]/g, '\\$&').replace(/[?]/g, ".").replace(/[*]/g, ".*") + '$')
}