worldstate-emitter 2.2.12 → 2.3.0
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 +252 -60
- package/dist/index.d.mts +56 -0
- package/dist/index.mjs +14645 -0
- package/package.json +43 -18
- package/.babelrc.json +0 -4
- package/.commitlintrc.yml +0 -5
- package/.eslintignore +0 -5
- package/.eslintrc.yml +0 -9
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.lintstagedrc.yml +0 -9
- package/.mocharc.yml +0 -3
- package/.nvmrc +0 -1
- package/.nycrc.yml +0 -4
- package/.prettierrc +0 -1
- package/.releaserc.yml +0 -1
- package/SECURITY.md +0 -17
- package/handlers/RSS.js +0 -66
- package/handlers/Twitter.js +0 -169
- package/handlers/Worldstate.js +0 -154
- package/handlers/events/arrayLike.js +0 -27
- package/handlers/events/checkOverrides.js +0 -17
- package/handlers/events/cycleLike.js +0 -38
- package/handlers/events/eKeyOverrides.js +0 -40
- package/handlers/events/kuva.js +0 -31
- package/handlers/events/nightwave.js +0 -35
- package/handlers/events/objectLike.js +0 -17
- package/handlers/events/parse.js +0 -82
- package/index.js +0 -96
- package/nodemon.json +0 -9
- package/resources/config.js +0 -8
- package/resources/rssFeeds.json +0 -129
- package/resources/tweeters.json +0 -17
- package/utilities/Cache.js +0 -61
- package/utilities/WSCache.js +0 -96
- package/utilities/env.js +0 -10
- package/utilities/index.js +0 -79
package/utilities/index.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { transports, createLogger, format } from 'winston';
|
|
2
|
-
|
|
3
|
-
import { LOG_LEVEL } from './env.js';
|
|
4
|
-
|
|
5
|
-
let tempLogger;
|
|
6
|
-
try {
|
|
7
|
-
const { combine, label, printf, colorize } = format;
|
|
8
|
-
|
|
9
|
-
/* Logger setup */
|
|
10
|
-
const transport = new transports.Console();
|
|
11
|
-
const logFormat = printf((info) => `[${info.label}] ${info.level}: ${info.message}`);
|
|
12
|
-
tempLogger = createLogger({
|
|
13
|
-
format: combine(colorize(), label({ label: 'WS'.brightBlue }), logFormat),
|
|
14
|
-
transports: [transport],
|
|
15
|
-
});
|
|
16
|
-
tempLogger.level = LOG_LEVEL;
|
|
17
|
-
} catch (e) {
|
|
18
|
-
tempLogger = console;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const logger = tempLogger;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Group an array by a field value
|
|
25
|
-
* @param {Object[]} array array of objects to broup
|
|
26
|
-
* @param {string} field field to group by
|
|
27
|
-
* @returns {Object} [description]
|
|
28
|
-
*/
|
|
29
|
-
export const groupBy = (array, field) => {
|
|
30
|
-
const grouped = {};
|
|
31
|
-
if (!array) return undefined;
|
|
32
|
-
array.forEach((item) => {
|
|
33
|
-
const fVal = item[field];
|
|
34
|
-
if (!grouped[fVal]) {
|
|
35
|
-
grouped[fVal] = [];
|
|
36
|
-
}
|
|
37
|
-
grouped[fVal].push(item);
|
|
38
|
-
});
|
|
39
|
-
return grouped;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const allowedDeviation = 30000;
|
|
43
|
-
/**
|
|
44
|
-
* Validate that b is between a and c
|
|
45
|
-
* @param {Date} a The first Date, should be the last time things were updated
|
|
46
|
-
* @param {Date} b The second Date, should be the activation time of an event
|
|
47
|
-
* @param {Date} c The third Date, should be the start time of this update cycle
|
|
48
|
-
* @returns {boolean} if the event date is between the server start time and the last update time
|
|
49
|
-
*/
|
|
50
|
-
export const between = (a, b, c = new Date()) => b + allowedDeviation > a && b - allowedDeviation < c;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns the number of milliseconds between now and a given date
|
|
54
|
-
* @param {string} d The date from which the current time will be subtracted
|
|
55
|
-
* @param {function} [now] A function that returns the current UNIX time in milliseconds
|
|
56
|
-
* @returns {number}
|
|
57
|
-
*/
|
|
58
|
-
export function fromNow(d, now = Date.now) {
|
|
59
|
-
return new Date(d).getTime() - now();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Map of last updated dates/times
|
|
64
|
-
* @type {Object}
|
|
65
|
-
*/
|
|
66
|
-
export const lastUpdated = {
|
|
67
|
-
pc: {
|
|
68
|
-
en: 0, // Date.now(),
|
|
69
|
-
},
|
|
70
|
-
ps4: {
|
|
71
|
-
en: Date.now(),
|
|
72
|
-
},
|
|
73
|
-
xb1: {
|
|
74
|
-
en: Date.now(),
|
|
75
|
-
},
|
|
76
|
-
swi: {
|
|
77
|
-
en: Date.now(),
|
|
78
|
-
},
|
|
79
|
-
};
|