Skip to main content

Module: @divine/commons

Classes

Interfaces

Type Aliases

BasicTypes

Ƭ BasicTypes: boolean | number | bigint | string | object | null

Defined in

commons/src/types.ts:4


Constructor

Ƭ Constructor<T>: (...args: any[]) => T

Type parameters

Name
T

Type declaration

• (...args)

Parameters
NameType
...argsany[]

Defined in

commons/src/types.ts:1


ValueEncoder

Ƭ ValueEncoder: (value: string, key: string | number) => string

Type declaration

▸ (value, key): string

Parameters
NameType
valuestring
keystring | number
Returns

string

Defined in

commons/src/types.ts:2

Functions

as

as<T>(value): T

Type parameters

Name
T

Parameters

NameType
valueT

Returns

T

Defined in

commons/src/utilities.ts:6


b64Decode

b64Decode(b64): string

Parameters

NameType
b64string

Returns

string

Defined in

commons/src/strings.ts:43


b64Encode

b64Encode(str): string

Parameters

NameType
strstring

Returns

string

Defined in

commons/src/strings.ts:47


copyStream

copyStream(from, to): Promise<typeof to>

Parameters

NameType
fromReadableStream
toWritableStream

Returns

Promise<typeof to>

Defined in

commons/src/streams.ts:14


es6Encoder

es6Encoder(strings, values, encoder): string

Parameters

NameType
stringsTemplateStringsArray
valuesunknown[]
encoderValueEncoder

Returns

string

Defined in

commons/src/strings.ts:18


escapeRegExp

escapeRegExp(str): string

Parameters

NameType
strstring

Returns

string

Defined in

commons/src/strings.ts:51


esxxEncoder

esxxEncoder(template, params, encoder): string

Parameters

NameType
templatestring
paramsParams
encoderValueEncoder

Returns

string

Defined in

commons/src/strings.ts:28


isAsyncIterable

isAsyncIterable<T>(object): object is AsyncIterable<T>

Type parameters

NameType
Tunknown

Parameters

NameType
objectany

Returns

object is AsyncIterable<T>

Defined in

commons/src/async-iterable.ts:8


isDOMNode

isDOMNode(obj): boolean

Parameters

NameType
objunknown

Returns

boolean

Defined in

commons/src/utilities.ts:23


isHTML

isHTML(obj): boolean

Parameters

NameType
objunknown

Returns

boolean

Defined in

commons/src/utilities.ts:31


isJSON

isJSON(obj): boolean

Parameters

NameType
objunknown

Returns

boolean

Defined in

commons/src/utilities.ts:43


isOneOf

isOneOf<T, V>(value, of): boolean

Type parameters

NameType
Textends string | number
Vextends T[]

Parameters

NameType
valueundefined | T
ofV

Returns

boolean

Defined in

commons/src/utilities.ts:10


isReadableStream

isReadableStream(obj): obj is ReadableStream & AsyncIterable<string | Buffer>

Parameters

NameType
objany

Returns

obj is ReadableStream & AsyncIterable<string | Buffer>

Defined in

commons/src/streams.ts:5


isTemplateStringsLike

isTemplateStringsLike(strings): strings is TemplateStringsArray

Parameters

NameType
stringsany

Returns

strings is TemplateStringsArray

Defined in

commons/src/strings.ts:38


isXML

isXML(obj): boolean

Parameters

NameType
objunknown

Returns

boolean

Defined in

commons/src/utilities.ts:27


mapped

mapped<T, TReturn, TNext, R>(it, fn): AsyncGenerator<R, TReturn, TNext>

Type parameters

Name
T
TReturn
TNext
R

Parameters

NameType
itAsyncGenerator<T, TReturn, TNext>
fn(value: T) => R | Promise<R>

Returns

AsyncGenerator<R, TReturn, TNext>

Defined in

commons/src/async-iterable.ts:76

mapped<T, TReturn, TNext, R>(it, fn): ExtAsyncIterableIterator<R, TReturn, TNext>

Type parameters

Name
T
TReturn
TNext
R

Parameters

NameType
itAsyncIterator<T, TReturn, TNext> | AsyncIterable<T>
fn(value: T) => R | Promise<R>

Returns

ExtAsyncIterableIterator<R, TReturn, TNext>

Defined in

commons/src/async-iterable.ts:77


percentEncode

percentEncode(str): string

Percent-encode everything except 0-9, A-Z, a-z, -, _, ., ! and ~.

Parameters

NameType
strstring

Returns

string

Defined in

commons/src/strings.ts:4


setProp

setProp<T, K>(object, prop, value): T

Type parameters

NameType
Textends object
Kextends string | number | symbol

Parameters

NameType
objectT
propK
valueT[K]

Returns

T

Defined in

commons/src/utilities.ts:18


sleep

sleep(ms): Promise<void>

Parameters

NameType
msnumber

Returns

Promise<void>

Defined in

commons/src/utilities.ts:2


throwError

throwError(err): never

Parameters

NameType
errError

Returns

never

Defined in

commons/src/utilities.ts:14


toAsyncIterable

toAsyncIterable(data): AsyncIterable<Buffer>

Parameters

NameType
datastring | Buffer | AsyncIterable<string | Buffer>

Returns

AsyncIterable<Buffer>

Defined in

commons/src/async-iterable.ts:12


toReadableStream

toReadableStream(data): Readable & AsyncIterable<Buffer>

Parameters

NameType
datastring | Buffer | AsyncIterable<string | Buffer>

Returns

Readable & AsyncIterable<Buffer>

Defined in

commons/src/streams.ts:10


unblocked

unblocked<T, TReturn, TNext>(it, timeout): AsyncGenerator<T | undefined, TReturn, TNext>

Type parameters

Name
T
TReturn
TNext

Parameters

NameType
itAsyncGenerator<T, TReturn, TNext>
timeoutnumber

Returns

AsyncGenerator<T | undefined, TReturn, TNext>

Defined in

commons/src/async-iterable.ts:96

unblocked<T, TReturn, TNext>(it, timeout): ExtAsyncIterableIterator<T | undefined, TReturn, TNext>

Type parameters

Name
T
TReturn
TNext

Parameters

NameType
itAsyncIterator<T, TReturn, TNext> | AsyncIterable<T>
timeoutnumber

Returns

ExtAsyncIterableIterator<T | undefined, TReturn, TNext>

Defined in

commons/src/async-iterable.ts:97