timing-provider-server 3.0.7 → 3.0.10

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.
@@ -1,43 +1,41 @@
1
1
  #!/usr/bin/env node
2
- import { generateUniqueNumber } from 'fast-unique-numbers';
3
2
  import { argv } from 'process';
3
+ import { generateUniqueNumber } from 'fast-unique-numbers';
4
4
  import { WebSocketServer } from 'ws';
5
5
  import yargs from 'yargs';
6
- (async () => {
7
- const commandLineArguments = yargs(argv.slice(2))
8
- .help()
9
- .option('port', {
10
- default: 2276,
11
- describe: 'specify the port at which the server will be listening',
12
- type: 'number'
13
- })
14
- .strict().argv;
15
- if (commandLineArguments instanceof Promise) {
16
- throw new Error('The command line arguments are expected to get parsed synchronously.');
17
- }
18
- const { port } = commandLineArguments;
19
- const activeConnections = new Map();
20
- const server = new WebSocketServer({ port });
21
- server.on('connection', (connection) => {
22
- const id = generateUniqueNumber(activeConnections);
23
- const sendMessage = (message) => connection.send(JSON.stringify(message));
24
- activeConnections.set(id, sendMessage);
25
- connection.on('message', (message) => {
26
- const parsedMessage = JSON.parse(message.toString());
27
- const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
28
- if (sendMessageToActiveConnection !== undefined) {
29
- sendMessageToActiveConnection({ client: { id }, message: parsedMessage.message });
30
- }
31
- });
32
- connection.on('close', () => activeConnections.delete(id));
33
- for (const activeConnection of activeConnections) {
34
- if (activeConnection[0] !== id) {
35
- const label = [id, activeConnection[0]].sort().join('-');
36
- const type = 'request';
37
- sendMessage({ message: { isActive: true, label, mask: { client: { id: activeConnection[0] } } }, type });
38
- activeConnection[1]({ message: { isActive: false, mask: { client: { id } } }, type });
39
- }
6
+ const commandLineArguments = yargs(argv.slice(2))
7
+ .help()
8
+ .option('port', {
9
+ default: 2276,
10
+ describe: 'specify the port at which the server will be listening',
11
+ type: 'number'
12
+ })
13
+ .strict().argv;
14
+ if (commandLineArguments instanceof Promise) {
15
+ throw new TypeError('The command line arguments are expected to get parsed synchronously.');
16
+ }
17
+ const { port } = commandLineArguments;
18
+ const activeConnections = new Map();
19
+ const server = new WebSocketServer({ port });
20
+ server.on('connection', (connection) => {
21
+ const id = generateUniqueNumber(activeConnections);
22
+ const sendMessage = (message) => connection.send(JSON.stringify(message));
23
+ activeConnections.set(id, sendMessage);
24
+ connection.on('message', (message) => {
25
+ const parsedMessage = JSON.parse(message.toString());
26
+ const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
27
+ if (sendMessageToActiveConnection !== undefined) {
28
+ sendMessageToActiveConnection({ client: { id }, message: parsedMessage.message });
40
29
  }
41
30
  });
42
- })();
31
+ connection.on('close', () => activeConnections.delete(id));
32
+ for (const activeConnection of activeConnections) {
33
+ if (activeConnection[0] !== id) {
34
+ const label = [id, activeConnection[0]].sort().join('-');
35
+ const type = 'request';
36
+ sendMessage({ message: { isActive: true, label, mask: { client: { id: activeConnection[0] } } }, type });
37
+ activeConnection[1]({ message: { isActive: false, mask: { client: { id } } }, type });
38
+ }
39
+ }
40
+ });
43
41
  //# sourceMappingURL=app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,CAAC,KAAK,IAAI,EAAE;IACR,MAAM,oBAAoB,GAAuC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE;SACjF,IAAI,EAAE;SACN,MAAM,CAAC,MAAM,EAAE;QACZ,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,wDAAwD;QAClE,IAAI,EAAE,QAAQ;KACjB,CAAC;SACD,MAAM,EAAE,CAAC,IAAI,CAAC;IAEnB,I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,CAAC;YACzD,MAAM,IAAI,GAAG,SAAS,CAAC;YAEvB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YACzG,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;SACzF;KACJ;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './command-line-arguments';
1
+ export * from './command-line-arguments.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './command-line-arguments';
1
+ export * from './command-line-arguments.js';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
package/build/node/app.js CHANGED
@@ -1,76 +1,73 @@
1
1
  #!/usr/bin/env node
2
- import { generateUniqueNumber } from 'fast-unique-numbers';
3
2
  import { argv } from 'process';
3
+ import { generateUniqueNumber } from 'fast-unique-numbers';
4
4
  import { WebSocketServer } from 'ws';
5
5
  import yargs from 'yargs';
6
+ const commandLineArguments = yargs(argv.slice(2)).help().option('port', {
7
+ default: 2276,
8
+ describe: 'specify the port at which the server will be listening',
9
+ type: 'number'
10
+ }).strict().argv;
6
11
 
7
- (async () => {
8
- const commandLineArguments = yargs(argv.slice(2)).help().option('port', {
9
- default: 2276,
10
- describe: 'specify the port at which the server will be listening',
11
- type: 'number'
12
- }).strict().argv;
12
+ if (commandLineArguments instanceof Promise) {
13
+ throw new TypeError('The command line arguments are expected to get parsed synchronously.');
14
+ }
13
15
 
14
- if (commandLineArguments instanceof Promise) {
15
- throw new Error('The command line arguments are expected to get parsed synchronously.');
16
- }
17
-
18
- const {
19
- port
20
- } = commandLineArguments;
21
- const activeConnections = new Map();
22
- const server = new WebSocketServer({
23
- port
24
- });
25
- server.on('connection', connection => {
26
- const id = generateUniqueNumber(activeConnections);
16
+ const {
17
+ port
18
+ } = commandLineArguments;
19
+ const activeConnections = new Map();
20
+ const server = new WebSocketServer({
21
+ port
22
+ });
23
+ server.on('connection', connection => {
24
+ const id = generateUniqueNumber(activeConnections);
27
25
 
28
- const sendMessage = message => connection.send(JSON.stringify(message));
26
+ const sendMessage = message => connection.send(JSON.stringify(message));
29
27
 
30
- activeConnections.set(id, sendMessage);
31
- connection.on('message', message => {
32
- const parsedMessage = JSON.parse(message.toString());
33
- const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
28
+ activeConnections.set(id, sendMessage);
29
+ connection.on('message', message => {
30
+ const parsedMessage = JSON.parse(message.toString());
31
+ const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
34
32
 
35
- if (sendMessageToActiveConnection !== undefined) {
36
- sendMessageToActiveConnection({
37
- client: {
38
- id
39
- },
40
- message: parsedMessage.message
41
- });
42
- }
43
- });
44
- connection.on('close', () => activeConnections.delete(id));
33
+ if (sendMessageToActiveConnection !== undefined) {
34
+ sendMessageToActiveConnection({
35
+ client: {
36
+ id
37
+ },
38
+ message: parsedMessage.message
39
+ });
40
+ }
41
+ });
42
+ connection.on('close', () => activeConnections.delete(id));
45
43
 
46
- for (const activeConnection of activeConnections) {
47
- if (activeConnection[0] !== id) {
48
- const label = [id, activeConnection[0]].sort().join('-');
49
- const type = 'request';
50
- sendMessage({
51
- message: {
52
- isActive: true,
53
- label,
54
- mask: {
55
- client: {
56
- id: activeConnection[0]
57
- }
44
+ for (const activeConnection of activeConnections) {
45
+ if (activeConnection[0] !== id) {
46
+ const label = [id, activeConnection[0]].sort().join('-');
47
+ const type = 'request';
48
+ sendMessage({
49
+ message: {
50
+ isActive: true,
51
+ label,
52
+ mask: {
53
+ client: {
54
+ id: activeConnection[0]
58
55
  }
59
- },
60
- type
61
- });
62
- activeConnection[1]({
63
- message: {
64
- isActive: false,
65
- mask: {
66
- client: {
67
- id
68
- }
56
+ }
57
+ },
58
+ type
59
+ });
60
+ activeConnection[1]({
61
+ message: {
62
+ isActive: false,
63
+ mask: {
64
+ client: {
65
+ id
69
66
  }
70
- },
71
- type
72
- });
73
- }
67
+ }
68
+ },
69
+ type
70
+ });
74
71
  }
75
- });
76
- })();
72
+ }
73
+ });
@@ -1 +1 @@
1
- export * from './command-line-arguments';
1
+ export * from './command-line-arguments.js';
package/package.json CHANGED
@@ -18,37 +18,35 @@
18
18
  }
19
19
  ],
20
20
  "dependencies": {
21
- "fast-unique-numbers": "^6.0.11",
21
+ "fast-unique-numbers": "^6.0.13",
22
22
  "tslib": "^2.3.1",
23
23
  "typescript": "^4.5.5",
24
- "ws": "^8.4.2",
24
+ "ws": "^8.5.0",
25
25
  "yargs": "^17.3.1"
26
26
  },
27
27
  "description": "A command line tool to spin up a server which can be used with the timing-provider.",
28
28
  "devDependencies": {
29
- "@babel/cli": "^7.16.8",
30
- "@babel/core": "^7.16.10",
29
+ "@babel/cli": "^7.17.6",
30
+ "@babel/core": "^7.17.5",
31
31
  "@babel/preset-env": "^7.16.11",
32
- "@babel/register": "^7.16.9",
33
- "@commitlint/cli": "^16.1.0",
34
- "@commitlint/config-angular": "^16.0.0",
35
- "@types/ws": "^8.2.2",
32
+ "@babel/register": "^7.17.0",
33
+ "@commitlint/cli": "^16.2.1",
34
+ "@commitlint/config-angular": "^16.2.1",
35
+ "@types/ws": "^8.5.1",
36
36
  "@types/yargs": "^17.0.8",
37
- "chai": "^4.3.4",
37
+ "chai": "^4.3.6",
38
38
  "commitizen": "^4.2.4",
39
39
  "cz-conventional-changelog": "^3.3.0",
40
- "eslint": "^8.7.0",
41
- "eslint-config-holy-grail": "^51.0.0",
40
+ "eslint": "^8.10.0",
41
+ "eslint-config-holy-grail": "^52.0.2",
42
42
  "husky": "^7.0.4",
43
- "mocha": "^9.1.4",
43
+ "mocha": "^9.2.1",
44
44
  "prettier": "^2.5.1",
45
45
  "pretty-quick": "^3.1.3",
46
46
  "rimraf": "^3.0.2",
47
47
  "sinon": "^12.0.1",
48
48
  "sinon-chai": "^3.7.0",
49
- "tsconfig-holy-grail": "^11.1.24",
50
- "tslint": "^6.1.3",
51
- "tslint-config-holy-grail": "^53.2.26"
49
+ "tsconfig-holy-grail": "^11.1.27"
52
50
  },
53
51
  "engines": {
54
52
  "node": ">=12.20.1"
@@ -77,7 +75,7 @@
77
75
  "build": "rimraf build/* && tsc --project src/tsconfig.json && babel ./build/es2020 --config-file ./config/babel/build.json --out-dir ./build/node",
78
76
  "lint": "npm run lint:config && npm run lint:src && npm run lint:test",
79
77
  "lint:config": "eslint --config config/eslint/config.json --ext .js --report-unused-disable-directives config/",
80
- "lint:src": "tslint --config config/tslint/src.json --project src/tsconfig.json src/*.ts src/**/*.ts",
78
+ "lint:src": "eslint --config config/eslint/src.json --ext .ts --report-unused-disable-directives src/",
81
79
  "lint:test": "eslint --config config/eslint/test.json --ext .js --report-unused-disable-directives test/",
82
80
  "prepare": "husky install",
83
81
  "prepublishOnly": "npm run build",
@@ -87,5 +85,5 @@
87
85
  "test:unit": "if [ \"$TYPE\" = \"\" -o \"$TYPE\" = \"unit\" ]; then mocha --bail --parallel --recursive --require config/mocha/config-unit.js test/unit; fi"
88
86
  },
89
87
  "type": "module",
90
- "version": "3.0.7"
88
+ "version": "3.0.10"
91
89
  }
package/src/app.ts CHANGED
@@ -1,55 +1,52 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { generateUniqueNumber } from 'fast-unique-numbers';
4
3
  import { argv } from 'process';
4
+ import { generateUniqueNumber } from 'fast-unique-numbers';
5
5
  import { WebSocketServer } from 'ws';
6
6
  import yargs from 'yargs';
7
7
  import { ICommandLineArguments } from './interfaces';
8
8
 
9
- (async () => {
10
- const commandLineArguments = (<yargs.Argv<ICommandLineArguments>>yargs(argv.slice(2)))
11
- .help()
12
- .option('port', {
13
- default: 2276,
14
- describe: 'specify the port at which the server will be listening',
15
- type: 'number'
16
- })
17
- .strict().argv;
18
-
19
- if (commandLineArguments instanceof Promise) {
20
- throw new Error('The command line arguments are expected to get parsed synchronously.');
21
- }
9
+ const commandLineArguments = (<yargs.Argv<ICommandLineArguments>>yargs(argv.slice(2)))
10
+ .help()
11
+ .option('port', {
12
+ default: 2276,
13
+ describe: 'specify the port at which the server will be listening',
14
+ type: 'number'
15
+ })
16
+ .strict().argv;
22
17
 
23
- const { port } = commandLineArguments;
24
- const activeConnections = new Map<number, (message: object) => void>();
25
- const server = new WebSocketServer({ port });
18
+ if (commandLineArguments instanceof Promise) {
19
+ throw new TypeError('The command line arguments are expected to get parsed synchronously.');
20
+ }
26
21
 
27
- server.on('connection', (connection) => {
28
- const id = generateUniqueNumber(activeConnections);
29
- const sendMessage = (message: object) => connection.send(JSON.stringify(message));
22
+ const { port } = commandLineArguments;
23
+ const activeConnections = new Map<number, (message: object) => void>();
24
+ const server = new WebSocketServer({ port });
30
25
 
31
- activeConnections.set(id, sendMessage);
26
+ server.on('connection', (connection) => {
27
+ const id = generateUniqueNumber(activeConnections);
28
+ const sendMessage = (message: object) => connection.send(JSON.stringify(message));
32
29
 
33
- connection.on('message', (message) => {
34
- const parsedMessage = JSON.parse(message.toString());
30
+ activeConnections.set(id, sendMessage);
35
31
 
36
- const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
32
+ connection.on('message', (message) => {
33
+ const parsedMessage = JSON.parse(message.toString());
34
+ const sendMessageToActiveConnection = activeConnections.get(parsedMessage.client.id);
37
35
 
38
- if (sendMessageToActiveConnection !== undefined) {
39
- sendMessageToActiveConnection({ client: { id }, message: parsedMessage.message });
40
- }
41
- });
36
+ if (sendMessageToActiveConnection !== undefined) {
37
+ sendMessageToActiveConnection({ client: { id }, message: parsedMessage.message });
38
+ }
39
+ });
42
40
 
43
- connection.on('close', () => activeConnections.delete(id));
41
+ connection.on('close', () => activeConnections.delete(id));
44
42
 
45
- for (const activeConnection of activeConnections) {
46
- if (activeConnection[0] !== id) {
47
- const label = [id, activeConnection[0]].sort().join('-');
48
- const type = 'request';
43
+ for (const activeConnection of activeConnections) {
44
+ if (activeConnection[0] !== id) {
45
+ const label = [id, activeConnection[0]].sort().join('-');
46
+ const type = 'request';
49
47
 
50
- sendMessage({ message: { isActive: true, label, mask: { client: { id: activeConnection[0] } } }, type });
51
- activeConnection[1]({ message: { isActive: false, mask: { client: { id } } }, type });
52
- }
48
+ sendMessage({ message: { isActive: true, label, mask: { client: { id: activeConnection[0] } } }, type });
49
+ activeConnection[1]({ message: { isActive: false, mask: { client: { id } } }, type });
53
50
  }
54
- });
55
- })();
51
+ }
52
+ });
@@ -1 +1 @@
1
- export * from './command-line-arguments';
1
+ export * from './command-line-arguments.js';