Skip to main content

miscUtils

Index

Namespaces

mapAndFilter

mapAndFilter:

skip

skip: typeof mapAndFilterSkip

mapAndFind

mapAndFind:

skip

skip: typeof mapAndFindSkip

Enumerations

CachingStrategy

CachingStrategy:

FsTime

FsTime: 1

NoCache

NoCache: 0

Node

Node: 2

Classes

AsyncActions

AsyncActions:

constructor

reduce

  • reduce(key: string, factory: (action: Promise<void>) => Promise<void>): void
  • Parameters

    • key: string
    • factory: (action: Promise<void>) => Promise<void>

    Returns void

set

  • set(key: string, factory: () => Promise<void>): Promise<void>
  • Parameters

    • key: string
    • factory: () => Promise<void>

    Returns Promise<void>

wait

  • wait(): Promise<void>
  • Returns Promise<void>

BufferStream

BufferStream:

externalconstructor

  • Parameters

    • externaloptionalopts: TransformOptions

    Returns BufferStream

_flush

  • _flush(cb: any): void
  • Parameters

    • cb: any

    Returns void

_transform

  • _transform(chunk: Buffer, encoding: string, cb: any): void
  • Parameters

    • chunk: Buffer
    • encoding: string
    • cb: any

    Returns void

DefaultStream

DefaultStream:

constructor

  • Parameters

    • ifEmpty: Buffer = ...

    Returns DefaultStream

publicactive

active: boolean = true

_flush

  • _flush(cb: any): void
  • Parameters

    • cb: any

    Returns void

_transform

  • _transform(chunk: Buffer, encoding: string, cb: any): void
  • Parameters

    • chunk: Buffer
    • encoding: string
    • cb: any

    Returns void

Interfaces

GetSetMap

GetSetMap<K, V>:

Type parameters

  • K
  • V

get

  • get(k: K): undefined | V
  • Parameters

    • k: K

    Returns undefined | V

set

  • set(k: K, v: V): void
  • Parameters

    • k: K
    • v: V

    Returns void

ToMapValue

ToMapValue<T>:

Type parameters

  • T: object

get

  • get<K>(key: K): T[K]
  • Type parameters

    • K: string | number | symbol

    Parameters

    • key: K

    Returns T[K]

Type Aliases

Deferred

Deferred<T>: { promise: Promise<T>; reject: (err: Error) => void; resolve: (val: T) => void }

Type parameters

  • T = void

Type declaration

  • promise: Promise<T>
  • reject: (err: Error) => void
      • (err: Error): void
      • Parameters

        • err: Error

        Returns void

  • resolve: (val: T) => void
      • (val: T): void
      • Parameters

        • val: T

        Returns void

FilterKeys

FilterKeys<T, Filter>: { [ K in keyof T ]: T[K] extends Filter ? K : never }[keyof T]

Type parameters

  • T: {}
  • Filter

MapValue

MapValue<T>: T extends Map<any, infer V> ? V : never

Type parameters

  • T

MapValueToObjectValue

MapValueToObjectValue<T>: T extends Map<infer K, infer V> ? K extends string | number | symbol ? MapValueToObjectValue<Record<K, V>> : never : T extends ToMapValue<infer V> ? MapValueToObjectValue<V> : T extends PortablePath ? PortablePath : T extends object ? { [ K in keyof T ]: MapValueToObjectValue<T[K]> } : T

Type parameters

  • T

Functions

allSettledSafe

  • allSettledSafe<T>(promises: Promise<T>[]): Promise<T[]>
  • Type parameters

    • T

    Parameters

    • promises: Promise<T>[]

    Returns Promise<T[]>

assertNever

  • assertNever(arg: never): never
  • Parameters

    • arg: never

    Returns never

bufferStream

  • bufferStream(stream: Readable): Promise<Buffer>
  • Parameters

    • stream: Readable

    Returns Promise<Buffer>

buildIgnorePattern

  • buildIgnorePattern(ignorePatterns: string[]): null | string
  • Combines an Array of glob patterns into a regular expression.


    Parameters

    • ignorePatterns: string[]

      An array of glob patterns

    Returns null | string

    A string representing a regular expression or null if no glob patterns are provided

convertMapsToIndexableObjects

  • Converts Maps to indexable objects recursively.


    Type parameters

    • T

    Parameters

    • arg: T

    Returns MapValueToObjectValue<T>

dynamicRequire

  • dynamicRequire(path: string, opts?: { cachingStrategy?: CachingStrategy }): any
  • dynamicRequire(path: PortablePath, opts: { cachingStrategy: FsTime }): any
  • Parameters

    Returns any

escapeRegExp

  • escapeRegExp(str: string): string
  • Parameters

    • str: string

    Returns string

getArrayWithDefault

  • getArrayWithDefault<K, T>(map: GetSetMap<K, T[]>, key: K): T[]
  • Type parameters

    • K
    • T

    Parameters

    Returns T[]

getFactoryWithDefault

  • getFactoryWithDefault<K, T>(map: GetSetMap<K, T>, key: K, factory: () => T): T
  • Type parameters

    • K
    • T

    Parameters

    Returns T

