@effectionx/tinyexec
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

tinyexec

Effection compatible wrapper around tinyexec package.


To run a process, use the x function:

import { x } from "@effectionx/tinyexec";
import { each, main } from "effection";

await main(function* () {
  let proc = yield* x("echo", ["Hello, World"]);

  for (let line of yield* each(proc.lines)) {
    console.log(line);
    yield* each.next();
  }
});
// => prints "Hello, World"

The process will be automatically destroyed whenever it passes out of scope. For example, the following shows the output of the top command for five seconds before exiting.

import { x } from "@effectionx/tinyexec";
import { each, main, sleep, spawn } from "effection";

await main(function* () {
  yield* spawn(function* () {
    let proc = yield* x("top");

    for (let line of yield* each(proc.lines)) {
      console.log(line);
      yield* each.next();
    }
  });

  yield* sleep(5000);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @effectionx/tinyexec

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

7.99 kB

Total Files

16

Last publish

Collaborators

  • frontsidejack