Skip to content

Commit af9ec65

Browse files
authored
Merge pull request #6 from Borewit/node-v11
Node v11 tests & codacy code quality
2 parents c4ccdc2 + 9084daa commit af9ec65

File tree

4 files changed

+1619
-214
lines changed

4 files changed

+1619
-214
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ node_js:
55
- "8"
66
- "9"
77
- "10"
8+
- "11"
89
install:
910
- yarn install
1011
- yarn run compile
1112
script:
12-
- yarn run lint
13+
- yarn run lint-ts
14+
- yarn run lint-md
1315
- yarn run test
1416

1517
jobs:

README.md

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,48 @@
33
[![npm downloads](http://img.shields.io/npm/dm/token-types.svg)](https://npmjs.org/package/token-types)
44
[![Dependencies](https://david-dm.org/Borewit/token-types.svg)](https://david-dm.org/Borewit/token-types)
55
[![coveralls](https://coveralls.io/repos/github/Borewit/token-types/badge.svg?branch=master)](https://coveralls.io/github/Borewit/token-types?branch=master)
6-
[![NSP Status](https://nodesecurity.io/orgs/borewit/projects/a193313e-00be-4611-bcba-f68773e5704c/badge)](https://nodesecurity.io/orgs/borewit/projects/a193313e-00be-4611-bcba-f68773e5704c)
6+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4723ce4613fc49cda8db5eed29f18834)](https://www.codacy.com/app/Borewit/token-types?utm_source=github.com&utm_medium=referral&utm_content=Borewit/token-types&utm_campaign=Badge_Grade)
7+
[![Known Vulnerabilities](https://snyk.io/test/github/Borewit/token-types/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/token-types?targetFile=package.json)
78

89
A primitive token library used to read from, and to write a node `Buffer`.
910

1011
### Tokens
1112

1213
`node-strtok` supports a wide variety of numerical tokens out of the box:
1314

14-
* `UINT8`
15-
* `UINT16_BE`, `UINT16_LE`
16-
* `UINT24_BE`, `UINT24_LE`
17-
* `UINT32_BE`, `UINT32_LE`
18-
* `UINT64_BE`, `UINT64_LE` *
19-
* `INT8`
20-
* `INT16_BE`, `INT16_LE`
21-
* `INT24_BE`, `INT24_LE`
22-
* `INT32_BE`, `INT32_LE`
23-
* `INT64_BE`, `UINT64_LE` *
15+
* `UINT8`
16+
* `UINT16_BE`, `UINT16_LE`
17+
* `UINT24_BE`, `UINT24_LE`
18+
* `UINT32_BE`, `UINT32_LE`
19+
* `UINT64_BE`, `UINT64_LE`*
20+
* `INT8`
21+
* `INT16_BE`, `INT16_LE`
22+
* `INT24_BE`, `INT24_LE`
23+
* `INT32_BE`, `INT32_LE`
24+
* `INT64_BE`, `UINT64_LE`*
2425

2526
String types:
26-
* Windows-1252
27-
* ISO-8859-1
28-
29-
*) The 64-bit tokens are best effort based, since JavaScript limit value size to less than 2^64.
30-
31-
[npm-url]: https://npmjs.org/package/token-types
32-
[npm-image]: https://badge.fury.io/js/token-types.svg
33-
[npm-downloads-image]: http://img.shields.io/npm/dm/token-types.svg
34-
35-
[travis-url]: https://travis-ci.org/Borewit/token-types
36-
[travis-image]: https://api.travis-ci.org/Borewit/token-types.svg?branch=master
37-
38-
[coveralls-url]: https://coveralls.io/github/Borewit/token-types?branch=master
39-
[coveralls-image]: https://coveralls.io/repos/github/Borewit/token-types/badge.svg?branch=master
27+
* Windows-1252
28+
* ISO-8859-1
29+
30+
*) The 64-bit tokens are best effort based, since JavaScript limit value size to less than 2^64.
31+
32+
Complex tokens can be added, which makes very suitable for reading binary files or network messages:
33+
```JavaScript
34+
public static ExtendedHeader: Token.IGetToken<IExtendedHeader> = {
35+
len: 10,
36+
37+
get: (buf, off): IExtendedHeader => {
38+
return {
39+
// Extended header size
40+
size: Token.UINT32_BE.get(buf, off),
41+
// Extended Flags
42+
extendedFlags: Token.UINT16_BE.get(buf, off + 4),
43+
// Size of padding
44+
sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),
45+
// CRC data present
46+
crcDataPresent: common.strtokBITSET.get(buf, off + 4, 31)
47+
};
48+
}
49+
};
50+
```

package.json

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77
"url": "https://github.com/Borewit"
88
},
99
"scripts": {
10-
"build": "yarn run compile",
10+
"build": "npm run compile",
1111
"compile-src": "tsc -p src",
1212
"compile-test": "tsc -p test",
13-
"compile": "yarn run compile-src && yarn run compile-test",
14-
"prepare": "yarn run compile",
15-
"lint": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
13+
"compile": "npm run compile-src && npm run compile-test",
14+
"prepare": "npm run compile",
15+
"lint-ts": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
16+
"lint-md": "remark -u preset-lint-recommended .",
17+
"lint": "npm run lint-ts && npm run lint-md",
1618
"test": "mocha --require ts-node/register test",
17-
"cover-test": "nyc yarn run test",
18-
"coveralls": "yarn run cover-test && nyc report --reporter=text-lcov | coveralls"
19+
"cover-test": "nyc npm run test",
20+
"coveralls": "npm run cover-test && nyc report --reporter=text-lcov | coveralls"
1921
},
2022
"engines": {
2123
"node": ">=0.1.98"
@@ -31,17 +33,21 @@
3133
"url": "https://github.com/Borewit/token-types/issues"
3234
},
3335
"devDependencies": {
34-
"@types/chai": "^4.1.4",
36+
"@types/chai": "^4.1.6",
3537
"@types/mocha": "^5.2.5",
36-
"@types/node": "^10.9.4",
37-
"chai": "^4.1.2",
38-
"copyfiles": "^2.0.0",
38+
"@types/node": "^10.12.0",
39+
"chai": "^4.2.0",
3940
"coveralls": "^3.0.2",
4041
"mocha": "^5.2.0",
41-
"nyc": "^13.0.1",
42+
"nyc": "^13.1.0",
43+
"remark-cli": "^6.0.0",
44+
"remark-preset-lint-recommended": "^3.0.2",
4245
"ts-node": "^7.0.1",
4346
"tslint": "^5.11.0",
44-
"typescript": "^3.0.3"
47+
"typescript": "^3.1.3"
4548
},
46-
"dependencies": {}
49+
"dependencies": {},
50+
"remarkConfig": {
51+
"plugins": ["preset-lint-recommended"]
52+
}
4753
}

0 commit comments

Comments
 (0)