koolii / async-subtask

exec async function into child_process using `child_process.fork()`

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[WIP] async-subtask

This module offers interface which execs async function(and promise) in child_process which Node.js has already.

environment

Node.js(x < 8.3.9)

model-case

// example/example0.js
const fetch = require('node-fetch')
const fork = require('async-subtask')

const expression = async (url) => {
  const response = await fetch(url)
  const text = await response.json()
  return text
}

const main = async () => {
  const responseText = await fork({
    expression,
    argument: ['http://example.com/'],
    dependencies: ['node-fetch:fetch'],
  })

  console.log(responseText)
}

main()

About

exec async function into child_process using `child_process.fork()`


Languages

Language:JavaScript 100.0%