0.0.7 • Published 1 year ago

sever-membrane v0.0.7

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Sever Membrane

Sever Membrane aims to create an Elixir like API to spawn and manage processes in JavaScript.

Sever Membrane works on Browsers only.

Install

npm install sever-membrane

Usage

import { spawn, alive, me } from "sever-membrane"

Spawn a process

// spawn(fn -> 1 + 2 end)
spawn(() => 1 + 2);

Get process id

// pid = spawn(fn -> 1 + 2 end)
const id = spawn(() => 1 + 2);

Use process id

// spawn(fn -> self() == 1 end)
spawn(() => me() === 1);

Check if process is alive

// pid = spawn(fn -> 1 + 2 end)
const id = spawn(() => 1 + 2);

if (alive(id)) {
  // do somenthing...
}

Send message to a process

// pid = spawn(fn -> receive do msg -> IO.puts "Received: #{msg}" end end)
const id id = spawn(() => {
  receive((data) => {
    console.log(me(), "received", data)
  })
})

send(id, "hello")
// send(pid, "hello")
0.0.3

1 year ago

0.0.2

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.1

1 year ago