UNPKG

2.94 kBTypeScriptView Raw
1/// <reference types="node" />
2import { PortablePath } from '@yarnpkg/fslib';
3import { Readable, Transform } from 'stream';
4export declare function escapeRegExp(str: string): string;
5export declare function overrideType<T>(val: unknown): asserts val is T;
6export declare function assertNever(arg: never): never;
7export declare function validateEnum<T>(def: {
8 [key: string]: T;
9}, value: string): T;
10export declare function mapAndFilter<In, Out>(iterable: Iterable<In>, cb: (value: In) => Out | typeof mapAndFilterSkip): Array<Out>;
11export declare namespace mapAndFilter {
12 var skip: typeof mapAndFilterSkip;
13}
14declare const mapAndFilterSkip: unique symbol;
15export declare function mapAndFind<In, Out>(iterable: Iterable<In>, cb: (value: In) => Out | typeof mapAndFindSkip): Out | undefined;
16export declare namespace mapAndFind {
17 var skip: typeof mapAndFindSkip;
18}
19declare const mapAndFindSkip: unique symbol;
20export declare function isIndexableObject(value: unknown): value is {
21 [key: string]: unknown;
22};
23export declare function getFactoryWithDefault<K, T>(map: Map<K, T>, key: K, factory: () => T): T;
24export declare function getArrayWithDefault<K, T>(map: Map<K, Array<T>>, key: K): T[];
25export declare function getSetWithDefault<K, T>(map: Map<K, Set<T>>, key: K): Set<T>;
26export declare function getMapWithDefault<K, MK, MV>(map: Map<K, Map<MK, MV>>, key: K): Map<MK, MV>;
27export declare function releaseAfterUseAsync<T>(fn: () => Promise<T>, cleanup?: (() => any) | null): Promise<T>;
28export declare function prettifyAsyncErrors<T>(fn: () => Promise<T>, update: (message: string) => string): Promise<T>;
29export declare function prettifySyncErrors<T>(fn: () => T, update: (message: string) => string): T;
30export declare function bufferStream(stream: Readable): Promise<Buffer>;
31export declare class BufferStream extends Transform {
32 private readonly chunks;
33 _transform(chunk: Buffer, encoding: string, cb: any): void;
34 _flush(cb: any): void;
35}
36export declare class DefaultStream extends Transform {
37 private readonly ifEmpty;
38 active: boolean;
39 constructor(ifEmpty?: Buffer);
40 _transform(chunk: Buffer, encoding: string, cb: any): void;
41 _flush(cb: any): void;
42}
43export declare function dynamicRequire(path: string): any;
44export declare function dynamicRequireNoCache(path: PortablePath): any;
45export declare function sortMap<T>(values: Iterable<T>, mappers: ((value: T) => string) | Array<(value: T) => string>): T[];
46/**
47 * Combines an Array of glob patterns into a regular expression.
48 *
49 * @param ignorePatterns An array of glob patterns
50 *
51 * @returns A `string` representing a regular expression or `null` if no glob patterns are provided
52 */
53export declare function buildIgnorePattern(ignorePatterns: Array<string>): string | null;
54export declare function replaceEnvVariables(value: string, { env }: {
55 env: {
56 [key: string]: string | undefined;
57 };
58}): string;
59export {};