getMapWithDefault

  • getMapWithDefault<K, MK, MV>(map: GetSetMap<K, Map<MK, MV>>, key: K): Map<MK, MV>
  • Type parameters

    • K
    • MK
    • MV

    Parameters

    Returns Map<MK, MV>

getSetWithDefault

  • getSetWithDefault<K, T>(map: GetSetMap<K, Set<T>>, key: K): Set<T>
  • Type parameters

    • K
    • T

    Parameters

    Returns Set<T>

groupBy

  • groupBy<T, K>(items: Iterable<T>, key: K): { [ V in T[K] ]?: Extract<T, { [ _ in K ]: V }>[] }
  • Type parameters

    • T: Record<string, any>
    • K: string | number | symbol

    Parameters

    • items: Iterable<T>
    • key: K

    Returns { [ V in T[K] ]?: Extract<T, { [ _ in K ]: V }>[] }

isIndexableObject

  • isIndexableObject(value: unknown): value is {}
  • Parameters

    • value: unknown

    Returns value is {}

isPathLike

  • isPathLike(value: string): boolean
  • Parameters

    • value: string

    Returns boolean

makeDeferred

  • Type parameters

    • T = void

    Returns Deferred<T>

mapAndFilter

  • mapAndFilter<In, Out>(iterable: Iterable<In>, cb: (value: In) => Out | typeof mapAndFilterSkip): Out[]
  • Type parameters

    • In
    • Out

    Parameters

    • iterable: Iterable<In>
    • cb: (value: In) => Out | typeof mapAndFilterSkip

    Returns Out[]

mapAndFind

  • mapAndFind<In, Out>(iterable: Iterable<In>, cb: (value: In) => Out | typeof mapAndFindSkip): Out | undefined
  • Type parameters

    • In
    • Out

    Parameters

    • iterable: Iterable<In>
    • cb: (value: In) => Out | typeof mapAndFindSkip

    Returns Out | undefined

mergeIntoTarget

  • mergeIntoTarget<T, S>(target: T, ...sources: S): MergeObjects<S, T>
  • Merges multiple objects into the target argument.

    Important: This function mutates the target argument.

    Custom classes inside the target parameter are supported (e.g. comment-json’s CommentArray - comments from target will be preserved).

    @see

    toMerged for a version that doesn’t mutate the target argument


    Type parameters

    • T: object
    • S: object[]

    Parameters

    • target: T
    • rest...sources: S

    Returns MergeObjects<S, T>

overrideType

  • overrideType<T>(val: unknown): asserts val is T
  • Type parameters

    • T

    Parameters

    • val: unknown

    Returns asserts val is T

parseBoolean

  • parseBoolean(value: unknown): boolean
  • Parameters

    • value: unknown

    Returns boolean

parseInt

  • parseInt(val: string | number): number
  • Parameters

    • val: string | number

    Returns number

parseOptionalBoolean

  • parseOptionalBoolean(value: unknown): boolean | undefined
  • Parameters

    • value: unknown

    Returns boolean | undefined

plural

  • plural(n: number, __namedParameters: { more: string; one: string; zero?: string }): string
  • Parameters

    • n: number
    • __namedParameters: { more: string; one: string; zero?: string }

    Returns string

prettifyAsyncErrors

  • prettifyAsyncErrors<T>(fn: () => Promise<T>, update: (message: string) => string): Promise<T>
  • Type parameters

    • T

    Parameters

    • fn: () => Promise<T>
    • update: (message: string) => string

    Returns Promise<T>

prettifySyncErrors

  • prettifySyncErrors<T>(fn: () => T, update: (message: string) => string): T
  • Type parameters

    • T

    Parameters

    • fn: () => T
    • update: (message: string) => string

    Returns T

releaseAfterUseAsync

  • releaseAfterUseAsync<T>(fn: () => Promise<T>, cleanup?: null | () => any): Promise<T>
  • Type parameters

    • T

    Parameters

    • fn: () => Promise<T>
    • optionalcleanup: null | () => any

    Returns Promise<T>

replaceEnvVariables

  • replaceEnvVariables(value: string, __namedParameters: { env: {} }): string
  • Parameters

    • value: string
    • __namedParameters: { env: {} }

    Returns string

sortMap

  • sortMap<T>(values: Iterable<T>, mappers: (value: T) => string | (value: T) => string[]): T[]
  • Type parameters

    • T

    Parameters

    • values: Iterable<T>
    • mappers: (value: T) => string | (value: T) => string[]

    Returns T[]

toMerged

  • toMerged<S>(...sources: S): MergeObjects<S, {}>
  • Merges multiple objects into a single one, without mutating any arguments.

    Custom classes are not supported (i.e. comment-json’s comments will be lost).


    Type parameters

    • S: object[]

    Parameters

    • rest...sources: S

    Returns MergeObjects<S, {}>

tryParseOptionalBoolean

  • tryParseOptionalBoolean(value: unknown): boolean | undefined | null
  • Parameters

    • value: unknown

    Returns boolean | undefined | null

validateEnum

  • validateEnum<T>(def: {}, value: string): T
  • Type parameters

    • T

    Parameters

    • def: {}
    • value: string

    Returns T