4.3.6 • Published 1 month ago

data-transport v4.3.6

Weekly downloads
137
License
MIT
Repository
github
Last release
1 month ago

data-transport

Node CI npm version

A simple and responsible transport

Motivation

Many front-end communication APIs based on JavaScript are almost one-way communication, and their communication interface are often different. In terms of communication interaction protocols, we need an universal and responsive communication library that will help us communicate in any scenario very simply and easily.

And It is also very easy to mock to be used for testing, and it is also easy to design an common interface that is compatible with multiple communication APIs.

Support Transport

data-transport is a generic and responsible communication transporter

  • iframe
  • Broadcast
  • Web Worker
  • Service Worker
  • Shared Worker
  • Browser Extension
  • Node.js
  • WebRTC
  • Electron
  • More transport port

Usage

  • Installation
yarn add data-transport
  • Create transport in main page
import { createTransport } from 'data-transport';

const external = createTransport('IFrameMain');
external.listen('hello', async (num) => ({ text: `hello ${num}` }));
  • Create transport in the iframe
import { createTransport } from 'data-transport'

const internal = createTransport('IFrameInternal');
expect(await internal.emit('hello', 42).toEqual({ text: 'hello 42' });

APIs

  • createTransport() Create a transport instance by transport options.

  • mockPorts() Mock ports for testing.

  • merge() Merge multiple transports into one transport.

  • Transport
  • MessageTransport
  • IFrameMainTransport
  • IFrameInternalTransport
  • SharedWorkerClientTransport
  • SharedWorkerInternalTransport
  • ServiceWorkerClientTransport
  • ServiceWorkerServiceTransport
  • WorkerMainTransport
  • WorkerInternalTransport
  • BrowserExtensionsGenericTransport
  • BrowserExtensionsMainTransport
  • BrowserExtensionsClientTransport
  • ElectronMainTransport
  • ElectronRendererTransport
  • WebRTCTransport
  • BroadcastTransport
  • MainProcessTransport
  • ChildProcessTransport

Example

4.3.6

1 month ago

4.3.5

5 months ago

4.2.3

8 months ago

4.2.4

8 months ago

4.3.2

6 months ago

4.3.1

6 months ago

4.3.4

5 months ago

4.3.3

6 months ago

4.3.0

6 months ago

4.2.2

10 months ago

4.2.1

10 months ago

4.2.0

10 months ago

4.1.0

1 year ago

4.1.1

1 year ago

4.0.0

1 year ago

3.3.6

1 year ago

3.3.1

1 year ago

3.3.5

1 year ago

3.3.4

1 year ago

3.3.3

1 year ago

3.3.2

1 year ago

3.2.2

1 year ago

3.2.1

1 year ago

3.1.2

1 year ago

3.2.0

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

2 years ago

2.5.0

2 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.5

3 years ago

2.2.4

3 years ago

2.2.3

3 years ago

2.2.1

3 years ago

2.2.2

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.4.0

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.1.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.3

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago