duml-packet
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -7,23 +7,2 @@ "use strict"; | ||
class Packet { | ||
raw; | ||
version; | ||
length; | ||
crcHead; | ||
sourceRaw; | ||
sourceType; | ||
sourceIndex; | ||
destinationRaw; | ||
destinationType; | ||
destinationIndex; | ||
sequenceID; | ||
commandTypeRaw; | ||
commandType; | ||
ackType; | ||
encryptionType; | ||
commandSet; | ||
command; | ||
commandPayload; | ||
crc; | ||
changed; | ||
emitter; | ||
/** | ||
@@ -296,3 +275,9 @@ * | ||
Packet, | ||
GeneralTypes: types_1.GeneralTypes, | ||
DeviceType: types_1.DeviceType, | ||
CommandType: types_1.CommandType, | ||
AckType: types_1.AckType, | ||
EncryptionType: types_1.EncryptionType, | ||
SetType: types_1.SetType, | ||
}; | ||
//# sourceMappingURL=packet.js.map |
{ | ||
"name": "duml-packet", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "For use when parsing and modifying DUML packets for DJI drones", | ||
@@ -9,8 +9,9 @@ "main": "dist/packet.js", | ||
}, | ||
"types": "./dist/packet.d.ts", | ||
"types": "./dist/types.d.ts", | ||
"scripts": { | ||
"arkit": "npx arkit -o docs/arkit.svg", | ||
"lint": "eslint . --ext .ts", | ||
"prettier-format": "prettier --config .prettierrc package.json tsconfig.json './src/**/*.ts' --write", | ||
"prettier-format": "prettier --config .prettierrc package.json tsconfig.json ./src/**/*.ts --write", | ||
"prepare": "tsc", | ||
"prepare:defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly", | ||
"cli": "ts-node dist/cli.js", | ||
@@ -20,3 +21,5 @@ "test": "mocha", | ||
"test:coverage:html": "nyc --reporter=html --reporter=text mocha", | ||
"package": "pkg . --output dumlpacket" | ||
"package": "pkg . --output dumlpacket", | ||
"prepublishOnly": "npm run prepare && npm run prepare:defs", | ||
"postpublish": "rm -r dist" | ||
}, | ||
@@ -23,0 +26,0 @@ "pkg": { |
@@ -0,3 +1,4 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { Packet } from './packet'; | ||
import { AckType, CommandType, DeviceType, EncryptionType, GeneralTypes, SetType } from './types'; | ||
import { AckType, CommandType, DeviceType, EncryptionType, GeneralTypes, SetType } from './packet'; | ||
import { expect } from 'chai'; | ||
@@ -4,0 +5,0 @@ |
@@ -197,3 +197,3 @@ import { EventEmitter } from 'events'; | ||
createPacketProxy(packet: Packet) { | ||
private createPacketProxy(packet: Packet) { | ||
const handler = { | ||
@@ -249,3 +249,3 @@ get: (target: any, propertyName: any, receiver: unknown): unknown => { | ||
*/ | ||
randomSequenceID() { | ||
public randomSequenceID() { | ||
this.sequenceID = Math.floor(Math.random() * 65534) + 1; | ||
@@ -262,3 +262,3 @@ } | ||
*/ | ||
calculatePacket(generate = true) { | ||
private calculatePacket(generate = true) { | ||
if (generate) { | ||
@@ -313,3 +313,3 @@ this.length = 13 + ~~this.commandPayload?.length; | ||
*/ | ||
isValid(): boolean { | ||
public isValid(): boolean { | ||
return ( | ||
@@ -324,3 +324,3 @@ this.crcHead === crc8Wire(this.raw.subarray(0, 3)) && | ||
*/ | ||
toShortString(): string { | ||
public toShortString(): string { | ||
let commandSubType = 'UNKNOWN'; | ||
@@ -345,3 +345,3 @@ if (this.commandSet === SetType.GENERAL && GeneralTypes[this.command]) { | ||
*/ | ||
toLongString(): string { | ||
public toLongString(): string { | ||
let commandSubType = 'UNKNOWN'; | ||
@@ -383,3 +383,3 @@ if (this.commandSet === SetType.GENERAL && GeneralTypes[this.command]) { | ||
*/ | ||
toHexString(): string { | ||
public toHexString(): string { | ||
return this.toBuffer().toString('hex'); | ||
@@ -391,3 +391,3 @@ } | ||
*/ | ||
toBuffer(): Buffer { | ||
public toBuffer(): Buffer { | ||
return this.raw; | ||
@@ -403,3 +403,3 @@ } | ||
*/ | ||
static fromBuffer(buffer: Buffer, autoCalculate = true): Packet { | ||
public static fromBuffer(buffer: Buffer, autoCalculate = true): Packet { | ||
return new Packet({ raw: buffer }, autoCalculate); | ||
@@ -415,3 +415,3 @@ } | ||
*/ | ||
static fromHexString(hexString: string, autoCalculate = true): Packet { | ||
public static fromHexString(hexString: string, autoCalculate = true): Packet { | ||
return new Packet({ raw: Buffer.from(hexString, 'hex') }, autoCalculate); | ||
@@ -423,2 +423,9 @@ } | ||
Packet, | ||
GeneralTypes, | ||
DeviceType, | ||
CommandType, | ||
AckType, | ||
EncryptionType, | ||
SetType, | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"esModuleInterop": true, | ||
"target": "es2022", | ||
"target": "es2021", | ||
"noImplicitAny": true, | ||
@@ -27,3 +27,3 @@ "moduleResolution": "node", | ||
"./node_modules/@types/node/index.d.ts" | ||
] | ||
], | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103689
29
1868