Socket
Socket
Sign inDemoInstall

@types/which

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.3 to 3.0.4

72

which/index.d.ts
/** Finds all instances of a specified executable in the PATH environment variable */
declare function which(cmd: string, options: which.Options & which.AsyncOptions & which.OptionsAll): Promise<string[]>;
declare function which(cmd: string, options?: which.Options & which.AsyncOptions & which.OptionsFirst): Promise<string>;
declare namespace which {
/** Finds all instances of a specified executable in the PATH environment variable */
function sync(cmd: string, options: Options & OptionsAll & OptionsNoThrow): readonly string[] | null;
function sync(cmd: string, options: Options & OptionsFirst & OptionsNoThrow): string | null;
function sync(cmd: string, options: Options & OptionsAll & OptionsThrow): readonly string[];
function sync(cmd: string, options?: Options & OptionsFirst & OptionsThrow): string;
function sync(cmd: string, options: Options): string | readonly string[] | null;
type AppendNullIfNothrow<TOptions, TRet> = TOptions extends { nothrow: infer TVal }
// nothrow is specified
? TVal extends false
// TVal is false
? TRet
// TVal is boolean or true
: TRet | null
// nothrow not specified
: TRet;
/** Options that ask for all matches. */
interface OptionsAll extends AsyncOptions {
all: true;
}
type TransformToArrayIfAll<TOptions, TRet> = TOptions extends { all: infer TVal }
// all is specified
? TVal extends true
// TVal is true
? readonly TRet[]
: TVal extends false
// TVal is false
? TRet
// TVal is boolean
: readonly TRet[] | TRet
// all not specified
: TRet;
/** Options that ask for the first match (the default behavior) */
interface OptionsFirst extends AsyncOptions {
all?: false | undefined;
}
type ReturnType<TOptions> = AppendNullIfNothrow<TOptions, TransformToArrayIfAll<TOptions, string>>;
/** Options that ask to receive null instead of a thrown error */
interface OptionsNoThrow extends Options {
nothrow: true;
}
type Exact<T, U extends T> = {
[Key in keyof U]: Key extends keyof T ? U[Key]
: never;
};
/** Options that ask for a thrown error if executable is not found (the default behavior) */
interface OptionsThrow extends Options {
nothrow?: false | undefined;
}
declare function which<TOptions extends which.Options>(
cmd: string,
options?: Exact<which.Options, TOptions>,
): Promise<ReturnType<Exact<which.Options, TOptions>>>;
/** Options for which() async API */
interface AsyncOptions {
declare namespace which {
/** Finds all instances of a specified executable in the PATH environment variable */
function sync<TOptions extends Options>(
cmd: string,
options?: Exact<Options, TOptions>,
): ReturnType<Exact<Options, TOptions>>;
/** Options for which() API */
interface Options {
/** If true, return all matches, instead of just the first one. Note that this means the function returns an array of strings instead of a single string. */

@@ -41,6 +53,4 @@ all?: boolean | undefined;

pathExt?: string | undefined;
}
/** Options for which() sync and async APIs */
interface Options extends AsyncOptions {
/** Use instead of the platform's native path separator. */
delimiter?: string | undefined;
/** If true, returns null when not found */

@@ -47,0 +57,0 @@ nothrow?: boolean | undefined;

{
"name": "@types/which",
"version": "3.0.3",
"version": "3.0.4",
"description": "TypeScript definitions for which",

@@ -33,4 +33,4 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/which",

"dependencies": {},
"typesPublisherContentHash": "d3b56661a01ae2cc87078e8feea2fbae7c60fea1111936e7fb0b582ead6694e9",
"typeScriptVersion": "4.5"
"typesPublisherContentHash": "b1e35ca81c3da9996afe499fdd69d8fc3b710326b77371e390503de8f2ba02d9",
"typeScriptVersion": "4.7"
}

@@ -12,35 +12,47 @@ # Installation

/** Finds all instances of a specified executable in the PATH environment variable */
declare function which(cmd: string, options: which.Options & which.AsyncOptions & which.OptionsAll): Promise<string[]>;
declare function which(cmd: string, options?: which.Options & which.AsyncOptions & which.OptionsFirst): Promise<string>;
declare namespace which {
/** Finds all instances of a specified executable in the PATH environment variable */
function sync(cmd: string, options: Options & OptionsAll & OptionsNoThrow): readonly string[] | null;
function sync(cmd: string, options: Options & OptionsFirst & OptionsNoThrow): string | null;
function sync(cmd: string, options: Options & OptionsAll & OptionsThrow): readonly string[];
function sync(cmd: string, options?: Options & OptionsFirst & OptionsThrow): string;
function sync(cmd: string, options: Options): string | readonly string[] | null;
type AppendNullIfNothrow<TOptions, TRet> = TOptions extends { nothrow: infer TVal }
// nothrow is specified
? TVal extends false
// TVal is false
? TRet
// TVal is boolean or true
: TRet | null
// nothrow not specified
: TRet;
/** Options that ask for all matches. */
interface OptionsAll extends AsyncOptions {
all: true;
}
type TransformToArrayIfAll<TOptions, TRet> = TOptions extends { all: infer TVal }
// all is specified
? TVal extends true
// TVal is true
? readonly TRet[]
: TVal extends false
// TVal is false
? TRet
// TVal is boolean
: readonly TRet[] | TRet
// all not specified
: TRet;
/** Options that ask for the first match (the default behavior) */
interface OptionsFirst extends AsyncOptions {
all?: false | undefined;
}
type ReturnType<TOptions> = AppendNullIfNothrow<TOptions, TransformToArrayIfAll<TOptions, string>>;
/** Options that ask to receive null instead of a thrown error */
interface OptionsNoThrow extends Options {
nothrow: true;
}
type Exact<T, U extends T> = {
[Key in keyof U]: Key extends keyof T ? U[Key]
: never;
};
/** Options that ask for a thrown error if executable is not found (the default behavior) */
interface OptionsThrow extends Options {
nothrow?: false | undefined;
}
declare function which<TOptions extends which.Options>(
cmd: string,
options?: Exact<which.Options, TOptions>,
): Promise<ReturnType<Exact<which.Options, TOptions>>>;
/** Options for which() async API */
interface AsyncOptions {
declare namespace which {
/** Finds all instances of a specified executable in the PATH environment variable */
function sync<TOptions extends Options>(
cmd: string,
options?: Exact<Options, TOptions>,
): ReturnType<Exact<Options, TOptions>>;
/** Options for which() API */
interface Options {
/** If true, return all matches, instead of just the first one. Note that this means the function returns an array of strings instead of a single string. */

@@ -52,6 +64,4 @@ all?: boolean | undefined;

pathExt?: string | undefined;
}
/** Options for which() sync and async APIs */
interface Options extends AsyncOptions {
/** Use instead of the platform's native path separator. */
delimiter?: string | undefined;
/** If true, returns null when not found */

@@ -67,3 +77,3 @@ nothrow?: boolean | undefined;

### Additional Details
* Last updated: Mon, 20 Nov 2023 23:36:24 GMT
* Last updated: Thu, 30 May 2024 17:35:42 GMT
* Dependencies: none

@@ -70,0 +80,0 @@

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