4.5.1 • Published 2 months ago

qiao-process v4.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

qiao-process

npm version npm downloads

nodejs 下 process 能力

install

安装

npm i qiao-process

use

使用

// cjs
const { fork } = require('qiao-process');

// mjs
import { fork } from 'qiao-process';

api

fork & kill

// path
const path = require('path');

// q
const { fork, kill } = require('qiao-process');

// test
function test() {
  const jsPath = path.resolve(__dirname, './cp.js');
  const args = ['haha'];

  const cp = fork(
    jsPath,
    args,
    function (msg) {
      console.log(`from child process: ${msg}`);
    },
    function (code) {
      console.log(`exit code: ${code}`);
    },
  );

  cp.send('hello child process');

  // kill cp
  setTimeout(function () {
    kill(cp.pid);
  }, 3000);
}

test();

onMsg & send

// qiao
const { onMsg, send } = require('qiao-process');

onMsg(function (msg) {
  console.log(`from main process: ${msg}`);
});

send('hello main process');
4.5.1

2 months ago

4.4.2

3 months ago

4.2.6

6 months ago

4.0.0

7 months ago

4.3.0

6 months ago

4.1.1

7 months ago

3.4.7

8 months ago

3.1.2

1 year ago

3.1.5

1 year ago

3.2.7

1 year ago

3.1.1

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago