atmosx-nwws-parser 1.0.18 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +183 -64
- package/dist/cjs/index.cjs +3799 -0
- package/dist/esm/index.mjs +3757 -0
- package/package.json +49 -29
- package/src/bootstrap.ts +196 -0
- package/src/database.ts +148 -0
- package/src/dictionaries/awips.ts +342 -0
- package/src/dictionaries/events.ts +142 -0
- package/src/dictionaries/icao.ts +237 -0
- package/src/dictionaries/offshore.ts +12 -0
- package/src/dictionaries/signatures.ts +107 -0
- package/src/eas.ts +493 -0
- package/src/index.ts +229 -0
- package/src/parsers/events/api.ts +151 -0
- package/src/parsers/events/cap.ts +138 -0
- package/src/parsers/events/text.ts +106 -0
- package/src/parsers/events/ugc.ts +109 -0
- package/src/parsers/events/vtec.ts +78 -0
- package/src/parsers/events.ts +367 -0
- package/src/parsers/hvtec.ts +46 -0
- package/src/parsers/pvtec.ts +71 -0
- package/src/parsers/stanza.ts +132 -0
- package/src/parsers/text.ts +166 -0
- package/src/parsers/ugc.ts +197 -0
- package/src/types.ts +251 -0
- package/src/utils.ts +314 -0
- package/src/xmpp.ts +144 -0
- package/test.js +61 -32
- package/tsconfig.json +14 -0
- package/tsup.config.ts +14 -0
- package/bootstrap.js +0 -111
- package/index.js +0 -261
- package/src/events.js +0 -336
- package/src/stanza.js +0 -103
- package/src/text.js +0 -108
- package/src/ugc.js +0 -115
- package/src/vtec.js +0 -89
package/src/vtec.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
_ _ __ __
|
|
3
|
-
/\ | | | | (_) \ \ / /
|
|
4
|
-
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
-
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
-
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
-
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
-
| |
|
|
9
|
-
|_|
|
|
10
|
-
|
|
11
|
-
Written by: k3yomi@GitHub
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
let loader = require(`../bootstrap.js`);
|
|
15
|
-
|
|
16
|
-
class NoaaWeatherWireServiceVtec {
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @function getVTEC
|
|
20
|
-
* @description Extracts VTEC information from a message and its attributes.
|
|
21
|
-
* @param {string} message - The message containing VTEC information.
|
|
22
|
-
* @param {object} attributes - The attributes of the message.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
getVTEC = function(message, attributes) {
|
|
26
|
-
let matches = message.match(new RegExp(loader.definitions.expressions.vtec, 'g'));
|
|
27
|
-
if (!matches) return null;
|
|
28
|
-
let vtecs = matches.map(match => {
|
|
29
|
-
let splitVTEC = match.split(`.`);
|
|
30
|
-
let vtecDates = splitVTEC[6].split(`-`);
|
|
31
|
-
return {
|
|
32
|
-
raw: match,
|
|
33
|
-
tracking: this.getTrackingIdentifier(splitVTEC),
|
|
34
|
-
event: this.getEventName(splitVTEC),
|
|
35
|
-
status: this.getEventStatus(splitVTEC),
|
|
36
|
-
wmo: message.match(new RegExp(loader.definitions.expressions.wmo, 'gimu')),
|
|
37
|
-
expires: this.getExpires(vtecDates),
|
|
38
|
-
issued: attributes.issue
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
return vtecs;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @function getTrackingIdentifier
|
|
46
|
-
* @description Constructs a tracking identifier from the VTEC components.
|
|
47
|
-
* @param {Array} args - The components of the VTEC string.
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
getTrackingIdentifier = function(args) {
|
|
51
|
-
return `${args[2]}-${args[3]}-${args[4]}-${args[5]}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @function getEventName
|
|
56
|
-
* @description Constructs a an event name from the VTEC components.
|
|
57
|
-
* @param {Array} args - The components of the VTEC string.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
getEventName = function(args) {
|
|
61
|
-
return `${loader.definitions.events[args[3]]} ${loader.definitions.actions[args[4]]}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @function getEventStatus
|
|
66
|
-
* @description Retrieves the status of the event from the VTEC components. (Issued, Updated, Extended, etc.)
|
|
67
|
-
* @param {Array} args - The components of the VTEC string.
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
getEventStatus = function(args) {
|
|
71
|
-
return loader.definitions.status[args[1]]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @function getExpires
|
|
76
|
-
* @description Converts the VTEC expiration date into a standardized format.
|
|
77
|
-
* @param {Array} args - The components of the VTEC string.
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
getExpires = function(args) {
|
|
81
|
-
if (args[1] == `000000T0000Z`) return `Invalid Date Format`;
|
|
82
|
-
let expires = `${new Date().getFullYear().toString().substring(0, 2)}${args[1].substring(0, 2)}-${args[1].substring(2, 4)}-${args[1].substring(4, 6)}T${args[1].substring(7, 9)}:${args[1].substring(9, 11)}:00`;
|
|
83
|
-
let local = new Date(new Date(expires).getTime() - 4 * 60 * 60000);
|
|
84
|
-
let pad = n => n.toString().padStart(2, '0');
|
|
85
|
-
return `${local.getFullYear()}-${pad(local.getMonth() + 1)}-${pad(local.getDate())}T${pad(local.getHours())}:${pad(local.getMinutes())}:00.000-04:00`;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = new NoaaWeatherWireServiceVtec();
|