Socket
Socket
Sign inDemoInstall

@definitelytyped/utils

Package Overview
Dependencies
Maintainers
7
Versions
260
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@definitelytyped/utils - npm Package Compare versions

Comparing version 0.0.179 to 0.0.180

6

CHANGELOG.md
# @definitelytyped/utils
## 0.0.180
### Patch Changes
- d01cacd5: Make AllPackages lazy and asynchronous
## 0.0.179

@@ -4,0 +10,0 @@

8

dist/process.d.ts

@@ -11,10 +11,2 @@ /// <reference types="node" />

export declare function execAndThrowErrors(cmd: string, cwd?: string): Promise<string>;
export interface RunWithChildProcessesOptions<In> {
readonly inputs: readonly In[];
readonly commandLineArgs: string[];
readonly workerFile: string;
readonly nProcesses: number;
handleOutput(output: unknown): void;
}
export declare function runWithChildProcesses<In>({ inputs, commandLineArgs, workerFile, nProcesses, handleOutput, }: RunWithChildProcessesOptions<In>): Promise<void>;
export declare const enum CrashRecoveryState {

@@ -21,0 +13,0 @@ Normal = 0,

55

dist/process.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.runWithListeningChildProcesses = exports.runWithChildProcesses = exports.execAndThrowErrors = exports.exec = void 0;
exports.runWithListeningChildProcesses = exports.execAndThrowErrors = exports.exec = void 0;
const assert_1 = __importDefault(require("assert"));

@@ -34,55 +34,2 @@ const child_process_1 = require("child_process");

exports.execAndThrowErrors = execAndThrowErrors;
function runWithChildProcesses({ inputs, commandLineArgs, workerFile, nProcesses, handleOutput, }) {
return new Promise(async (resolve, reject) => {
const nPerProcess = Math.floor(inputs.length / nProcesses);
let processesLeft = nProcesses;
let rejected = false;
const allChildren = [];
for (let i = 0; i < nProcesses; i++) {
const lo = nPerProcess * i;
const hi = i === nProcesses - 1 ? inputs.length : lo + nPerProcess;
let outputsLeft = hi - lo; // Expect one output per input
if (outputsLeft === 0) {
// No work for this process to do, so don't launch it
processesLeft--;
continue;
}
const child = (0, child_process_1.fork)(workerFile, commandLineArgs, {
execArgv: await getChildProcessExecArgv(i),
});
allChildren.push(child);
child.send(inputs.slice(lo, hi));
child.on("message", (outputMessage) => {
handleOutput(outputMessage);
(0, assert_1.default)(outputsLeft > 0);
outputsLeft--;
if (outputsLeft === 0) {
(0, assert_1.default)(processesLeft > 0);
processesLeft--;
if (processesLeft === 0) {
resolve();
}
child.kill();
}
});
child.on("disconnect", () => {
if (outputsLeft !== 0) {
fail(new Error(`disconnect with ${outputsLeft} outputs left`));
}
});
child.on("close", () => {
(0, assert_1.default)(rejected || outputsLeft === 0);
});
child.on("error", fail);
}
function fail(e) {
rejected = true;
for (const child of allChildren) {
child.kill();
}
reject(e);
}
});
}
exports.runWithChildProcesses = runWithChildProcesses;
function runWithListeningChildProcesses({ inputs, commandLineArgs, workerFile, nProcesses, cwd, handleOutput, crashRecovery, crashRecoveryMaxOldSpaceSize = DEFAULT_CRASH_RECOVERY_MAX_OLD_SPACE_SIZE, childRestartTaskInterval = DEFAULT_CHILD_RESTART_TASK_INTERVAL, handleStart, handleCrash, softTimeoutMs = Infinity, }) {

@@ -89,0 +36,0 @@ return new Promise(async (resolve, reject) => {

{
"name": "@definitelytyped/utils",
"version": "0.0.179",
"version": "0.0.180",
"description": "Shared utilities for DefinitelyTyped tools",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/microsoft/DefinitelyTyped-tools/tree/master/packages/utils#readme",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc