Socket
Socket
Sign inDemoInstall

synckit

Package Overview
Dependencies
50
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.0 to 0.8.1

1

lib/index.d.ts

@@ -15,2 +15,3 @@ import { AnyAsyncFn, Syncify, ValueOf } from './types.js';

export declare const DEFAULT_TS_RUNNER: TsRunner;
export declare const MTS_SUPPORTED_NODE_VERSION = 16;
export interface SynckitOptions {

@@ -17,0 +18,0 @@ bufferSize?: number;

41

lib/index.js

@@ -30,2 +30,3 @@ import { __awaiter } from "tslib";

TsRunner.TsNode);
export const MTS_SUPPORTED_NODE_VERSION = 16;
const syncFnCache = new Map();

@@ -64,3 +65,3 @@ // MessagePort doesn't copy the properties of Error objects. We still want

const setupTsRunner = (workerPath, { execArgv, tsRunner }) => {
const ext = path.extname(workerPath);
let ext = path.extname(workerPath);
if (!/[/\\]node_modules[/\\]/.test(workerPath) &&

@@ -84,4 +85,8 @@ (!ext || /^\.[cm]?js$/.test(ext))) {

const found = tryExtensions(workPathWithoutExt, extensions);
if (found && (!ext || found !== workPathWithoutExt)) {
let differentExt;
if (found && (!ext || (differentExt = found !== workPathWithoutExt))) {
workerPath = found;
if (differentExt) {
ext = path.extname(workerPath);
}
}

@@ -143,8 +148,12 @@ }

};
// eslint-disable-next-line sonarjs/cognitive-complexity
function startWorkerThread(workerPath, { bufferSize = DEFAULT_WORKER_BUFFER_SIZE, timeout = DEFAULT_TIMEOUT, execArgv = DEFAULT_EXEC_ARGV, tsRunner = DEFAULT_TS_RUNNER, } = {}) {
const { port1: mainPort, port2: workerPort } = new MessageChannel();
const { ext, tsUseEsm, workerPath: finalWorkerPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
const { isTs, ext, tsUseEsm, workerPath: finalWorkerPath, execArgv: finalExecArgv, } = setupTsRunner(workerPath, { execArgv, tsRunner });
const workerPathUrl = pathToFileURL(finalWorkerPath);
if (/\.[cm]ts$/.test(finalWorkerPath) &&
[
if (/\.[cm]ts$/.test(finalWorkerPath)) {
const isTsxSupported = !tsUseEsm ||
Number.parseFloat(process.versions.node) >= MTS_SUPPORTED_NODE_VERSION;
/* istanbul ignore if */
if ([
// https://github.com/egoist/esbuild-register/issues/79

@@ -154,15 +163,17 @@ TsRunner.EsbuildRegister,

TsRunner.EsbuildRunner,
... /* istanbul ignore next */(isTsxSupported ? [] : [TsRunner.TSX]),
].includes(tsRunner)) {
throw new Error(`${tsRunner} is not supported for ${ext} files yet, you can try [tsx](https://github.com/esbuild-kit/tsx) instead`);
throw new Error(`${tsRunner} is not supported for ${ext} files yet` +
(isTsxSupported
? ', you can try [tsx](https://github.com/esbuild-kit/tsx) instead'
: ''));
}
}
const worker = new Worker(tsUseEsm &&
[
TsRunner.TsNode,
// https://github.com/egoist/esbuild-register/issues/79
// TsRunner.EsbuildRegister,
// https://github.com/folke/esbuild-runner/issues/67
// TsRunner.EsbuildRunner
].includes(tsRunner)
const useEval = isTs && !tsUseEsm;
const worker = new Worker(tsUseEsm && tsRunner === TsRunner.TsNode
? dataUrl(`import '${String(workerPathUrl)}'`)
: workerPathUrl, {
: useEval
? `require('${finalWorkerPath.replace(/\\/g, '\\\\')}')`
: workerPathUrl, {
eval: useEval,
workerData: { workerPort },

@@ -169,0 +180,0 @@ transferList: [workerPort],

{
"name": "synckit",
"version": "0.8.0",
"version": "0.8.1",
"type": "module",

@@ -66,6 +66,90 @@ "description": "Perform async work synchronously in Node.js using `worker_threads` with first-class TypeScript support.",

],
"scripts": {
"benchmark": "run-s benchmark:*",
"benchmark-export": "run-s benchmark-export:*",
"benchmark-export:cjs": "yarn benchmark:cjs > benchmarks/benchmark.cjs.txt",
"benchmark-export:esm": "yarn benchmark:esm> benchmarks/benchmark.esm.txt",
"benchmark:cjs": "node benchmarks/benchmark.cjs",
"benchmark:esm": "node benchmarks/benchmark.js",
"build": "run-p build:*",
"build:r": "r -f cjs",
"build:ts": "tsc -p src",
"lint": "run-p lint:*",
"lint:es": "eslint . --cache -f friendly --max-warnings 10",
"lint:tsc": "tsc --noEmit",
"prepare": "patch-package && simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prerelease": "yarn build",
"release": "changeset publish",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"typecov": "type-coverage"
},
"dependencies": {
"@pkgr/utils": "^2.3.0",
"tslib": "^2.4.0"
},
"devDependencies": {
"@1stg/lib-config": "^9.0.0",
"@changesets/changelog-github": "^0.4.5",
"@changesets/cli": "^2.23.2",
"@types/jest": "^28.1.5",
"@types/node": "^18.0.4",
"deasync": "^0.1.27",
"esbuild-register": "^3.3.3",
"esbuild-runner": "^2.2.1",
"jest": "^28.1.3",
"patch-package": "^6.4.7",
"sync-threads": "^1.0.1",
"ts-expect": "^1.3.0",
"ts-jest": "^28.0.6",
"ts-node": "^10.9.1",
"tsx": "^3.8.0",
"type-coverage": "^2.22.0",
"typescript": "^4.7.4",
"yarn-deduplicate": "^5.0.0"
},
"resolutions": {
"prettier": "^2.7.1"
},
"commitlint": {
"extends": "@1stg"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"collectCoverage": true,
"extensionsToTreatAsEsm": [
".ts"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1",
"^synckit$": "<rootDir>/src"
},
"globals": {
"ts-jest": {
"useESM": true,
"tsconfig": {
"importHelpers": false
}
}
}
},
"prettier": "@1stg/prettier-config",
"renovate": {
"extends": [
"@1stg"
]
},
"typeCoverage": {
"atLeast": 100,
"cache": true,
"detail": true,
"ignoreAsAssertion": true,
"ignoreFiles": [
"**/*.d.ts"
],
"ignoreNonNullAssertion": true,
"showRelativePath": true,
"strict": true,
"update": true
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc