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

    @types/which

TypeScript definitions for which


Version published
Maintainers
1
Install size
7.20 kB
Created

Package description

What is @types/which?

The @types/which package provides TypeScript type definitions for the 'which' npm package. 'which' is a utility that locates and returns the path to an executable in the system path, similar to the Unix 'which' command. The @types/which package does not contain functionality itself but provides type definitions to help TypeScript developers use the 'which' package with type safety.

What are @types/which's main functionalities?

Type definitions for finding an executable in the path

This code sample demonstrates how to use the 'which' package with TypeScript type definitions provided by @types/which. It attempts to locate the 'node' executable in the system path and prints its location or an error if not found.

import which from 'which';

which('node', (err, resolvedPath) => {
  if (err) {
    console.error('Node executable not found');
    return;
  }
  console.log('Node executable located at:', resolvedPath);
});

Other packages similar to @types/which

Readme

Source

Installation

npm install --save @types/which

Summary

This package contains type definitions for which (https://github.com/isaacs/node-which).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/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): ReadonlyArray<string> | null;
    function sync(cmd: string, options: Options & OptionsFirst & OptionsNoThrow): string | null;
    function sync(cmd: string, options: Options & OptionsAll & OptionsThrow): ReadonlyArray<string>;
    function sync(cmd: string, options?: Options & OptionsFirst & OptionsThrow): string;
    function sync(cmd: string, options: Options): string | ReadonlyArray<string> | null;

    /** Options that ask for all matches. */
    interface OptionsAll extends AsyncOptions {
        all: true;
    }

    /** Options that ask for the first match (the default behavior) */
    interface OptionsFirst extends AsyncOptions {
        all?: false | undefined;
    }

    /** Options that ask to receive null instead of a thrown error */
    interface OptionsNoThrow extends Options {
        nothrow: true;
    }

    /** Options that ask for a thrown error if executable is not found (the default behavior) */
    interface OptionsThrow extends Options {
        nothrow?: false | undefined;
    }

    /** Options for which() async API */
    interface AsyncOptions {
        /** 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. */
        all?: boolean | undefined;
        /** Use instead of the PATH environment variable. */
        path?: string | undefined;
        /** Use instead of the PATHEXT environment variable. */
        pathExt?: string | undefined;
    }

    /** Options for which() sync and async APIs */
    interface Options extends AsyncOptions {
        /** If true, returns null when not found */
        nothrow?: boolean | undefined;
    }
}

export = which;

Additional Details

  • Last updated: Wed, 18 Oct 2023 18:04:04 GMT
  • Dependencies: none

Credits

These definitions were written by vvakame, cspotcode, and Piotr Błażejewicz.

FAQs

Last updated on 18 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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