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
Perform async work synchronously in Node.js using a separate process with first-class TypeScript support
Usage
# yarn
yarn add synckit
# npm
npm i synckitAPI
// 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.