miscUtils
Index
Enumerations
Classes
Interfaces
Type Aliases
Functions
- allSettledSafe
- assertNever
- bufferStream
- buildIgnorePattern
- convertMapsToIndexableObjects
- dynamicRequire
- escapeRegExp
- getArrayWithDefault
- getFactoryWithDefault
- getMapWithDefault
- getSetWithDefault
- groupBy
- isIndexableObject
- isPathLike
- makeDeferred
- mapAndFilter
- mapAndFind
- mergeIntoTarget
- overrideType
- parseBoolean
- parseInt
- parseOptionalBoolean
- plural
- prettifyAsyncErrors
- prettifySyncErrors
- releaseAfterUseAsync
- replaceEnvVariables
- sortMap
- toMerged
- tryParseOptionalBoolean
- validateEnum
Enumerations
CachingStrategy
FsTime
NoCache
Node
Classes
AsyncActions
constructor
Parameters
limit: number
Returns AsyncActions
reduce
Parameters
key: string
factory: (action: Promise<void>) => Promise<void>
Returns void
set
Parameters
key: string
factory: () => Promise<void>
Returns Promise<void>
wait
Returns Promise<void>
BufferStream
externalconstructor
Parameters
externaloptionalopts: TransformOptions
Returns BufferStream
_flush
Parameters
cb: any
Returns void
_transform
Parameters
chunk: Buffer
encoding: string
cb: any
Returns void
DefaultStream
constructor
Parameters
ifEmpty: Buffer = ...
Returns DefaultStream
publicactive
_flush
Parameters
cb: any
Returns void
_transform
Parameters
chunk: Buffer
encoding: string
cb: any
Returns void
Interfaces
GetSetMap
Type parameters
- K
- V
get
Parameters
k: K
Returns undefined | V
set
Parameters
k: K
v: V
Returns void
ToMapValue
Type parameters
- T: object
get
Type parameters
- K: string | number | symbol
Parameters
key: K
Returns T[K]
Type Aliases
Deferred
Type parameters
- T = void
Type declaration
promise: Promise<T>
reject: (err: Error) => void
Parameters
err: Error
Returns void
resolve: (val: T) => void
Parameters
val: T
Returns void
FilterKeys
Type parameters
- T: {}
- Filter
MapValue
Type parameters
- T
MapValueToObjectValue
Type parameters
- T
Functions
allSettledSafe
Type parameters
- T
Parameters
promises: Promise<T>[]
Returns Promise<T[]>
assertNever
Parameters
arg: never
Returns never
bufferStream
Parameters
stream: Readable
Returns Promise<Buffer>
buildIgnorePattern
Parameters
ignorePatterns: string[]
An array of glob patterns
Returns null | string
A
string
representing a regular expression ornull
if no glob patterns are provided
convertMapsToIndexableObjects
Converts Maps to indexable objects recursively.
Type parameters
- T
Parameters
arg: T
Returns MapValueToObjectValue<T>
dynamicRequire
Parameters
path: string
optionalopts: { cachingStrategy?: CachingStrategy }
Returns any
escapeRegExp
Parameters
str: string
Returns string
getArrayWithDefault
Type parameters
- K
- T
Parameters
map: GetSetMap<K, T[]>
key: K
Returns T[]
getFactoryWithDefault
Type parameters
- K
- T
Parameters
map: GetSetMap<K, T>
key: K
factory: () => T
Returns T
getMapWithDefault
Type parameters
- K
- MK
- MV
Parameters
map: GetSetMap<K, Map<MK, MV>>
key: K
Returns Map<MK, MV>
getSetWithDefault
Type parameters
- K
- T
Parameters
map: GetSetMap<K, Set<T>>
key: K
Returns Set<T>
groupBy
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
Parameters
value: unknown
Returns value is {}
isPathLike
Parameters
value: string
Returns boolean
makeDeferred
Type parameters
- T = void
Returns Deferred<T>
mapAndFilter
Type parameters
- In
- Out
Parameters
iterable: Iterable<In>
cb: (value: In) => Out | typeof mapAndFilterSkip
Returns Out[]
skip
mapAndFind
Type parameters
- In
- Out
Parameters
iterable: Iterable<In>
cb: (value: In) => Out | typeof mapAndFindSkip
Returns Out | undefined
skip
mergeIntoTarget
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).Type parameters
- T: object
- S: object[]
Parameters
target: T
rest...sources: S
Returns MergeObjects<S, T>
overrideType
Type parameters
- T
Parameters
val: unknown
Returns asserts val is T
parseBoolean
Parameters
value: unknown
Returns boolean
parseInt
Parameters
val: string | number
Returns number
parseOptionalBoolean
Parameters
value: unknown
Returns boolean | undefined
plural
Parameters
n: number
__namedParameters: { more: string; one: string; zero?: string }
Returns string
prettifyAsyncErrors
Type parameters
- T
Parameters
fn: () => Promise<T>
update: (message: string) => string
Returns Promise<T>
prettifySyncErrors
Type parameters
- T
Parameters
fn: () => T
update: (message: string) => string
Returns T
releaseAfterUseAsync
Type parameters
- T
Parameters
fn: () => Promise<T>
optionalcleanup: null | () => any
Returns Promise<T>
replaceEnvVariables
Parameters
value: string
__namedParameters: { env: {} }
Returns string
sortMap
Type parameters
- T
Parameters
values: Iterable<T>
mappers: (value: T) => string | (value: T) => string[]
Returns T[]
toMerged
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
Parameters
value: unknown
Returns boolean | undefined | null
validateEnum
Type parameters
- T
Parameters
def: {}
value: string
Returns T
Combines an Array of glob patterns into a regular expression.