@ton-api/isomorphic-ws
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@ton-api/isomorphic-ws

This package provides WebSocket applicable in different environments (browser & NodeJS).

Get started

npm i @ton-api/isomorphic-ws

How to use

Just import the package and use global WebSocket constructor:

import '@ton-api/isomorphic-ws';

const webSocketInstance = new WebSocket();

That will work in both browser and NodeJS.

How does it work

This package exports an empty script if bundler creates browser-compatible build. When package is imported in NodeJS environment, it assigns an WebSocket imported from the ws package to the global variable.

Note that this package doesn't provide an WebSocket polyfill for browsers which doesn't support WebSocket natively.

Package Sidebar

Install

npm i @ton-api/isomorphic-ws

Weekly Downloads

0

Version

0.0.1

License

GPL-3.0

Unpacked Size

37.2 kB

Total Files

7

Last publish

Collaborators

  • mois-ilya
  • siandreev