diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 864a640..3b30be3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -24,19 +24,3 @@ jobs:
- name: Run tests
run: |
npm run test:ci
-
- - name: Coveralls Parallel
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.github_token }}
- parallel: true
-
- coverage:
- needs: test
- runs-on: ubuntu-latest
- steps:
- - name: Coveralls Finished
- uses: coverallsapp/github-action@master
- with:
- github-token: ${{ secrets.GITHUB_TOKEN }}
- parallel-finished: true
diff --git a/.gitignore b/.gitignore
index b8f89b8..4612afc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
# Logs
logs
*.log
+npm-debug.log*
# Runtime data
pids
@@ -17,14 +18,36 @@ coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
-# node-waf configuration
-.lock-wscript
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
-# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
+# Commenting this out is preferred by some people, see
+# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules
+# Users Environment Variables
+.lock-wscript
+.vscode
+*code-workspace
+
+# 0x
+flamegraph.html
+.__*
+profile*
+
+# mac files
+.DS_Store
+
+# vim swap files
+*.swp
+
+# lock files
package-lock.json
+
+# generated code
+test/types/*.js
+test/types/*.map
+
+# test tap report
+out.tap
diff --git a/README.md b/README.md
index eb71dd1..cad12e6 100644
--- a/README.md
+++ b/README.md
@@ -1,20 +1,19 @@
+
# aedes-packet
-![](https://github.com/moscajs/aedes-packet/workflows/ci/badge.svg)
-[![Dependencies Status](https://david-dm.org/moscajs/aedes-packet/status.svg)](https://david-dm.org/moscajs/aedes-packet)
-[![devDependencies Status](https://david-dm.org/moscajs/aedes-packet/dev-status.svg)](https://david-dm.org/moscajs/aedes-packet?type=dev)
-
+
+![ci](https://github.com/moscajs/aedes-packet/workflows/ci/badge.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/moscajs/aedes-packet/badge.svg)](https://snyk.io/test/github/moscajs/aedes-packet)
-[![Coverage Status](https://coveralls.io/repos/moscajs/aedes-packet/badge.svg?branch=master&service=github)](https://coveralls.io/github/moscajs/aedes-packet?branch=master)
+[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\
+[![Dependencies Status](https://david-dm.org/moscajs/aedes-packet/status.svg)](https://david-dm.org/moscajs/aedes-packet)
+[![devDependencies Status](https://david-dm.org/moscajs/aedes-packet/dev-status.svg)](https://david-dm.org/moscajs/aedes-packet?type=dev)\
[![NPM version](https://img.shields.io/npm/v/aedes-packet.svg?style=flat)](https://www.npmjs.com/package/aedes-packet)
[![NPM downloads](https://img.shields.io/npm/dm/aedes-packet.svg?style=flat)](https://www.npmjs.com/package/aedes-packet)
-Basic data structure for packets in [Aedes](http://npm.im/aedes), packaged up for perf and reusability between modules.
+Basic data structure for packets in [Aedes](https://www.npmjs.com/aedes), packaged up for perf and reusability between modules.
See [./packet.js](./packet.js) and [./test.js](./test.js) for
documentation and usage.
-[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
-
## Collaborators
* [__Gnought__](https://github.com/gnought)
diff --git a/package.json b/package.json
index 1ff8d04..859fc77 100644
--- a/package.json
+++ b/package.json
@@ -4,11 +4,14 @@
"description": "Basic data structure for packets in Aedes ",
"main": "packet.js",
"scripts": {
- "lint": "standard --verbose | snazzy",
- "unit": "tape test.js | faucet",
- "test": "npm run lint && npm run unit",
- "coverage": "nyc --reporter=lcov tape test.js",
- "test:ci": "npm run lint && npm run coverage",
+ "lint": "npm run lint:standard && npm run lint:typescript && npm run lint:markdown",
+ "lint:standard": "standard --verbose | snazzy",
+ "lint:typescript": "standard --parser @typescript-eslint/parser --plugin @typescript-eslint/eslint-plugin test/types/*.ts packet.d.ts",
+ "lint:markdown": "markdownlint README.md",
+ "unit": "tap --no-esm -J test.js",
+ "typescript": "tsc --project ./test/types/tsconfig.json",
+ "test": "npm run lint && npm run unit && npm run typescript",
+ "test:ci": "npm run test",
"license-checker": "license-checker --production --onlyAllow='MIT;ISC;BSD-3-Clause;BSD-2-Clause'"
},
"pre-commit": [
@@ -36,14 +39,19 @@
"url": "https://github.com/moscajs/aedes-packet/issues"
},
"homepage": "https://github.com/moscajs/aedes-packet#readme",
- "dependencies": {},
+ "dependencies": {
+ "mqtt-packet": "^6.3.0"
+ },
"devDependencies": {
+ "@types/node": "^12.12.26",
+ "@typescript-eslint/eslint-plugin": "^2.19.0",
+ "@typescript-eslint/parser": "^2.19.0",
"faucet": "0.0.1",
"license-checker": "^25.0.1",
- "nyc": "^15.0.0",
+ "markdownlint-cli": "^0.22.0",
"pre-commit": "^1.2.2",
"snazzy": "^8.0.0",
"standard": "^14.3.1",
- "tape": "^4.13.0"
+ "tap": "^14.10.6"
}
}
diff --git a/packet.d.ts b/packet.d.ts
new file mode 100644
index 0000000..a5f5b2d
--- /dev/null
+++ b/packet.d.ts
@@ -0,0 +1,19 @@
+/* eslint no-unused-vars: 0 */
+/* eslint no-undef: 0 */
+/* eslint space-infix-ops: 0 */
+
+///
+
+import { Packet as IPacket } from 'mqtt-packet'
+
+declare namespace aedes {
+
+ type AedesPacket = IPacket & {
+ brokerId: string
+ brokerCounter: number
+ }
+
+ function Packet(object?: AedesPacket) : aedes.AedesPacket
+}
+
+export = aedes
diff --git a/test.js b/test.js
index 23673ed..fcdeab6 100644
--- a/test.js
+++ b/test.js
@@ -1,6 +1,6 @@
'use strict'
-var test = require('tape')
+var { test } = require('tap')
var Packet = require('./')
test('Packet defaults - PUBLISH, QoS 0', function (t) {
diff --git a/test/types/index.ts b/test/types/index.ts
new file mode 100644
index 0000000..ac736ca
--- /dev/null
+++ b/test/types/index.ts
@@ -0,0 +1,21 @@
+/* eslint no-unused-vars: 0 */
+/* eslint no-undef: 0 */
+
+import { Packet } from '../../packet'
+
+var p = Packet()
+p = Packet({
+ cmd: 'publish',
+ topic: 'hello',
+ payload: Buffer.from('world'),
+ qos: 0,
+ dup: false,
+ retain: false,
+ brokerId: 'afds8f',
+ brokerCounter: 10
+})
+p = Packet({
+ cmd: 'pingresp',
+ brokerId: 'ab7d9',
+ brokerCounter: 3
+})
diff --git a/test/types/tsconfig.json b/test/types/tsconfig.json
new file mode 100644
index 0000000..7914842
--- /dev/null
+++ b/test/types/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "es6",
+ "noEmit": true,
+ "strict": true
+ },
+ "files": [
+ "./index.ts"
+ ]
+}