Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.
/ workerman Public archive

Run your JavaScript off the browser's main thread with inline workers

License

Notifications You must be signed in to change notification settings

raminjafary/workerman

Repository files navigation

Workerman

npm (scoped with tag)

Run your JavaScript off the browser's main thread with inline workers

Installation

npm i @raminjafary/workerman
# or
yarn add @raminjafary/workerman

Usage

Async/Await

import Workerman from "@raminjafary/workerman";

const post = new Workerman(async function getUserPosts() {
  const res = await fetch('https://jsonplaceholder.typicode.com/posts?userId=1')
  return res.json()
})
;(async () => {
  const data = await post.proxy()
  // do sth with data
})()

Promise

import Workerman from "@raminjafary/workerman";

const post = new Workerman(id => {
  return fetch(`https://jsonplaceholder.typicode.com/posts/${id}`)
    .then(res => res.json())
    .then(json => json)
})
post.proxy(2).then((data) => {
  // do sth with data
}, console.error)

License

MIT

About

Run your JavaScript off the browser's main thread with inline workers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •