Skip to content

Commit e6c8a4a

Browse files
committed
docs: export SocketType in the compat layer
1 parent 703f1e1 commit e6c8a4a

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/compat.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const shortOptions = {
5757
connect_timeout: longOptions.ZMQ_CONNECT_TIMEOUT,
5858
}
5959

60-
class Context {
60+
export class Context {
6161
static setMaxThreads(value: number) {
6262
zmq.context.ioThreads = value
6363
}
@@ -79,7 +79,10 @@ class Context {
7979
}
8080
}
8181

82-
type SocketType =
82+
/**
83+
* All the socket types available in the compatibility layer
84+
*/
85+
export type SocketType =
8386
| "pair"
8487
| "req"
8588
| "rep"
@@ -97,7 +100,7 @@ type SocketType =
97100

98101
type Callback = (err?: Error) => void
99102

100-
class Socket extends EventEmitter {
103+
export class Socket extends EventEmitter {
101104
[key: string]: any
102105

103106
type: SocketType
@@ -729,7 +732,7 @@ for (const key in shortOptions) {
729732
})
730733
}
731734

732-
function createSocket(type: SocketType, options: {[key: string]: any} = {}) {
735+
export function createSocket(type: SocketType, options: {[key: string]: any} = {}) {
733736
const sock = new Socket(type)
734737
for (const key in options) {
735738
if (options.hasOwnProperty(key)) {
@@ -739,12 +742,12 @@ function createSocket(type: SocketType, options: {[key: string]: any} = {}) {
739742
return sock
740743
}
741744

742-
function curveKeypair() {
745+
export function curveKeypair() {
743746
const {publicKey, secretKey} = zmq.curveKeyPair()
744747
return {public: publicKey, secret: secretKey}
745748
}
746749

747-
function proxy(frontend: Socket, backend: Socket, capture?: Socket) {
750+
export function proxy(frontend: Socket, backend: Socket, capture?: Socket) {
748751
switch (`${frontend.type}/${backend.type}`) {
749752
case "push/pull":
750753
case "pull/push":
@@ -790,17 +793,10 @@ function proxy(frontend: Socket, backend: Socket, capture?: Socket) {
790793
}
791794
}
792795

793-
const version = zmq.version
796+
export const version = zmq.version
794797

795798
export {
796-
version,
797-
Context,
798-
Socket,
799-
SocketType,
800799
createSocket as socket,
801-
createSocket,
802-
curveKeypair,
803-
proxy,
804800
shortOptions as options,
805801
}
806802

src/native.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@ export declare abstract class Socket {
656656
protected setStringOption(option: number, value: string | Buffer | null): void
657657
}
658658

659+
/**
660+
* Socket types available for creating sockets.
661+
*/
659662
export const enum SocketType {
660663
Pair = 0,
661664
Publisher = 1,

0 commit comments

Comments
 (0)