1010 iterators.
1111- High performance.
1212- Fully usable with TypeScript (3+).
13+ - Compatible with Zeromq 4/5 via "zeromq/v5-compat"
1314
1415## Useful links
1516
@@ -51,14 +52,19 @@ Requirements for using prebuilt binaries:
5152
5253The following platforms have a ** prebuilt binary** available:
5354
55+ - Windows on x86/x86-64
56+
57+ Zeromq binaries on Windows 10 or older need
58+ [ Visual C++ Redistributable] ( https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version )
59+ to be installed.
60+
5461- Linux on x86-64 with libstdc++.so.6.0.21+ (glibc++ 3.4.21+), for example:
5562 - Debian 9+ (Stretch or later)
5663 - Ubuntu 16.04+ (Xenial or later)
5764 - CentOS 8+
5865- Linux on x86-64 with musl, for example:
5966 - Alpine 3.3+
6067- MacOS 10.9+ on x86-64
61- - Windows on x86/x86-64
6268
6369If a prebuilt binary is not available for your platform, installing will attempt
6470to start a build from source.
@@ -161,11 +167,40 @@ macos_deployment_target="10.15"
161167
162168## Examples
163169
164- ** Note:** These examples assume the reader is familiar with ZeroMQ. If you are
165- new to ZeroMQ, please start with the
170+ Here some examples of different features are provided. More examples can be
171+ found in the [ examples directory] ( examples ) .
172+
173+ You can also browse
174+ [ the API reference documentation] ( http://zeromq.github.io/zeromq.js/globals.html )
175+ to see all socket types, methods & options as well as more detailed information
176+ about how to apply them.
177+
178+ ** Note:** If you are new to ZeroMQ, please start with the
166179[ ZeroMQ documentation] ( https://zeromq.org/get-started/ ) .
167180
168- More examples can be found in the [ examples directory] ( examples ) .
181+ ### Basic Usage
182+
183+ ES modules:
184+
185+ ``` typescript
186+ import {Request } from " zeromq"
187+ // or as namespace
188+ import * as zmq from " zeromq"
189+
190+ const reqSock = new Request ()
191+ // ...
192+ const repSock = new zmq .Reply ()
193+ ```
194+
195+ Commonjs:
196+
197+ ``` js
198+ const zmq = require (" zeromq" )
199+
200+ const reqSock = new zmq.Request ()
201+ // ...
202+ const repSock = new zmq.Reply ()
203+ ```
169204
170205### Push/Pull
171206
@@ -177,7 +212,7 @@ how a worker pulls information from the socket.
177212Creates a producer to push information onto a socket.
178213
179214``` js
180- const zmq = require ( " zeromq" )
215+ import * as zmq from " zeromq"
181216
182217async function run () {
183218 const sock = new zmq.Push ()
@@ -201,7 +236,7 @@ run()
201236Creates a worker to pull information from the socket.
202237
203238``` js
204- const zmq = require ( " zeromq" )
239+ import * as zmq from " zeromq"
205240
206241async function run () {
207242 const sock = new zmq.Pull ()
@@ -227,7 +262,7 @@ Publisher/Subscriber, application.
227262Create the publisher which sends messages.
228263
229264``` js
230- const zmq = require ( " zeromq" )
265+ import * as zmq from " zeromq"
231266
232267async function run () {
233268 const sock = new zmq.Publisher ()
@@ -252,7 +287,7 @@ run()
252287Create a subscriber to connect to a publisher's port to receive messages.
253288
254289``` js
255- const zmq = require ( " zeromq" )
290+ import * as zmq from " zeromq"
256291
257292async function run () {
258293 const sock = new zmq.Subscriber ()
@@ -281,7 +316,7 @@ This example illustrates a request from a client and a reply from a server.
281316#### ` client.js `
282317
283318``` js
284- const zmq = require ( " zeromq" )
319+ import * as zmq from " zeromq"
285320
286321async function run () {
287322 const sock = new zmq.Request ()
@@ -301,58 +336,22 @@ run()
301336#### ` server.js `
302337
303338``` js
304- const zmq = require ( " zeromq" )
339+ import * as zmq from " zeromq"
305340
306341async function run () {
307342 const sock = new zmq.Reply ()
308343
309344 await sock .bind (" tcp://127.0.0.1:3000" )
310345
311346 for await (const [msg ] of sock ) {
312- await sock .send (2 * parseInt (msg, 10 ))
347+ await sock .send (( 2 * parseInt (msg . toString () , 10 )). toString ( ))
313348 }
314349}
315350
316351run ()
317352```
318353
319- ## TypeScript
320-
321- This library provides typings for TypeScript version 3.0.x and later.
322-
323- _ Requirements_
324-
325- - For TypeScript version >= 3:
326- - [ compilerOptions] ( https://www.typescriptlang.org/docs/handbook/compiler-options.html )
327- - For TypeScript version < 3.6:
328- - either set ` compilerOptions.target ` to ` esnext ` or later (e.g. ` es2018 ` )
329- - or add the following, or similar, libraries to ` compilerOptions.lib ` (and
330- include their corresponding polyfills if needed): ` es2015 ` ,
331- ` ESNext.AsyncIterable `
332-
333- _ Example Usage_
334-
335- ``` typescript
336- import {Request } from " zeromq"
337- // or as namespace
338- import * as zmq from " zeromq"
339-
340- const reqSock = new Request ()
341- // ...
342- const repSock = new zmq .Reply ()
343- ```
344-
345- ### More examples
346-
347- More advanced examples can be found in the [ examples] ( examples ) directory of
348- this repository.
349-
350- Or you can
351- [ browse the API reference documentation] ( http://zeromq.github.io/zeromq.js/globals.html )
352- to see all socket types, methods & options as well as more detailed information
353- about how to apply them.
354-
355- ### Compatibility layer for version 4/5
354+ ## Zeromq 4 and 5 Compatibility layer
356355
357356The next generation version of the library features a compatibility layer for
358357ZeroMQ.js versions 4 and 5. This is recommended for users upgrading from
@@ -379,6 +378,20 @@ pub.bind("tcp://*:3456", err => {
379378})
380379```
381380
381+ ## TypeScript
382+
383+ This library provides typings for TypeScript version 3.0.x and later.
384+
385+ _ Requirements_
386+
387+ - For TypeScript version >= 3:
388+ - [ compilerOptions] ( https://www.typescriptlang.org/docs/handbook/compiler-options.html )
389+ - For TypeScript version < 3.6:
390+ - either set ` compilerOptions.target ` to ` esnext ` or later (e.g. ` es2018 ` )
391+ - or add the following, or similar, libraries to ` compilerOptions.lib ` (and
392+ include their corresponding polyfills if needed): ` es2015 ` ,
393+ ` ESNext.AsyncIterable `
394+
382395## Contribution
383396
384397If you are interested in making contributions to this project, please read the
0 commit comments