Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eduardorothdev/rxjs-mqtt

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eduardorothdev/rxjs-mqtt - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

5

dist/index.d.ts
import { IClientOptions, IClientReconnectOptions, ISubscriptionMap, MqttClient, Packet, PacketCallback } from "mqtt";
import { Observable } from "rxjs";
import { MessagePacket } from "@eduardorothdev/rxjs-mqtt/types";
import { typedMessage } from "@eduardorothdev/rxjs-mqtt/parsers";
declare class ObsClient {

@@ -25,5 +26,3 @@ _client: MqttClient;

on(event: string): Observable<MessagePacket>;
onJsonMessage<T>(): Observable<Omit<MessagePacket, "payload"> & {
payload: string | JSON | T;
}>;
onJsonMessage<T>(): Observable<typedMessage<T>>;
once(event: string): Observable<unknown>;

@@ -30,0 +29,0 @@ prependListener(event: string, listener: (...args: any[]) => void): MqttClient;

9

dist/parsers/index.d.ts
import { OperatorFunction } from "rxjs";
import { MessagePacket } from "@eduardorothdev/rxjs-mqtt/types";
declare function parsePayload<T>(parser?: (buffer: Buffer) => T | string): OperatorFunction<MessagePacket, Omit<MessagePacket, "payload"> & {
export type typedMessage<T> = Omit<MessagePacket, "payload"> & {
payload: T | string;
}>;
declare function parsePayloadToJSON<T>(): OperatorFunction<MessagePacket, Omit<MessagePacket, "payload"> & {
payload: string | T | JSON;
}>;
};
declare function parsePayload<T>(parser?: (buffer: Buffer) => T | string): OperatorFunction<MessagePacket, typedMessage<T>>;
declare function parsePayloadToJSON<T>(): OperatorFunction<MessagePacket, typedMessage<T>>;
export { parsePayload, parsePayloadToJSON };
{
"name": "@eduardorothdev/rxjs-mqtt",
"version": "1.0.7",
"version": "1.0.8",
"description": "RxJS wrapper for MQTT. Based on async-mqtt",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -15,3 +15,6 @@ import {

import { MessagePacket } from "@eduardorothdev/rxjs-mqtt/types";
import { parsePayloadToJSON } from "@eduardorothdev/rxjs-mqtt/parsers";
import {
parsePayloadToJSON,
typedMessage,
} from "@eduardorothdev/rxjs-mqtt/parsers";

@@ -18,0 +21,0 @@ class ObsClient {

import { map, OperatorFunction, pipe } from "rxjs";
import { MessagePacket } from "@eduardorothdev/rxjs-mqtt/types";
export type typedMessage<T> = Omit<MessagePacket, "payload"> & {
payload: T | string;
};
function parsePayload<T>(
parser: (buffer: Buffer) => T | string = (buffer: Buffer) =>
buffer.toString(),
): OperatorFunction<
MessagePacket,
Omit<MessagePacket, "payload"> & { payload: T | string }
> {
): OperatorFunction<MessagePacket, typedMessage<T>> {
return pipe(
map((v) => ({
...v,
payload: parser(v.payload),
})),
map(
(v): typedMessage<T> => ({
...v,
payload: parser(v.payload),
}),
),
);
}
function parsePayloadToJSON<T>() {
return parsePayload<T | JSON>((buffer) => JSON.parse(buffer.toString()));
function parsePayloadToJSON<T>(): OperatorFunction<
MessagePacket,
typedMessage<T>
> {
return parsePayload<T>((buffer) => JSON.parse(buffer.toString()));
}
export { parsePayload, parsePayloadToJSON };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc