0.4.1 • Published 4 months ago

u8-mqtt-packet v0.4.1

Weekly downloads
1
License
BSD-2-Clause
Repository
github
Last release
4 months ago

u8-mqtt-packet

MQTT packet encoder and decoder using Uint8Array in ES Modules (ESM). Zero dependencies. Tree-shaking friendly. Suited for use in modern ES6 environments: the Browser, NodeJS, and Deno.

Consider u8-mqtt for QOS-0 and QOS-1 MQTT client communications.

Docs

Targeting MQTT-3.1.1 (v4) and MQTT-5.0.0 (v5) compatibility.

Use

import {mqtt_session_v4} from 'u8-mqtt-packet'
const [mqtt_decode, mqtt_encode] = mqtt_session_v4()

const u8_pkt = mqtt_encode('connect', {
  keep_alive: 60,
  flags: 0,
  client_id: 'readme',
})

console.log(u8_pkt)

/*
  Uint8Array(20) [16,18,0,4,77,81,84,84,4,0,0,60,0,6,114,101,97,100,109,101]
*/


console.log(mqtt_decode(u8_pkt))

/*
  [
    {
      b0: 16,
      mqtt_level: 4,
      flags: [Number (_connect_flags_): 0],
      keep_alive: 60,
      client_id: 'readme'
    }
  ]
*/

Module size

modulebrotliminified
u8-mqtt-packet/esm/codec_v4_lean.min.js1700 B4886 B
u8-mqtt-packet/esm/codec_v5_lean.min.js2388 B7010 B
u8-mqtt-packet/esm/index.min.js4144 B14053 B

automated sizing report

MQTT Client sizes

minifeid(x)ProjectMeasurement
187.0KB12xMQTT.jscurl -sL https://cdn.jsdelivr.net/npm/mqtt@4.0.1/dist/mqtt.min.js \| wc -c
32.3KB2xpahocurl -sL https://cdn.jsdelivr.net/npm/paho-mqtt@1.1.0/paho-mqtt.min.js \| wc -c
19.9KB1.3xu8-mqtt v5cat ./u8-mqtt/esm/web/v5.min.js \| wc -c
15.5KB1xu8-mqtt v4cat ./u8-mqtt/esm/web/v4.min.js \| wc -c

Prior Art

The u8-mqtt-packet project was inspired by mqtt-packet written for NodeJS. The codecs of that project are written with a NodeJS ecosystem in mind: Buffer, EventEmitter, Streams.

License

BSD-2-Clause

0.4.1

4 months ago

0.4.0

4 months ago

0.3.5

4 months ago

0.3.4

4 months ago

0.3.2

10 months ago

0.3.3

10 months ago

0.3.0-1

1 year ago

0.3.0

1 year ago

0.3.1

1 year ago

0.2.5

2 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago