@ionic/utils-process

  • Version 2.1.12
  • Published
  • 10.2 kB
  • 6 dependencies
  • MIT license

Install

npm i @ionic/utils-process
yarn add @ionic/utils-process
pnpm add @ionic/utils-process

Overview

Process utils for NodeJS

Index

Variables

variable ERROR_TIMEOUT_REACHED

const ERROR_TIMEOUT_REACHED: Error;

    Functions

    function createProcessEnv

    createProcessEnv: (...sources: { [key: string]: string }[]) => NodeJS.ProcessEnv;
    • Creates an alternative implementation of process.env object.

      On a Windows shell, process.env is a magic object that offers case-insensitive environment variable access. On other platforms, case sensitivity matters. This method creates an empty "process.env" object type that works for all platforms.

    function getPathParts

    getPathParts: (envpath?: string) => string[];
    • Split a PATH string into path parts.

    function killProcessTree

    killProcessTree: (pid: number, signal?: string | number) => Promise<void>;

      function offBeforeExit

      offBeforeExit: (fn: ExitFn) => void;
      • Remove a function that was registered with onBeforeExit.

      function onBeforeExit

      onBeforeExit: (fn: ExitFn) => void;
      • Register an asynchronous function to be called when the process wants to exit.

        A handler will be registered for the 'SIGINT', 'SIGTERM', 'SIGHUP', 'SIGBREAK' signals. If any of the signal events is emitted, fn will be called exactly once, awaited upon, and then the process will exit once all registered functions are resolved.

      function onExit

      onExit: (fn: () => void) => void;
      • Register a synchronous function to be called once the process exits.

      function processExit

      processExit: (exitCode?: number) => Promise<void>;
      • Asynchronous process.exit(), for running functions registered with onBeforeExit.

      function sleep

      sleep: (ms: number) => Promise<void>;
      • Resolves when the given amount of milliseconds has passed.

      function sleepForever

      sleepForever: () => Promise<never>;
      • Never resolves and keeps Node running.

      function sleepUntil

      sleepUntil: (
      predicate: () => boolean,
      { interval, timeout }: { interval?: number; timeout?: number }
      ) => Promise<void>;
      • Resolves when a given predicate is true or a timeout is reached.

        Configure interval to set how often the predicate is called.

        By default, timeout is Infinity. If given a value (in ms), and that timeout value is reached, this function will reject with the ERROR_TIMEOUT_REACHED error.

      Type Aliases

      type ExitFn

      type ExitFn = () => Promise<void>;

        Package Files (1)

        Dependencies (6)

        Dev Dependencies (10)

        Peer Dependencies (0)

        No peer dependencies.

        Badge

        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@ionic/utils-process.

        • Markdown
          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@ionic/utils-process)
        • HTML
          <a href="https://www.jsdocs.io/package/@ionic/utils-process"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>