JSPM

  • Created
  • Published
  • Downloads 16463212
  • Score
    100M100P100Q228725F
  • License MIT

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

Package Exports

  • synckit

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (synckit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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