8000 GitHub - un-ts/synckit at v0.1.6
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ synckit Public

Perform async work synchronously in Node.js/Bun using `worker_threads` with first-class TypeScript and Yarn P'n'P support.

License

Notifications You must be signed in to change notification settings

un-ts/synckit

Repository files navigation

synckit

GitHub Actions Codecov Codacy Grade type-coverage npm GitHub Release

David Peer David David Dev

Conventional Commits Renovate enabled JavaScript Style Guide Code Style: Prettier

Perform async work synchronously in Node.js using a separate process with first-class TypeScript support

Usage

# yarn
yarn add synckit

# npm
npm i synckit

API

// runner.js
import { createSyncFn } from 'synckit'

// the worker path must be absolute
const syncFn = createSyncFn(require.resolve('./worker'))

// do whatever you want, you will get the result synchronously!
const result = syncFn(...args)
// worker.js
import { runAsWorker } from 'synckit'

runAsWorker(async (...args) => {
  // do expensive work
  // but you must make sure the `result` is serializable by `JSON.stringify`
  return result
})

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © JounQin@1stG.me

About

Perform async work synchronously in Node.js/Bun using `worker_threads` with first-class TypeScript and Yarn P'n'P support.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 16

0