@statengine/siamese 0.0.19 → 0.0.21
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/.babelrc +5 -5
- package/.eslintrc +18 -18
- package/LICENSE +674 -674
- package/README.md +18 -18
- package/lib/helpers.js +3 -3
- package/package.json +42 -42
- package/src/helpers.js +49 -49
- package/src/index.js +358 -358
- package/src/priorityDispatchCodes.js +985 -985
- package/test/test.helpers.js +487 -487
- package/test/test.js +114 -114
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# siamese
|
|
2
|
-
|
|
3
|
-
Pluggable library to help transform public safety data into standardized schemas.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Using npm:
|
|
8
|
-
```
|
|
9
|
-
npm install @statengine/siamese
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Tests
|
|
13
|
-
To run the test suite, first install the dependencies, then run `npm test`:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install
|
|
17
|
-
npm test
|
|
18
|
-
```
|
|
1
|
+
# siamese
|
|
2
|
+
|
|
3
|
+
Pluggable library to help transform public safety data into standardized schemas.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Using npm:
|
|
8
|
+
```
|
|
9
|
+
npm install @statengine/siamese
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Tests
|
|
13
|
+
To run the test suite, first install the dependencies, then run `npm test`:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install
|
|
17
|
+
npm test
|
|
18
|
+
```
|
package/lib/helpers.js
CHANGED
|
@@ -20,9 +20,9 @@ var PRIORITY_DISPATCH_REGEX = /([0-9]+?)([ABCDEO])([0-9a-z]*)/;
|
|
|
20
20
|
var SUBDETERMINATE_REGEX = /([0-9]+)([a-z]*)/;
|
|
21
21
|
|
|
22
22
|
function split(code) {
|
|
23
|
-
/**
|
|
24
|
-
* @param {string} code - Priority dispatch code (eg: 32B).
|
|
25
|
-
* https://wiki.radioreference.com/index.php/Priority_Dispatch_Codes
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} code - Priority dispatch code (eg: 32B).
|
|
25
|
+
* https://wiki.radioreference.com/index.php/Priority_Dispatch_Codes
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
var check = code.match(PRIORITY_DISPATCH_REGEX);
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@statengine/siamese",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Normalizes public safety data.",
|
|
5
|
-
"main": "lib",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"lint": "node_modules/eslint/bin/eslint.js src/** test/**",
|
|
8
|
-
"test": "mocha --require babel-register ./test/*.js",
|
|
9
|
-
"compile": "babel --presets env -d lib/ src/ --copy-files",
|
|
10
|
-
"prepare": "npm run compile"
|
|
11
|
-
},
|
|
12
|
-
"repository": "https://github.com/StatEngine/siamese.git",
|
|
13
|
-
"author": "Prominent Edge",
|
|
14
|
-
"license": "GPL-3.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"babel-cli": "^6.24.1",
|
|
17
|
-
"babel-polyfill": "^6.26.0",
|
|
18
|
-
"babel-preset-env": "^1.6.0",
|
|
19
|
-
"babel-register": "^6.24.1",
|
|
20
|
-
"babel-tap": "^5.0.0",
|
|
21
|
-
"chai": "4.1.0",
|
|
22
|
-
"eslint": "^5.3.0",
|
|
23
|
-
"eslint-config-airbnb": "^17.1.0",
|
|
24
|
-
"eslint-plugin-import": "^2.16.0",
|
|
25
|
-
"eslint-plugin-jsx-a11y": "^6.2.0",
|
|
26
|
-
"eslint-plugin-react": "^7.12.4",
|
|
27
|
-
"mocha": "4.1.0"
|
|
28
|
-
},
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"@statengine/schemas": "latest",
|
|
31
|
-
"@statengine/shiftly": "^0.0.
|
|
32
|
-
"ajv": "^5.5.2",
|
|
33
|
-
"bluebird": "^3.5.3",
|
|
34
|
-
"jsonschema": "^1.1.1",
|
|
35
|
-
"lodash": "^4.17.20",
|
|
36
|
-
"moment": "^2.24.0",
|
|
37
|
-
"moment-timezone": "^0.5.23",
|
|
38
|
-
"ngeohash": "^0.6.3",
|
|
39
|
-
"proj4": "^2.5.0",
|
|
40
|
-
"xml2js": "^0.4.19"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@statengine/siamese",
|
|
3
|
+
"version": "0.0.21",
|
|
4
|
+
"description": "Normalizes public safety data.",
|
|
5
|
+
"main": "lib",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "node_modules/eslint/bin/eslint.js src/** test/**",
|
|
8
|
+
"test": "mocha --require babel-register ./test/*.js",
|
|
9
|
+
"compile": "babel --presets env -d lib/ src/ --copy-files",
|
|
10
|
+
"prepare": "npm run compile"
|
|
11
|
+
},
|
|
12
|
+
"repository": "https://github.com/StatEngine/siamese.git",
|
|
13
|
+
"author": "Prominent Edge",
|
|
14
|
+
"license": "GPL-3.0",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"babel-cli": "^6.24.1",
|
|
17
|
+
"babel-polyfill": "^6.26.0",
|
|
18
|
+
"babel-preset-env": "^1.6.0",
|
|
19
|
+
"babel-register": "^6.24.1",
|
|
20
|
+
"babel-tap": "^5.0.0",
|
|
21
|
+
"chai": "4.1.0",
|
|
22
|
+
"eslint": "^5.3.0",
|
|
23
|
+
"eslint-config-airbnb": "^17.1.0",
|
|
24
|
+
"eslint-plugin-import": "^2.16.0",
|
|
25
|
+
"eslint-plugin-jsx-a11y": "^6.2.0",
|
|
26
|
+
"eslint-plugin-react": "^7.12.4",
|
|
27
|
+
"mocha": "4.1.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@statengine/schemas": "latest",
|
|
31
|
+
"@statengine/shiftly": "^0.0.114",
|
|
32
|
+
"ajv": "^5.5.2",
|
|
33
|
+
"bluebird": "^3.5.3",
|
|
34
|
+
"jsonschema": "^1.1.1",
|
|
35
|
+
"lodash": "^4.17.20",
|
|
36
|
+
"moment": "^2.24.0",
|
|
37
|
+
"moment-timezone": "^0.5.23",
|
|
38
|
+
"ngeohash": "^0.6.3",
|
|
39
|
+
"proj4": "^2.5.0",
|
|
40
|
+
"xml2js": "^0.4.19"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/helpers.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
|
-
import CODES from './priorityDispatchCodes';
|
|
3
|
-
|
|
4
|
-
const PRIORITY_DISPATCH_REGEX = /([0-9]+?)([ABCDEO])([0-9a-z]*)/;
|
|
5
|
-
const SUBDETERMINATE_REGEX = /([0-9]+)([a-z]*)/;
|
|
6
|
-
|
|
7
|
-
function split(code) {
|
|
8
|
-
/**
|
|
9
|
-
* @param {string} code - Priority dispatch code (eg: 32B).
|
|
10
|
-
* https://wiki.radioreference.com/index.php/Priority_Dispatch_Codes
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const check = code.match(PRIORITY_DISPATCH_REGEX);
|
|
14
|
-
|
|
15
|
-
if (!check) {
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const [, protocol, determinate, subDeterminate] = check;
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
protocol,
|
|
23
|
-
determinate,
|
|
24
|
-
subDeterminate,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getProtocolDescription(protocol) {
|
|
29
|
-
if (protocol) {
|
|
30
|
-
return _.get(CODES, `[${Number(protocol).toString()}]description`);
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getSubDeterminateDescription(protocol, determinate, subDeterminate) {
|
|
36
|
-
if (protocol && determinate && subDeterminate) {
|
|
37
|
-
const [, noSuffix] = subDeterminate.toString().match(SUBDETERMINATE_REGEX);
|
|
38
|
-
return _.get(CODES, `[${Number(protocol).toString()}]determinates[${determinate}]subdeterminants[${Number(noSuffix).toString()}.description]`);
|
|
39
|
-
}
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
priorityDispatch: {
|
|
45
|
-
split,
|
|
46
|
-
getProtocolDescription,
|
|
47
|
-
getSubDeterminateDescription,
|
|
48
|
-
},
|
|
49
|
-
};
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import CODES from './priorityDispatchCodes';
|
|
3
|
+
|
|
4
|
+
const PRIORITY_DISPATCH_REGEX = /([0-9]+?)([ABCDEO])([0-9a-z]*)/;
|
|
5
|
+
const SUBDETERMINATE_REGEX = /([0-9]+)([a-z]*)/;
|
|
6
|
+
|
|
7
|
+
function split(code) {
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} code - Priority dispatch code (eg: 32B).
|
|
10
|
+
* https://wiki.radioreference.com/index.php/Priority_Dispatch_Codes
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const check = code.match(PRIORITY_DISPATCH_REGEX);
|
|
14
|
+
|
|
15
|
+
if (!check) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const [, protocol, determinate, subDeterminate] = check;
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
protocol,
|
|
23
|
+
determinate,
|
|
24
|
+
subDeterminate,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getProtocolDescription(protocol) {
|
|
29
|
+
if (protocol) {
|
|
30
|
+
return _.get(CODES, `[${Number(protocol).toString()}]description`);
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getSubDeterminateDescription(protocol, determinate, subDeterminate) {
|
|
36
|
+
if (protocol && determinate && subDeterminate) {
|
|
37
|
+
const [, noSuffix] = subDeterminate.toString().match(SUBDETERMINATE_REGEX);
|
|
38
|
+
return _.get(CODES, `[${Number(protocol).toString()}]determinates[${determinate}]subdeterminants[${Number(noSuffix).toString()}.description]`);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default {
|
|
44
|
+
priorityDispatch: {
|
|
45
|
+
split,
|
|
46
|
+
getProtocolDescription,
|
|
47
|
+
getSubDeterminateDescription,
|
|
48
|
+
},
|
|
49
|
+
};
|