1.2.0 • Published 5 years ago

deasync-ipc v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

deasync-ipc

npm

A filesystem-based Node.js IPC, where the server can provide syncronous or asynchronous functions, both to be called synchronously in the client side.

Synchronous IPC is poor design. Do not use this package, unless you have extremely special needs, like polyfilling synchronous native calls based on alert() and prompt() in an Electron WebView.


一个基于文件系统的 Node.js IPC,服务端可提供同步或异步函数,客户端可以全同步调用。

同步 IPC 是糟糕的设计,不要使用这个库,除非你有极其特殊的需求,比如在 Electron WebView 中对基于 alert()prompt() 的同步通信进行 polyfill。

Example

const { Server } = require('deasync-ipc');

new Server('/path/to/lockfile.lock', {
  async add(a, b) {
    return new Promise((resolve, reject) => {
      setTimeout(() => resolve(a + b), 1000);
    });
  }
}).start();

Meanwhile, in a separate process:

const { Client } = require('deasync-ipc');

// Will blocks for 1 second and prints 3
console.log(new Client('/path/to/lockfile.lock').add(1, 2));
1.2.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago