Appearance
index
Namespaces
Classes
EventEmitter
Defined in: src/EventEmitter/index.ts:16
Simple typed event emitter. Supports subscribe/once listeners and a destroy lifecycle hook.
Example
ts
const emitter = new EventEmitter<number>();
const unsubscribe = emitter.subscribe((v) => console.log(v));
emitter['emit'](42); // => logs 42
unsubscribe();Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Implements
Constructors
Constructor
ts
new EventEmitter<T>(listeners?): EventEmitter<T>;Defined in: src/EventEmitter/index.ts:19
Parameters
| Parameter | Type |
|---|---|
listeners? | TListener<T>[] |
Returns
EventEmitter<T>
Methods
clear()
ts
clear(): void;Defined in: src/EventEmitter/index.ts:53
Removes all listeners without destroying the emitter.
Returns
void
Implementation of
destroy()
ts
destroy(): void;Defined in: src/EventEmitter/index.ts:23
Destroys the emitter and clears all listeners.
Returns
void
Implementation of
emit()
ts
protected emit(data): void;Defined in: src/EventEmitter/index.ts:27
Parameters
| Parameter | Type |
|---|---|
data | T |
Returns
void
once()
ts
once(...listeners): () => void;Defined in: src/EventEmitter/index.ts:46
Parameters
| Parameter | Type |
|---|---|
...listeners | IEventEmitterListener<T>[] |
Returns
() => void
subscribe()
ts
subscribe(...listeners): () => void;Defined in: src/EventEmitter/index.ts:42
Registers one or more listeners; returns a function that removes them all.
Parameters
| Parameter | Type |
|---|---|
...listeners | IEventEmitterListener<T>[] |
Returns
() => void
Implementation of
LineBasedFormat
Defined in: src/LineBasedFormat.ts:31
Formats line-based data using pluggable parse and stringify functions.
Example
ts
const fmt = new LineBasedFormat({
parse: (line) => JSON.parse(line),
stringify: (v) => JSON.stringify(v),
});
fmt.parse('{"a":1}\n{"b":2}'); // => [{ a: 1 }, { b: 2 }]
fmt.stringify([{ a: 1 }]); // => '{"a":1}'Constructors
Constructor
ts
new LineBasedFormat(options): LineBasedFormat;Defined in: src/LineBasedFormat.ts:52
Creates a new line-based format.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ILineBasedFormatOptions | The options for the line-based format. |
Returns
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
parse | public | (input) => any | Parses a string into an array of values. | src/LineBasedFormat.ts:38 |
stringify | public | (input) => string | Stringifies an array of values into a string. | src/LineBasedFormat.ts:45 |
LineDecoder
Defined in: src/LineDecoder.ts:62
Streaming line splitter for \n and \r\n line endings. Not tied to JSONL; suitable for CSV, logs, NDJSON, and similar line-based formats.
Example
ts
const decoder = new LineDecoder({ parse: (line) => JSON.parse(line) });
decoder.write('{"a":1}\n{"b"'); // => [{ a: 1 }]
decoder.end('2}'); // => [{ b: 2 }]Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Constructors
Constructor
ts
new LineDecoder<T>(options?): LineDecoder<T>;Defined in: src/LineDecoder.ts:120
Creates a new line decoder.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ILineDecoderOptions | The options for the line decoder. |
Returns
LineDecoder<T>
The line decoder.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
end | (chunk?, output?) => T[] | Ends the decoder. | src/LineDecoder.ts:78 |
write | (chunk, output?) => T[] | Writes a chunk of text to the decoder. | src/LineDecoder.ts:70 |
Methods
create()
ts
static create<T>(options): LineDecoder<T>;Defined in: src/LineDecoder.ts:86
Creates a new line decoder.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | ILineDecoderOptions<T> | The options for the line decoder. |
Returns
LineDecoder<T>
The line decoder.
provider()
ts
static provider<T>(parse): ILineDecoderConstructor<T>;Defined in: src/LineDecoder.ts:96
Creates a new line decoder provider.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
parse | (line) => T | The function to parse a line of text into a value. |
Returns
The line decoder provider.
PortPolyfill
Defined in: src/PortPolyfill.ts:11
A polyfill for the MessagePort interface.
Extends
EventTargetConstructor
Extended by
Constructors
Constructor
ts
new PortPolyfill(): PortPolyfill;Defined in: node_modules/typescript/lib/lib.dom.d.ts:11586
Returns
Inherited from
ts
EventTargetConstructor.constructorMethods
addEventListener()
ts
addEventListener(
type,
callback,
options?): void;Defined in: node_modules/typescript/lib/lib.dom.d.ts:11569
The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
Parameters
| Parameter | Type |
|---|---|
type | string |
callback | EventListenerOrEventListenerObject |
options? | boolean | AddEventListenerOptions |
Returns
void
Inherited from
ts
EventTargetConstructor.addEventListenerdispatchEvent()
ts
dispatchEvent(event): boolean;Defined in: node_modules/typescript/lib/lib.dom.d.ts:11575
The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
Parameters
| Parameter | Type |
|---|---|
event | Event |
Returns
boolean
Inherited from
ts
EventTargetConstructor.dispatchEventpostMessage()
ts
postMessage(data): void;Defined in: src/PortPolyfill.ts:21
Sends a message to the port.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | any | The data to send. |
Returns
void
The data.
Example
ts
const port = new PortPolyfill();
port.postMessage('hello'); // => 'hello'removeEventListener()
ts
removeEventListener(
type,
callback,
options?): void;Defined in: node_modules/typescript/lib/lib.dom.d.ts:11581
The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
Parameters
| Parameter | Type |
|---|---|
type | string |
callback | EventListenerOrEventListenerObject |
options? | boolean | EventListenerOptions |
Returns
void
Inherited from
ts
EventTargetConstructor.removeEventListenerUnsubscriber
Defined in: src/Unsubscriber/index.ts:17
Collects unsubscribe callbacks and calls them all at once via unsubscribe().
Example
ts
const unsub = new Unsubscriber();
unsub.add(store.subscribe(listener));
unsub.add(emitter.subscribe(handler));
unsub.unsubscribe(); // cancels both subscriptionsImplements
Constructors
Constructor
ts
new Unsubscriber(unsubscribers?): Unsubscriber;Defined in: src/Unsubscriber/index.ts:20
Parameters
| Parameter | Type |
|---|---|
unsubscribers? | TUnsubscriberUnsubscribe[] |
Returns
Methods
add()
ts
add(...unsubscribers): IUnsubscriberUnsubscribeFn;Defined in: src/Unsubscriber/index.ts:24
Adds one or more unsubscribers; returns a function that removes them all.
Parameters
| Parameter | Type |
|---|---|
...unsubscribers | TUnsubscriberUnsubscribe[] |
Returns
Implementation of
unsubscribe()
ts
unsubscribe(): void;Defined in: src/Unsubscriber/index.ts:28
Calls all registered unsubscribers and clears the list.
Returns
void
Implementation of
Interfaces
BaseLineDecoder
Defined in: src/LineDecoder.ts:31
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Methods
end()
ts
end(chunk?, output?): T[];Defined in: src/LineDecoder.ts:47
Ends the decoder.
Parameters
| Parameter | Type | Description |
|---|---|---|
chunk? | string | The chunk of text to end the decoder with. |
output? | T[] | The output array to end the decoder with. |
Returns
T[]
The output array.
write()
ts
write(chunk, output?): T[];Defined in: src/LineDecoder.ts:39
Writes a chunk of text to the decoder.
Parameters
| Parameter | Type | Description |
|---|---|---|
chunk | string | The chunk of text to write. |
output? | T[] | The output array to write the chunk to. |
Returns
T[]
The output array.
IColor()
Defined in: src/color.ts:15
ts
IColor(v, alt?): string[];Defined in: src/color.ts:16
Parameters
| Parameter | Type |
|---|---|
v | string |
alt? | boolean |
Returns
string[]
Properties
| Property | Type | Defined in |
|---|---|---|
base | (rgbaColor, alt?) => string[] | src/color.ts:20 |
double | (v, start) => number | src/color.ts:18 |
normalize | (v, alpha?, w?, l?) => [number, number, number, number] | src/color.ts:19 |
one | (v) => number | src/color.ts:17 |
rgbStringify | (rgb) => string | src/color.ts:21 |
IColorRange()
Defined in: src/colorRange.ts:3
ts
IColorRange(colors, precision): string[];Defined in: src/colorRange.ts:4
Parameters
| Parameter | Type |
|---|---|
colors | [number, number, number, number][] |
precision | number |
Returns
string[]
Properties
| Property | Type | Defined in |
|---|---|---|
base | (input, precision) => [number, number, number, number][] | src/colorRange.ts:5 |
rgba | (rgbaColor) => string | src/colorRange.ts:6 |
IComplement()
Defined in: src/complement.ts:7
ts
IComplement<TDst, TSrc>(
dst,
src,
depth): TDst | TSrc;Defined in: src/complement.ts:8
Type Parameters
| Type Parameter |
|---|
TDst extends Record<string, any> |
TSrc extends ComplementSource |
Parameters
| Parameter | Type |
|---|---|
dst | TDst |
src | TSrc |
depth | number |
Returns
TDst | TSrc
Properties
| Property | Type | Defined in |
|---|---|---|
base | (dst, src, depth) => Record<string, any> | src/complement.ts:9 |
IDecorate()
Defined in: src/decorate.ts:6
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
ts
IDecorate(emit): T;Defined in: src/decorate.ts:7
Parameters
| Parameter | Type |
|---|---|
emit | T |
Returns
T
Properties
| Property | Type | Defined in |
|---|---|---|
use | (decorator) => IDecorate<T> | src/decorate.ts:8 |
IDestroyer()
Defined in: src/destroyProvider.ts:7
ts
IDestroyer(): boolean;Defined in: src/destroyProvider.ts:8
Returns
boolean
Properties
| Property | Type | Defined in |
|---|---|---|
add | (...fns) => IDestroyer | src/destroyProvider.ts:9 |
child | () => IDestroyer | src/destroyProvider.ts:11 |
clear | () => IDestroyer | src/destroyProvider.ts:13 |
isDestroyed | () => boolean | src/destroyProvider.ts:12 |
remove | (fn) => IDestroyer | src/destroyProvider.ts:10 |
IEventEmitter
Defined in: src/EventEmitter/types.ts:20
Minimal event-emitter interface.
Example
ts
const emitter: IEventEmitter<string> = new EventEmitter();
const off = emitter.subscribe((value) => console.log(value));
off(); // removes the listener
emitter.destroy();Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Methods
clear()
ts
clear(): void;Defined in: src/EventEmitter/types.ts:26
Removes all listeners without destroying the emitter.
Returns
void
destroy()
ts
destroy(): void;Defined in: src/EventEmitter/types.ts:24
Destroys the emitter and clears all listeners.
Returns
void
subscribe()
ts
subscribe(...listeners): IEventEmitterUnsubscribe;Defined in: src/EventEmitter/types.ts:22
Registers one or more listeners; returns a function that removes them all.
Parameters
| Parameter | Type |
|---|---|
...listeners | IEventEmitterListener<T>[] |
Returns
IEventEmitterListener()
Defined in: src/EventEmitter/types.ts:7
Listener callback passed to subscribe.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
ts
IEventEmitterListener(value): void;Defined in: src/EventEmitter/types.ts:8
Listener callback passed to subscribe.
Parameters
| Parameter | Type |
|---|---|
value | T |
Returns
void
IEventEmitterUnsubscribe()
Defined in: src/EventEmitter/types.ts:2
Function returned by subscribe — call it to remove the listener.
ts
IEventEmitterUnsubscribe(): void;Defined in: src/EventEmitter/types.ts:3
Function returned by subscribe — call it to remove the listener.
Returns
void
ILimitStream()
Defined in: src/limitStream/index.ts:3
ts
ILimitStream(): Promise<any[]>;Defined in: src/limitStream/index.ts:4
Returns
Promise<any[]>
Properties
| Property | Type | Defined in |
|---|---|---|
close | () => void | src/limitStream/index.ts:5 |
ILineBasedFormatOptions
Defined in: src/LineBasedFormat.ts:1
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
parse | (input) => any | Parses a string into an array of values. | src/LineBasedFormat.ts:8 |
stringify | (input) => string | Stringifies an array of values into a string. | src/LineBasedFormat.ts:15 |
ILineDecoderBaseOptions
Defined in: src/LineDecoder.ts:3
Extended by
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
skipEmptyLines? | boolean | Whether to skip empty lines. Default false | src/LineDecoder.ts:9 |
ILineDecoderConstructor
Defined in: src/LineDecoder.ts:21
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Constructors
Constructor
ts
new ILineDecoderConstructor(options?): BaseLineDecoder<T>;Defined in: src/LineDecoder.ts:28
Creates a new line decoder.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | ILineDecoderBaseOptions | The options for the line decoder. |
Returns
The line decoder.
ILineDecoderOptions
Defined in: src/LineDecoder.ts:11
Extends
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
parse? | (line) => T | Parses a line of text into a value. | - | src/LineDecoder.ts:18 |
skipEmptyLines? | boolean | Whether to skip empty lines. Default false | ILineDecoderBaseOptions.skipEmptyLines | src/LineDecoder.ts:9 |
IRemove()
Defined in: src/remove.ts:4
ts
IRemove(ctx, path): any;Defined in: src/remove.ts:15
Removes a property at a dot-separated path from the context object. Mutates and returns the context.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | any | The context object. |
path | string | The dot-separated path to the property to remove. |
Returns
any
The context object.
Example
ts
remove({ a: { b: 1 } }, 'a.b'); // => { a: {} }Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
base | (ctx, path) => any | Removes a property at a dot-separated path from the context object. Mutates and returns the context. | src/remove.ts:25 |
IStack
Defined in: src/stackProvider.ts:3
Type Parameters
| Type Parameter |
|---|
T |
Methods
eachPop()
ts
eachPop(iteratee): void;Defined in: src/stackProvider.ts:23
Iterates over the stack and pops each item.
Parameters
| Parameter | Type | Description |
|---|---|---|
iteratee | (item) => void | The function to call for each item. |
Returns
void
has()
ts
has(): boolean;Defined in: src/stackProvider.ts:30
Checks if the stack has any items.
Returns
boolean
Whether the stack has any items.
pop()
ts
pop(): T;Defined in: src/stackProvider.ts:9
Pops the last item from the stack.
Returns
T
The popped item.
push()
ts
push(data): void;Defined in: src/stackProvider.ts:16
Pushes an item onto the stack.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | T | The item to push. |
Returns
void
IStringifyCss()
Defined in: src/cssPropertiesStringifyProvider.ts:8
ts
IStringifyCss(props, important?): string;Defined in: src/cssPropertiesStringifyProvider.ts:9
Parameters
| Parameter | Type |
|---|---|
props | TCssProps |
important? | boolean |
Returns
string
Properties
| Property | Type | Defined in |
|---|---|---|
prefixedAttrs | TPrefixedAttrs | src/cssPropertiesStringifyProvider.ts:10 |
prefixes | TPrefixes | src/cssPropertiesStringifyProvider.ts:11 |
IUnsubscriber
Defined in: src/Unsubscriber/types.ts:24
Collects unsubscribe callbacks and removes them all at once.
Example
ts
const unsub = new Unsubscriber();
unsub.add(store.subscribe(handler));
unsub.add(emitter.subscribe(listener));
unsub.unsubscribe(); // removes all at onceMethods
add()
ts
add(...unsubscribers): IUnsubscriberUnsubscribeFn;Defined in: src/Unsubscriber/types.ts:26
Adds one or more unsubscribers; returns a function that removes them all.
Parameters
| Parameter | Type |
|---|---|
...unsubscribers | TUnsubscriberUnsubscribe[] |
Returns
unsubscribe()
ts
unsubscribe(): void;Defined in: src/Unsubscriber/types.ts:28
Calls all registered unsubscribers and clears the list.
Returns
void
IUnsubscriberUnsubscribeFn()
Defined in: src/Unsubscriber/types.ts:2
Plain unsubscribe function.
ts
IUnsubscriberUnsubscribeFn(): void;Defined in: src/Unsubscriber/types.ts:3
Plain unsubscribe function.
Returns
void
IUnsubscriberUnsubscribeObject
Defined in: src/Unsubscriber/types.ts:7
Object with an unsubscribe() method (RxJS-compatible).
Methods
unsubscribe()
ts
unsubscribe(): void;Defined in: src/Unsubscriber/types.ts:8
Returns
void
IVariantsProviderOptions
Defined in: src/variantsProvider.ts:14
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
maxDepth | number | Максимальная глубина вложенности пар scope. Number.POSITIVE_INFINITY — без ограничения. Любое конечное <= 0 (в т.ч. отрицательные) — как 0: группы запрещены. NaN — ошибка при создании провайдера (TypeError). Конечное > 0 — лимит уровней. Удобно, если то же поле приходит из внешнего конфига в широком диапазоне без отдельной нормализации под этот модуль. | src/variantsProvider.ts:28 |
maxOutputCount? | number | Верхняя граница числа строк в результате развёртки (длина массива до unslash). undefined / Number.POSITIVE_INFINITY — без ограничения. Конечное <= 0 — как 0 (любая непустая развёртка — ошибка при вызове). NaN — TypeError при создании фабрики. При превышении лимита — RangeError на вызове возвращаемой функции (после полной сборки массива строк в variantsBuildSplit). | src/variantsProvider.ts:36 |
scopeEnd | string | Закрывающая граница группы (в MN по умолчанию )). Допускается любая непустая подстрока, отличная от scopeStart. | src/variantsProvider.ts:20 |
scopeStart | string | Открывающая граница группы (в MN по умолчанию (). Допускается любая непустая подстрока. | src/variantsProvider.ts:18 |
separator | string | Разделитель альтернатив внутри группы (в MN по умолчанию ` | ). Может быть подстрокой — см. escapedSplitProvider`. |
Store
Defined in: src/store.ts:22
A store.
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of the state. |
Methods
getState()
ts
getState(): T;Defined in: src/store.ts:28
Gets the state of the store.
Returns
T
The state of the store.
map()
ts
map<U>(fn): Store<U>;Defined in: src/store.ts:44
Maps the store.
Type Parameters
| Type Parameter |
|---|
U |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (state) => U | The function to map the store. |
Returns
Store<U>
The mapped store.
watch()
ts
watch(fn): Unsubscribe;Defined in: src/store.ts:36
Watches the store.
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | Watcher<T> | The function to watch the store. |
Returns
A function that unsubscribes from the store.
Type Aliases
ComplementSource
ts
type ComplementSource = Record<string, any>;Defined in: src/complement.ts:5
ComplementTarget
ts
type ComplementTarget = Record<string, any> | undefined;Defined in: src/complement.ts:4
CurryFn
ts
type CurryFn<F> = (...args) => ReturnType<F>;Defined in: src/curry.ts:1
Type Parameters
| Type Parameter |
|---|
F extends (...args) => any |
Parameters
| Parameter | Type |
|---|---|
...args | any[] |
Returns
ReturnType<F>
Decorator
ts
type Decorator<T> = (emit) => T;Defined in: src/decorate.ts:4
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type |
|---|---|
emit | T |
Returns
T
ScopeNode
ts
type ScopeNode = string | ScopeNode[];Defined in: src/scopeSplit.ts:1
StoreWritable
ts
type StoreWritable<T> = Store<T> & {
setState: void;
};Defined in: src/store.ts:52
A writable store.
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
setState() | (next) => void | Sets the state of the store. | src/store.ts:58 |
Type Parameters
| Type Parameter | Description |
|---|---|
T | The type of the state. |
TChainErrorHandler
ts
type TChainErrorHandler<TReq> = (error, req) => void;Defined in: src/responsibilityChain.ts:6
Type Parameters
| Type Parameter | Default type |
|---|---|
TReq | any |
Parameters
| Parameter | Type |
|---|---|
error | unknown |
req | TReq |
Returns
void
TChainHandler
ts
type TChainHandler<TReq> = (req, next) => any;Defined in: src/responsibilityChain.ts:1
Type Parameters
| Type Parameter | Default type |
|---|---|
TReq | any |
Parameters
| Parameter | Type |
|---|---|
req | TReq |
next | (req?) => any |
Returns
any
TCookieStorage
ts
type TCookieStorage = StoreWritable<any> & {
clear: () => TCookieStorage;
get: (key) => any;
getKeys: () => string[];
remove: (key) => TCookieStorage;
set: (key, value) => TCookieStorage;
};Defined in: src/cookieStorageProvider.ts:10
Type Declaration
| Name | Type | Defined in |
|---|---|---|
clear() | () => TCookieStorage | src/cookieStorageProvider.ts:15 |
get() | (key) => any | src/cookieStorageProvider.ts:12 |
getKeys() | () => string[] | src/cookieStorageProvider.ts:14 |
remove() | (key) => TCookieStorage | src/cookieStorageProvider.ts:13 |
set() | (key, value) => TCookieStorage | src/cookieStorageProvider.ts:11 |
TCookieWindowContext
ts
type TCookieWindowContext = {
document: {
cookie: string;
};
};Defined in: src/cookieStorageProvider.ts:4
Properties
document
ts
document: {
cookie: string;
};Defined in: src/cookieStorageProvider.ts:5
| Name | Type | Defined in |
|---|---|---|
cookie | string | src/cookieStorageProvider.ts:6 |
TCssMap
ts
type TCssMap = Record<string, string[]>;Defined in: src/cssPropertiesParseSimple.ts:9
TCssProps
ts
type TCssProps = Record<string, string | string[]>;Defined in: src/cssPropertiesStringifyProvider.ts:6
TDestroyFn
ts
type TDestroyFn = () => void;Defined in: src/destroyProvider.ts:5
Returns
void
TLocalStorage
ts
type TLocalStorage = StoreWritable<any> & {
clear: () => TLocalStorage;
get: (key) => any;
getKeys: () => string[];
remove: (key) => TLocalStorage;
set: (key, value) => TLocalStorage;
};Defined in: src/localStorageProvider.ts:18
Type Declaration
| Name | Type | Description | Defined in |
|---|---|---|---|
clear() | () => TLocalStorage | Clears the local storage. | src/localStorageProvider.ts:52 |
get() | (key) => any | Gets a value from the local storage. | src/localStorageProvider.ts:33 |
getKeys() | () => string[] | Gets the keys from the local storage. | src/localStorageProvider.ts:46 |
remove() | (key) => TLocalStorage | Removes a value from the local storage. | src/localStorageProvider.ts:40 |
set() | (key, value) => TLocalStorage | Sets a value in the local storage. | src/localStorageProvider.ts:26 |
TLocalStorageEvent
ts
type TLocalStorageEvent = {
key: string;
value?: any;
};Defined in: src/localStorageProvider.ts:54
Properties
key
ts
key: string;Defined in: src/localStorageProvider.ts:58
The key of the event.
value?
ts
optional value?: any;Defined in: src/localStorageProvider.ts:62
The value of the event.
TLocalStorageWindowContext
ts
type TLocalStorageWindowContext = {
localStorage: {
length: number;
getItem: string;
key: string;
removeItem: void;
setItem: void;
};
addEventListener: void;
removeEventListener: void;
};Defined in: src/localStorageProvider.ts:6
Properties
localStorage
ts
localStorage: {
length: number;
getItem: string;
key: string;
removeItem: void;
setItem: void;
};Defined in: src/localStorageProvider.ts:7
| Name | Type | Defined in |
|---|---|---|
length | number | src/localStorageProvider.ts:8 |
getItem() | (key) => string | src/localStorageProvider.ts:10 |
key() | (index) => string | src/localStorageProvider.ts:9 |
removeItem() | (key) => void | src/localStorageProvider.ts:12 |
setItem() | (key, value) => void | src/localStorageProvider.ts:11 |
Methods
addEventListener()
ts
addEventListener(
type,
listener,
options?): void;Defined in: src/localStorageProvider.ts:14
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
options? | any |
Returns
void
removeEventListener()
ts
removeEventListener(
type,
listener,
options?): void;Defined in: src/localStorageProvider.ts:15
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (event) => void |
options? | any |
Returns
void
TMapper
ts
type TMapper = (values?, dst?) => Record<string, any>;Defined in: src/mapperProvider.ts:14
A function that maps an array of values to a record.
Parameters
| Parameter | Type | Description |
|---|---|---|
values? | any[] | The values to map. |
dst? | Record<string, any> | The destination record to map the values to. |
Returns
Record<string, any>
The mapped record.
Example
ts
const mapper = mapperProvider([ 'name', 'age']);
mapper([ 'Вася', 30 ]) //=> {name: 'Вася', age: 30}TParams
ts
type TParams = Record<string, any>;Defined in: src/unparam.ts:7
TPrefixedAttrs
ts
type TPrefixedAttrs = Record<string, Record<string, boolean> | boolean>;Defined in: src/cssPropertiesStringifyProvider.ts:4
TPrefixes
ts
type TPrefixes = Record<string, boolean>;Defined in: src/cssPropertiesStringifyProvider.ts:5
TReadyDocumentContext
ts
type TReadyDocumentContext = {
readyState: string;
addEventListener: void;
removeEventListener: void;
};Defined in: src/readyProvider.ts:5
Properties
readyState
ts
readyState: string;Defined in: src/readyProvider.ts:6
Methods
addEventListener()
ts
addEventListener(
type,
listener,
useCapture?): void;Defined in: src/readyProvider.ts:7
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (e) => void |
useCapture? | boolean |
Returns
void
removeEventListener()
ts
removeEventListener(
type,
listener,
useCapture?): void;Defined in: src/readyProvider.ts:8
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (e) => void |
useCapture? | boolean |
Returns
void
TReadyFn
ts
type TReadyFn = (fn, args?, ctx?) => TReadyUnsubscribe | void;Defined in: src/readyProvider.ts:19
Parameters
| Parameter | Type |
|---|---|
fn | (...args) => any |
args? | any[] |
ctx? | any |
Returns
TReadyUnsubscribe | void
TReadyUnsubscribe
ts
type TReadyUnsubscribe = () => boolean;Defined in: src/readyProvider.ts:17
Returns
boolean
TReadyWindowContext
ts
type TReadyWindowContext = {
document: TReadyDocumentContext;
addEventListener: void;
removeEventListener: void;
};Defined in: src/readyProvider.ts:11
Properties
document
ts
document: TReadyDocumentContext;Defined in: src/readyProvider.ts:12
Methods
addEventListener()
ts
addEventListener(
type,
listener,
useCapture?): void;Defined in: src/readyProvider.ts:13
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (e) => void |
useCapture? | boolean |
Returns
void
removeEventListener()
ts
removeEventListener(
type,
listener,
useCapture?): void;Defined in: src/readyProvider.ts:14
Parameters
| Parameter | Type |
|---|---|
type | string |
listener | (e) => void |
useCapture? | boolean |
Returns
void
TRouteMapper
ts
type TRouteMapper = (text, dst?) => boolean;Defined in: src/regexpMapperProvider.ts:4
Parameters
| Parameter | Type |
|---|---|
text | string |
dst? | Record<string, any> |
Returns
boolean
TScopeToken
ts
type TScopeToken =
| readonly [typeof SCOPE_PREFIX, string]
| readonly [typeof SCOPE_OPEN]
| readonly [typeof SCOPE_CLOSE];Defined in: src/variantsProvider.ts:48
Логическая форма токена (разбор встроен в цикл — отдельный поток кортежей не строится).
TSetStyleSheetDocument
ts
type TSetStyleSheetDocument = {
createTextNode: any;
};Defined in: src/setStyleSheet.ts:1
Methods
createTextNode()
ts
createTextNode(data): any;Defined in: src/setStyleSheet.ts:2
Parameters
| Parameter | Type |
|---|---|
data | string |
Returns
any
TStyleItem
ts
type TStyleItem = {
content?: string | null;
name: string;
revision: number;
};Defined in: src/stylesRenderProvider.ts:16
A style item.
Param
The name of the style.
Param
The revision of the style.
Param
The content of the style.
Properties
content?
ts
optional content?: string | null;Defined in: src/stylesRenderProvider.ts:30
The content of the style.
name
ts
name: string;Defined in: src/stylesRenderProvider.ts:20
The name of the style.
revision
ts
revision: number;Defined in: src/stylesRenderProvider.ts:25
The revision of the style.
TStylesRenderDocument
ts
type TStylesRenderDocument = TSetStyleSheetDocument & {
head: | {
appendChild: any;
removeChild?: any;
}
| null
| undefined;
createElement: any;
getElementById: any;
};Defined in: src/stylesRenderProvider.ts:3
Type Declaration
| Name | Type | Defined in |
|---|---|---|
head | | { appendChild: any; removeChild?: any; } | null | undefined | src/stylesRenderProvider.ts:5 |
createElement() | (tagName) => any | src/stylesRenderProvider.ts:6 |
getElementById() | (id) => any | src/stylesRenderProvider.ts:4 |
TUnsubscriberUnsubscribe
ts
type TUnsubscriberUnsubscribe =
| IUnsubscriberUnsubscribeFn
| IUnsubscriberUnsubscribeObject;Defined in: src/Unsubscriber/types.ts:12
Accepts either a plain function or an object with .unsubscribe().
TUrlOptions
ts
type TUrlOptions = {
alias: string;
child?: Partial<TUrlOptions> | null;
dirname: string;
extension: string;
hostname: string;
password: string;
port: string;
protocol: string;
query: any;
username: string;
};Defined in: src/urlParse.ts:9
Properties
alias
ts
alias: string;Defined in: src/urlParse.ts:15
child?
ts
optional child?: Partial<TUrlOptions> | null;Defined in: src/urlParse.ts:19
dirname
ts
dirname: string;Defined in: src/urlParse.ts:14
extension
ts
extension: string;Defined in: src/urlParse.ts:17
hostname
ts
hostname: string;Defined in: src/urlParse.ts:10
password
ts
password: string;Defined in: src/urlParse.ts:18
port
ts
port: string;Defined in: src/urlParse.ts:12
protocol
ts
protocol: string;Defined in: src/urlParse.ts:11
query
ts
query: any;Defined in: src/urlParse.ts:16
username
ts
username: string;Defined in: src/urlParse.ts:13
TUrlProps
ts
type TUrlProps = Omit<TUrlOptions, "child"> & {
basePath: string;
child?: Partial<TUrlProps> | null;
email: string;
filename: string;
hash: string;
host: string;
href: string;
login: string;
path: string;
port: string;
search: string;
unalias: string;
unextension: string;
unhash: string;
unpath: string;
unsearch: string;
username: string;
userpart: string;
};Defined in: src/urlParse.ts:21
Type Declaration
| Name | Type | Defined in |
|---|---|---|
basePath | string | src/urlParse.ts:26 |
child? | Partial<TUrlProps> | null | src/urlParse.ts:39 |
email | string | src/urlParse.ts:38 |
filename | string | src/urlParse.ts:32 |
hash | string | src/urlParse.ts:25 |
host | string | src/urlParse.ts:29 |
href | string | src/urlParse.ts:22 |
login | string | src/urlParse.ts:37 |
path | string | src/urlParse.ts:27 |
port | string | src/urlParse.ts:30 |
search | string | src/urlParse.ts:23 |
unalias | string | src/urlParse.ts:31 |
unextension | string | src/urlParse.ts:33 |
unhash | string | src/urlParse.ts:24 |
unpath | string | src/urlParse.ts:28 |
unsearch | string | src/urlParse.ts:34 |
username | string | src/urlParse.ts:36 |
userpart | string | src/urlParse.ts:35 |
TVariants
ts
type TVariants = (value, applyUnslash?) => TVariantsResult;Defined in: src/variantsProvider.ts:12
Функция разбора: строка выражения и опционально отключение unslash для сырого вывода.
Parameters
| Parameter | Type |
|---|---|
value | string |
applyUnslash? | boolean |
Returns
Кортеж [массив вариантов, максимальная глубина вложенности scope].
TVariantsResult
ts
type TVariantsResult = readonly [string[], number];Defined in: src/variantsProvider.ts:6
TViewportWindowContext
ts
type TViewportWindowContext = {
document: {
documentElement: {
clientHeight: number;
clientWidth: number;
};
height?: number;
width?: number;
};
innerHeight?: number;
innerWidth?: number;
};Defined in: src/getViewportSizeProvider.ts:1
Properties
document
ts
document: {
documentElement: {
clientHeight: number;
clientWidth: number;
};
height?: number;
width?: number;
};Defined in: src/getViewportSizeProvider.ts:4
| Name | Type | Defined in |
|---|---|---|
documentElement | { clientHeight: number; clientWidth: number; } | src/getViewportSizeProvider.ts:7 |
documentElement.clientHeight | number | src/getViewportSizeProvider.ts:9 |
documentElement.clientWidth | number | src/getViewportSizeProvider.ts:8 |
height? | number | src/getViewportSizeProvider.ts:6 |
width? | number | src/getViewportSizeProvider.ts:5 |
innerHeight?
ts
optional innerHeight?: number;Defined in: src/getViewportSizeProvider.ts:3
innerWidth?
ts
optional innerWidth?: number;Defined in: src/getViewportSizeProvider.ts:2
Unsubscribe
ts
type Unsubscribe = () => void;Defined in: src/store.ts:8
A function that unsubscribes from a store.
Returns
void
A function that unsubscribes from a store.
VariantsChild
ts
type VariantsChild = [string, VariantsChild[]];Defined in: src/variantsProvider.ts:39
Watcher
ts
type Watcher<T> = (state) => void;Defined in: src/store.ts:15
A function that watches a store.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
state | T | The state of the store. |
Returns
void
Variables
cloneDepth
ts
const cloneDepth: ICloneDepth;Defined in: src/cloneDepth.ts:19
Clones an object up to a given depth.
Param
The object to clone.
Param
The depth to clone to.
Returns
The cloned object.
Example
ts
cloneDepth({ a: { b: 1 } }, 1); // => { a: { b: 1 } } (shallow at depth 1)
cloneDepth([1, [2, 3]], 0); // => [1, [2, 3]] (reference, depth 0)color
ts
const color: IColor;Defined in: src/color.ts:36
Converts a color string to an array of color strings.
Param
The color string to convert.
Param
Whether to include alternative color strings.
Returns
An array of color strings.
Example
ts
color('ff0000'); // => ['#f00']
color('ff000080'); // => ['rgba(255,0,0,0.50)']
color('CT'); // => ['currentColor']
color('T'); // => ['Transparent']colorRange
ts
const colorRange: IColorRange;Defined in: src/colorRange.ts:19
Converts an array of colors to an array of strings.
Param
The array of RGBA colors [r, g, b, a] (each 0–1).
Param
Number of interpolation steps between each pair of colors.
Returns
Array of rgba(...) strings.
Example
ts
colorRange([[1, 0, 0, 1], [0, 0, 1, 1]], 1);
// => ['rgba(255,0,0,1)', 'rgba(128,0,128,1)', 'rgba(0,0,255,1)']complement
ts
const complement: IComplement;Defined in: src/complement.ts:22
Fills missing keys from src into dst.
Param
The destination object.
Param
The source object.
Param
The depth of the object.
Returns
The destination object.
Example
ts
complement({ a: 1 }, { a: 99, b: 2 }, 0); // => { a: 1, b: 2 }create
ts
const create: {
(o): any;
(o, properties): any;
} = Object.create;Defined in: src/create.ts:9
Safe Object.create wrapper.
Call Signature
ts
(o): any;Creates an object that has the specified prototype or that has null prototype.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | object | Object to use as a prototype. May be null. |
Returns
any
Call Signature
ts
(o, properties): any;Creates an object that has the specified prototype, and that optionally contains specified properties.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | object | Object to use as a prototype. May be null |
properties | PropertyDescriptorMap & ThisType<any> | JavaScript object that contains one or more property descriptors. |
Returns
any
Example
ts
const obj = create({ greet() { return 'hi'; } });
obj.greet(); // => 'hi'
create(null); // => plain object with no prototypeentries
ts
const entries: {
<T> (o): [string, T][];
(o): [string, any][];
} = Object.entries;Defined in: src/entries.ts:7
Returns [key, value] pairs for all enumerable properties of an object.
Call Signature
ts
<T>(o): [string, T][];Returns an array of key/values of the enumerable own properties of an object
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
o | | { [s: string]: T; } | ArrayLike<T> | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
[string, T][]
Call Signature
ts
(o): [string, any][];Returns an array of key/values of the enumerable own properties of an object
Parameters
| Parameter | Type | Description |
|---|---|---|
o | { } | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
[string, any][]
Example
ts
entries({ a: 1, b: 2 }); // => [['a', 1], ['b', 2]]escapeCss
ts
const escapeCss: (value) => string;Defined in: src/escapeCss.ts:13
Экранирует строку для безопасного использования в CSS‑селекторе.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to escape. |
Returns
string
The escaped string.
Example
ts
escapeCss('hello world'); // => 'hello\\ world'extendDepth
ts
const extendDepth: IExtendDepth;Defined in: src/extendDepth.ts:29
Example
ts
extendDepth({ a: { x: 1 } }, { a: { y: 2 } }, 1); // => { a: { x: 1, y: 2 } }floatval
ts
const floatval: (value, def?, minVal?, maxVal?) => number;Defined in: src/numval.ts:69
Parses a number string and returns the float value.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | The value to parse. |
def? | number | The default value returned when parsing fails (default 0). |
minVal? | number | Optional minimum clamp value. |
maxVal? | number | Optional maximum clamp value. |
Returns
number
The float value, or def if parsing fails.
Example
ts
floatval('3.14'); // => 3.14
floatval('abc'); // => 0formatTime
ts
const formatTime: IFormatTime;Defined in: src/formatTime.ts:53
Formats a date to a string.
Param
The date to format.
Param
The mask to use.
Param
Whether to use UTC time.
Param
The i18n object to use.
Returns
The formatted string.
Example
ts
formatTime(new Date('2024-06-15T08:05:03'), '{yyyy}-{mm}-{dd}'); // => '2024-06-15'
formatTime(new Date('2024-06-15T08:05:03'), '{HH}:{MM}:{ss}'); // => '08:05:03'getData
ts
const getData: (date, utc?, i18n?) => Record<string, string>;Defined in: src/formatTime.ts:92
Gets the data for a date.
Parameters
| Parameter | Type | Description |
|---|---|---|
date | string | number | Date | The date to get the data for. |
utc? | boolean | Whether to use UTC time. |
i18n? | Record<string, string[]> | The i18n object to use. |
Returns
Record<string, string>
The data.
getPrototypeOf
ts
const getPrototypeOf: (o) => any;Defined in: src/getPrototypeOf.ts:12
Safe wrapper around Object.getPrototypeOf.
Returns null when Object.getPrototypeOf is not available.
Returns the prototype of an object.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | any | The object that references the prototype. |
Returns
any
Param
The value to get the prototype of.
Returns
The prototype of the value, or null if the prototype is not available.
Example
ts
getPrototypeOf([]); // => Array.prototype
getPrototypeOf({}); // => Object.prototypegetRFC3339
ts
const getRFC3339: (time, utc?) => string;Defined in: src/formatTime.ts:158
Gets the RFC3339 format for a date.
Parameters
| Parameter | Type | Description |
|---|---|---|
time | string | number | Date | The date to get the RFC3339 format for. |
utc? | boolean | Whether to use UTC time. |
Returns
string
The RFC3339 format.
GLOBAL_CONTEXT
ts
const GLOBAL_CONTEXT: any;Defined in: src/globalContext.ts:12
Unified access to the global object in any environment.
Returns
The global object (globalThis, window, self, or global).
Example
ts
GLOBAL_CONTEXT.setTimeout(() => {}, 0);half
ts
const half: (input, separator, right?) => [string, string, string];Defined in: src/half.ts:29
Splits a string into two parts by the first occurrence of the separator.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | The input string to split. |
separator | string | The separator to split the string by. |
right? | number | boolean | If truthy and separator is absent, returns ['', input, ''] instead of [input, '', '']. |
Returns
[string, string, string]
Tuple [before, after, matchedSeparator].
Example
ts
half('a=b=c', '='); // => ['a', 'b=c', '=']
half('no-sep', ':'); // => ['no-sep', '', '']halfLast
ts
const halfLast: (input, separator, right?) => [string, string, string];Defined in: src/half.ts:41
Splits a string into two parts by the last occurrence of the separator.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | The input string to split. |
separator | string | The separator to split the string by. |
right? | number | boolean | If truthy and separator is absent, returns ['', input, '']. |
Returns
[string, string, string]
Tuple [before, after, matchedSeparator].
Example
ts
halfLast('a=b=c', '='); // => ['a=b', 'c', '=']hasOwn
ts
const hasOwn: (o, v) => boolean = Object.hasOwn;Defined in: src/hasOwn.ts:13
Safe wrapper around Object.prototype.hasOwnProperty.
Determines whether an object has a property with the specified name.
Parameters
| Parameter | Type | Description |
|---|---|---|
o | object | An object. |
v | PropertyKey | A property name. |
Returns
boolean
Param
The object to check the property of.
Param
The property to check.
Returns
Whether the object has the property.
Example
ts
hasOwn({ a: 1 }, 'a'); // => true
hasOwn({ a: 1 }, 'toString'); // => falseintval
ts
const intval: (value, def?, minVal?, maxVal?) => number;Defined in: src/numval.ts:55
Parses a number string and returns the integer value.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | The value to parse. |
def? | number | The default value. |
minVal? | number | The minimum value. |
maxVal? | number | The maximum value. |
Returns
number
The integer value, or def (default 0) if parsing fails.
Example
ts
intval('42px'); // => 42
intval('abc', 7); // => 7
intval(3, 0, 1, 10); // => 3 (clamped to [1,10])keys
ts
const keys: (obj) => string[];Defined in: src/keys.ts:9
Returns enumerable keys of an object as an array of strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | Record<string, any> | The object to get the keys of. |
Returns
string[]
The keys of the object.
Example
ts
keys({ a: 1, b: 2 }) // => ['a', 'b']NATIVE_PUSH
ts
const NATIVE_PUSH: (...items) => number = Array.prototype.push;Defined in: src/pushArray.ts:1
Appends new elements to the end of an array, and returns the new length of the array.
Parameters
| Parameter | Type | Description |
|---|---|---|
...items | any[] | New elements to add to the array. |
Returns
number
NATIVE_SLICE
ts
const NATIVE_SLICE: (start?, end?) => undefined[];Defined in: src/slice.ts:1
Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array. For example, -2 refers to the second to last element of the array.
Parameters
| Parameter | Type | Description |
|---|---|---|
start? | number | The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0. |
end? | number | The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array. |
Returns
undefined[]
normalizeDate
ts
const normalizeDate: (date) => Date;Defined in: src/formatTime.ts:66
Normalizes a date.
Parameters
| Parameter | Type | Description |
|---|---|---|
date | string | number | Date | The date to normalize. |
Returns
Date
The normalized date.
numParse
ts
const numParse: INumParse;Defined in: src/numParse.ts:42
Parses a number string.
Param
The number string to parse.
Returns
The parsed number.
Example
ts
numParse('42') // => 42
numParse('-3.14') // => -3.14remove
ts
const remove: IRemove;Defined in: src/remove.ts:28
variants
ts
const variants: TVariants;Defined in: src/variants.ts:13
Разбор MN-выражения со скобками и |: экземпляр variantsProvider с separator: '|', scopeStart: '(', scopeEnd: ')', безлимитной maxDepth, без maxOutputCount (без лимита числа строк). Свой лимит — через variantsProvider({ ..., maxOutputCount: n }).
Param
— входная строка.
Param
— при false первый элемент кортежа без unslash (по умолчанию эскейпы снимаются).
Returns
Кортеж [массив строк-вариантов, максимальная глубина вложенности scope].
Example
ts
const [names, depth] = variants('P(eter|awel|atrik)');
// names => ['Peter', 'Pawel', 'Patrik'], depth => 1Functions
addOf()
ts
function addOf<T>(collection, item): T[];Defined in: src/addOf.ts:13
Adds an item to a collection if it is not already present.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The array to add the item to. |
item | T | The item to add to the collection. |
Returns
T[]
The collection with the item added.
Example
ts
addOf([1, 2, 3], 2); // => [1, 2, 3] (already present)
addOf([1, 2], 3); // => [1, 2, 3]aggregate()
ts
function aggregate<T>(funcs, aggregator?): (this, ..._args) => any;Defined in: src/aggregate.ts:16
Aggregates an array of functions into a single function.
Type Parameters
| Type Parameter |
|---|
T extends any[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
funcs | AnyFn[] | The functions to aggregate. |
aggregator | Aggregator | The aggregator function to use (defaults to eachApply). |
Returns
A single function that fans the call out to all funcs.
(this, ..._args) => any
Example
ts
const notify = aggregate([logFn, metricsFn]);
notify('event'); // calls logFn('event') and metricsFn('event')asAsync()
ts
function asAsync<A>(fn): Promise<A>;Defined in: src/asAsync.ts:12
Wraps a function in a promise and returns a promise that resolves with the result of the function.
Type Parameters
| Type Parameter |
|---|
A |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | () => A | Promise<A> | The function to wrap. |
Returns
Promise<A>
A promise that resolves with the result of the function.
Example
ts
await asAsync(() => 42); // => 42
await asAsync(() => fetch('/api')); // waits for the fetchattachEvent()
ts
function attachEvent(
ctx,
type,
listener,
options?): TUnsubscribe;Defined in: src/attachEvent.ts:16
Attaches an event listener and returns an unsubscribe function.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | EventTarget | Target to attach event to. |
type | string | Event type (e.g. "click"). |
listener | (event) => any | Event handler. |
options? | TEventListenerOptions | Native addEventListener options. |
Returns
TUnsubscribe
A function that removes the event listener when called.
Example
ts
const off = attachEvent(window, 'resize', () => console.log('resized'));
off(); // removes the listenerbaseSet()
ts
function baseSet(
ctx,
path,
value): any;Defined in: src/set.ts:31
Sets a value in a context by a path array.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | any | The context to set the value in. |
path | ArrayLike<string> | The path to set the value in. |
value | any | The value to set. |
Returns
any
The context.
bind()
ts
function bind<F>(
fn,
ctx,
args?): (...rest) => ReturnType<F>;Defined in: src/bind.ts:13
Like Function.prototype.bind but accepts pre-bound args as an array.
Type Parameters
| Type Parameter |
|---|
F extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | F | Function to bind. |
ctx | any | this context. |
args? | any[] | Optional array of arguments to prepend on each call. |
Returns
Bound function that prepends args before runtime arguments.
(...rest) => ReturnType<F>
Example
ts
const log = bind(console.log, console, ['info:']);
log('Hello'); // console.log('info:', 'Hello')bindMethods()
ts
function bindMethods<T>(self, methods): T;Defined in: src/bindMethods.ts:26
Binds all listed methods of an object to that object in-place.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
self | T | The object whose methods to bind. |
methods | keyof T & string[] | Array of method names to bind. |
Returns
T
The same self object with the methods bound.
Example
ts
class Foo {
value = 1;
inc() { this.value += 1; }
}
const foo = new Foo();
bindMethods(foo, ['inc']);camelToDelimiterCase()
ts
function camelToDelimiterCase(value, delimiter): string;Defined in: src/camelToDelimiterCase.ts:14
Converts camelCase string to delimited case using given delimiter.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
delimiter | string | The delimiter to use. |
Returns
string
The converted string.
Example
ts
camelToDelimiterCase('camelCase', '-') // "camel-case"camelToKebabCase()
ts
function camelToKebabCase(value): string;Defined in: src/camelToKebabCase.ts:11
Converts camelCase string to kebab-case.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
Returns
string
The converted string.
Example
ts
camelToKebabCase('camelCase') // "camel-case"camelToSnakeCase()
ts
function camelToSnakeCase(value): string;Defined in: src/camelToSnakeCase.ts:11
Converts camelCase string to snake_case.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
Returns
string
The converted string.
Example
ts
camelToSnakeCase('camelCase') // "camel_case"cancelProvider()
ts
function cancelProvider(clearFn, id): () => void;Defined in: src/cancelProvider.ts:12
Wraps a clear function and id into a cancel callback.
Parameters
| Parameter | Type | Description |
|---|---|---|
clearFn | (id) => void | The function to clear. |
id | any | The id to clear. |
Returns
A zero-argument function that cancels the timer/operation.
() => void
Example
ts
const id = setTimeout(fn, 1000);
const cancel = cancelProvider(clearTimeout, id);
cancel(); // clears the timeoutchangeProviderProvider()
ts
function changeProviderProvider<TState>(set): (name, prop?, map) => (e) => void;Defined in: src/changeProviderProvider.ts:14
Creates a change handler factory that maps an event.target field to a state value.
Type Parameters
| Type Parameter |
|---|
TState |
Parameters
| Parameter | Type | Description |
|---|---|---|
set | (partial) => void | State setter that accepts a partial state patch. |
Returns
A factory function (name, prop?, map?) that returns an event handler.
(name, prop?, map) => (e) => void
Example
ts
const onChange = changeProviderProvider(set)('name', null, (v) => v.trim());changeProviderProviderSimple()
ts
function changeProviderProviderSimple<TState>(set): (name) => (value) => void;Defined in: src/changeProviderProviderSimple.ts:11
Simplified version of changeProviderProvider: value is passed directly to the setter.
Type Parameters
| Type Parameter |
|---|
TState |
Parameters
| Parameter | Type | Description |
|---|---|---|
set | (partial) => void | Function that applies a partial state update. |
Returns
A function that takes a state key and returns a setter for that key.
(name) => (value) => void
Example
ts
const changeField = changeProviderProviderSimple((patch) => setState(patch));
const setName = changeField('name');
setName('Alice'); // calls setState({ name: 'Alice' })childClass()
ts
function childClass<TParent>(
Parent,
constructor,
proto?): (...args) => InstanceType<TParent>;Defined in: src/childClass.ts:17
Creates a "child" class that wraps a Parent constructor.
Type Parameters
| Type Parameter |
|---|
TParent extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
Parent | TParent | The parent class to wrap. |
constructor | (self, superFn, ...args) => void | The constructor to wrap. |
proto? | Record<string, any> | The prototype to extend. |
Returns
The child class.
(...args) => InstanceType<TParent>
Example
ts
const Child = childClass(Parent, (self, superFn, ...args) => {
self.name = 'child';
});
The `constructor` receives `(self, superFn, ...args)`.childClassOfReact()
ts
function childClassOfReact(
Parent,
constructor,
proto?): {
(): void;
prototype: any;
};Defined in: src/childClassOfReact.ts:16
Creates a "child" class that wraps a Parent constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
Parent | any | The parent class to wrap. |
constructor | (self, props?) => void | The constructor to wrap. |
proto? | Record<string, any> | The prototype to extend. |
Returns
The child class.
{ (): void; prototype: any; }
| Name | Type | Defined in |
|---|---|---|
prototype | any | src/childClassOfReact.ts:26 |
Example
ts
const Child = childClassOfReact(Parent, (self, props) => {
self.name = 'child';
});colorGetBackground()
ts
function colorGetBackground(input, alt?): string[];Defined in: src/colorGetBackground.ts:30
Builds CSS gradient(s) from a compact text description.
Returns a single gradient string when alt is false, or an array of rgb/rgba alternatives when alt is true.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | Compact gradient description string. |
alt? | boolean | Whether to return alternative rgb/rgba variants. |
Returns
string[]
Array of CSS gradient strings.
Example
ts
colorGetBackground('ff0000-0000ff');
// => ['linear-gradient(180deg,#f00 0%,#00f 100%)']
colorGetBackground('ff0000-0000ff_r');
// => ['radial-gradient(circle,#f00 0%,#00f 100%)']convertToBreakLineHTML()
ts
function convertToBreakLineHTML(input): string;Defined in: src/convertToBreakLineHTML.ts:10
Converts a string to a break line HTML.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | The string to convert. |
Returns
string
The converted string.
Example
ts
convertToBreakLineHTML('line1\nline2');
// => '<span>line1</span><span><br/>line2</span>'cookieStorageProvider()
ts
function cookieStorageProvider(ctx): TCookieStorage;Defined in: src/cookieStorageProvider.ts:51
Creates a cookie storage provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | TCookieWindowContext | The Window whose document.cookie is managed. |
Returns
A reactive cookie storage with get, set, remove, getKeys, and clear.
Example
ts
const storage = cookieStorageProvider(window);
storage.set('token', 'abc123');
storage.get('token'); // => 'abc123'
storage.remove('token');createApi()
ts
function createApi<T, E>(store, shape): { [K in string | number | symbol]: (payload: Parameters<E[K]>[1]) => void };Defined in: src/store.ts:113
Creates a new api for the store.
Type Parameters
| Type Parameter |
|---|
T |
E extends Record<string, (state, payload) => T> |
Parameters
| Parameter | Type | Description |
|---|---|---|
store | StoreWritable<T> | The store to create the api for. |
shape | E | The shape of the api. |
Returns
{ [K in string | number | symbol]: (payload: Parameters<E[K]>[1]) => void }
The api.
Example
ts
const store = createStore({ a: 1, b: 2 });
const api = createApi(store, {
setA: (state, payload) => ({ ...state, a: payload }),
setB: (state, payload) => ({ ...state, b: payload }),
});
api.setA(3);
store.getState(); // => { a: 3, b: 2 }createInterval()
ts
function createInterval(
callback,
delay?,
args?,
ctx?): () => void;Defined in: src/createInterval.ts:13
Creates an interval.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
callback | (...args) => any | undefined | The callback to call when the interval is ready. |
delay | number | 250 | The delay to call the callback. |
args? | any[] | undefined | The arguments to pass to the callback. |
ctx? | any | undefined | The context to pass to the callback. |
Returns
The function to stop the interval.
() => void
Example
ts
const stop = createInterval(() => console.log('tick'), 500);
stop(); // cancels the intervalcreateStore()
ts
function createStore<T>(initial): StoreWritable<T>;Defined in: src/store.ts:67
Creates a new store.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
initial | T | The initial state. |
Returns
The store.
createTimeout()
ts
function createTimeout(
callback,
timeout?,
args?,
ctx?): () => void;Defined in: src/createTimeout.ts:13
Creates a timeout.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | (...args) => any | The callback to call when the timeout is ready. |
timeout? | number | The timeout to call the callback. |
args? | ArrayLike<any> | The arguments to pass to the callback. |
ctx? | any | The context to pass to the callback. |
Returns
The function to stop the timeout.
() => void
Example
ts
const cancel = createTimeout(() => console.log('done'), 1000);
cancel(); // cancels before it firescssPropertiesParseSimple()
ts
function cssPropertiesParseSimple(text, output?): TCssMap;Defined in: src/cssPropertiesParseSimple.ts:23
Parses a CSS string of the form "color:red; font-size: 12px" into an object.
Values for one property are collected into an array of strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
text | string | CSS string to parse. |
output? | TCssMap | Optional destination object to merge into. |
Returns
Map of camelCase property names to arrays of value strings.
Example
ts
cssPropertiesParseSimple('color:red; font-size:12px');
// => { color: ['red'], fontSize: ['12px'] }cssPropertiesStringifyProvider()
ts
function cssPropertiesStringifyProvider(prefixedAttrs?, prefixes?): IStringifyCss;Defined in: src/cssPropertiesStringifyProvider.ts:26
Factory function to serialize CSS properties to a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
prefixedAttrs | TPrefixedAttrs | The prefixed attributes. |
prefixes | TPrefixes | The prefixes. |
Returns
The function to serialize CSS properties to a string.
Example
ts
const stringify = cssPropertiesStringifyProvider();
stringify({ color: 'red', fontSize: '12px' }); // => 'color:red;font-size:12px'
stringify({ color: 'red' }, true); // => 'color:red!important'curry()
ts
function curry<F>(fn, ctx?): CurryFn<F>;Defined in: src/curry.ts:14
Curries a function.
Type Parameters
| Type Parameter |
|---|
F extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | F | The function to curry. |
ctx? | any | The context to curry the function with. |
Returns
CurryFn<F>
The curried function.
Example
ts
const add = curry((a: number, b: number) => a + b);
const add5 = add(5);
add5(3); // => 8dateToUTCString()
ts
function dateToUTCString(time): string;Defined in: src/dateToUTCString.ts:18
Converts a date to a UTC string.
Parameters
| Parameter | Type | Description |
|---|---|---|
time | number | Date | The date to convert. |
Returns
string
The UTC string.
Example
ts
dateToUTCString(new Date('2024-01-15T12:30:00Z')); // => '20240115T123000Z'decorate()
ts
function decorate<T>(emit, decorators): IDecorate<T>;Defined in: src/decorate.ts:21
Decorates a function.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
emit | T | The function to decorate. |
decorators | Decorator<T> | Decorator<T>[] | The decorators to apply. |
Returns
IDecorate<T>
The decorated function with the use method.
Example
ts
const fn = decorate(x => x, [logger, cache]);
fn.use(anotherDecorator);defer()
ts
function defer(
fn,
args?,
ctx?): () => void;Defined in: src/defer.ts:20
Schedules function execution as soon as possible using setImmediate, with a fallback to delay when setImmediate is not available.
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | Fn | The function to defer. |
args? | ArrayLike<any> | The arguments to pass to the function. |
ctx? | any | The context to pass to the function. |
Returns
A function that cancels the deferred execution when called.
() => void
Example
ts
const cancel = defer(() => console.log('hi'));
cancel(); // cancels before it runsdeflags()
ts
function deflags(flags): string[];Defined in: src/deflags.ts:13
Returns an array of keys for which the flag value is truthy.
Parameters
| Parameter | Type | Description |
|---|---|---|
flags | Record<string, any> | The flags to get the keys for. |
Returns
string[]
The keys for which the flag value is truthy.
Example
ts
deflags({ a: true, b: false, c: 1 }); // => ['a', 'c']deflagsByString()
ts
function deflagsByString(src, suffix?): string;Defined in: src/deflagsByString.ts:13
Builds a space‑separated flags string from an object and appends a suffix.
Parameters
| Parameter | Type | Description |
|---|---|---|
src | Record<string, any> | The object to build the flags string from. |
suffix? | string | The suffix to append to the flags string. |
Returns
string
The flags string.
Example
ts
deflagsByString({ a: true, b: false, c: true }, 'extra') === 'a c extra'delimiterToCamelCase()
ts
function delimiterToCamelCase(value, delimiter): string;Defined in: src/delimiterToCamelCase.ts:12
Converts a delimited string to camelCase using the given delimiter.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
delimiter | string | The delimiter to use. |
Returns
string
The camelCase string.
Example
ts
delimiterToCamelCase('hello_world', '_') === 'helloWorld'destroyProvider()
ts
function destroyProvider(initial?): IDestroyer;Defined in: src/destroyProvider.ts:27
Accumulates destroyer callbacks and executes them once when called.
Parameters
| Parameter | Type | Description |
|---|---|---|
initial? | TDestroyFn[] | The initial destroyer functions. |
Returns
A destroyer instance. Call it to run all callbacks; returns true if not already destroyed.
Example
ts
const destroy = destroyProvider();
destroy.add(() => console.log('cleaned up'));
destroy(); // => true, logs 'cleaned up'
destroy(); // => false (already destroyed)each()
ts
function each<T, C>(
collection,
iteratee,
ctx?): void;Defined in: src/each.ts:16
Iterates over a collection (array or object) and invokes iteratee for each item.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
C extends Record<string, T> | T[] | Record<string, T> | T[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | C | The collection to iterate over. |
iteratee | (this, value, key, collection) => void | The function to invoke for each item. |
ctx? | any | The context to use for the iteratee. |
Returns
void
void
Example
ts
each([1, 2], (v, i) => console.log(i, v)); // 0 1 / 1 2
each({ a: 1 }, (v, k) => console.log(k, v)); // a 1eachApply()
ts
function eachApply<T>(
funcs,
args?,
context?): void;Defined in: src/eachApply.ts:16
Applies all functions from funcs with the same args and context.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, TFn> | TFn[] |
Parameters
| Parameter | Type | Description |
|---|---|---|
funcs | T | The functions to apply. |
args? | any[] | The arguments to pass to the functions. |
context? | any | The context to pass to the functions. |
Returns
void
void
Example
ts
eachApply([Math.max, Math.min], [3, 1, 2]); // Math.max(3,1,2), Math.min(3,1,2)eachApplyMap()
ts
function eachApplyMap<T, R>(
fns,
args?,
ctx?): Record<string, R> | R[];Defined in: src/eachApplyMap.ts:18
Applies all functions from fns and returns mapped results (array for array‑like input, object otherwise).
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends Record<string, TFn> | TFn[] | - |
R | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fns | T | The functions to apply. |
args? | any[] | The arguments to pass to the functions. |
ctx? | any | The context to pass to the functions. |
Returns
Record<string, R> | R[]
The mapped array or object.
Example
ts
eachApplyMap([x => x + 1, x => x * 2], [5]); // => [6, 10]eachTry()
ts
function eachTry(
funcs,
args?,
context?,
onError?): void;Defined in: src/eachTry.ts:16
Executes all functions with shared args/context, catching errors via onError.
Parameters
| Parameter | Type | Description |
|---|---|---|
funcs | any | Array or object of functions to call. |
args? | any[] | Arguments forwarded to each function. |
context? | any | Optional this context. |
onError? | (err) => void | Optional error handler called if a function throws. |
Returns
void
void
Example
ts
eachTry([fn1, fn2], [arg], null, err => console.error(err));escapedHalfProvider()
ts
function escapedHalfProvider(separator, escaped?): IEscapedHalf;Defined in: src/escapedHalfProvider.ts:39
Creates a helper that splits string into [prefix, suffix, value] where suffix starts with the separator and value is the tail. Escaped fragments are preserved and unescaped via unslash.
Parameters
| Parameter | Type | Description |
|---|---|---|
separator | string | The separator to use. |
escaped? | string | The escaped string. |
Returns
IEscapedHalf
The function to split the string.
Example
ts
const half = escapedHalfProvider(':');
half('key:value'); // => ['key', ':value', 'value']
half('key\\:name:value'); // => ['key:name', ':value', 'value']escapedSplitProvider()
ts
function escapedSplitProvider(separator, escaped?): IEscapedSplit;Defined in: src/escapedSplitProvider.ts:40
Creates a splitter that respects escaped separators.
Parameters
| Parameter | Type | Description |
|---|---|---|
separator | string | The separator to use. |
escaped? | string | The escaped string. |
Returns
IEscapedSplit
The splitter that respects escaped separators.
Example
ts
const split = escapedSplitProvider(',');
split('a,b,c'); // => ['a', 'b', 'c']
split('a\\,b,c'); // => ['a,b', 'c']escapeHTML()
ts
function escapeHTML(v): string;Defined in: src/escapeHTML.ts:9
Escapes HTML‑special characters in a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to escape. |
Returns
string
The escaped string.
Example
ts
escapeHTML('<b>hi</b>'); // => '<b>hi</b>'escapeQuote()
ts
function escapeQuote(v): string;Defined in: src/escapeQuote.ts:11
Escapes double quotes and backslashes.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to escape. |
Returns
string
The escaped string.
Example
ts
escapeQuote('say "hi"'); // => 'say \\"hi\\"'escapeRegExp()
ts
function escapeRegExp(v): string;Defined in: src/escapeRegExp.ts:11
Escapes characters with special meaning in regular expressions.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to escape. |
Returns
string
The escaped string.
Example
ts
escapeRegExp('price: $1.00'); // => 'price: \\$1\\.00'every()
ts
function every<T>(collection, identity): boolean;Defined in: src/every.ts:12
Checks that predicate returns truthy for all items in an array‑like collection.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | ArrayLike<T> | The collection to check. |
identity | (value, index, collection) => any | The identity to check. |
Returns
boolean
true if all elements satisfy the predicate, false otherwise.
Example
ts
every([2, 4, 6], v => v % 2 === 0); // => trueeveryIn()
ts
function everyIn<T>(
collection,
identity,
ctx?): boolean;Defined in: src/everyIn.ts:11
Checks that predicate returns truthy for all own and inherited properties.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T | The object to check. |
identity | (value, key, collection) => any | Predicate called with (value, key, collection). |
ctx? | any | Optional this context for the predicate. |
Returns
boolean
true if all properties satisfy the predicate, false otherwise.
Example
ts
everyIn({ a: 2, b: 4 }, v => v % 2 === 0); // => trueexecuteTry()
ts
function executeTry<T>(
fn,
args?,
context?,
onError?): T;Defined in: src/executeTry.ts:17
Safely executes a function with the given context and arguments.
If the function throws, the optional onError handler is called and the function returns undefined.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (...args) => T | The function to execute. |
args? | IArguments | any[] | The arguments to pass to the function. |
context? | any | The context to pass to the function. |
onError? | (error) => void | The error handler. |
Returns
T
The result of the function, or undefined if an error occurred.
Example
ts
executeTry(() => JSON.parse('bad')); // => undefined
executeTry(() => 42); // => 42extend()
ts
function extend<S, D>(dst, src?): D & S;Defined in: src/extend.ts:10
Extends an object with the properties of another object.
Type Parameters
| Type Parameter |
|---|
S extends Record<string, any> |
D extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
dst | D | The destination object. |
src? | S | The source object. |
Returns
D & S
The destination object.
Example
ts
extend({ a: 1 }, { b: 2, c: 3 }); // => { a: 1, b: 2, c: 3 }extendByPathsMap()
ts
function extendByPathsMap(
dst,
src,
map?): Record<string, any>;Defined in: src/extendByPathsMap.ts:21
Extends dst from src according to a map of paths.
Map shape: { toPath: fromPath | '' }. Empty fromPath means copy whole src (optionally shallow‑extend).
Parameters
| Parameter | Type | Description |
|---|---|---|
dst | Record<string, any> | The destination object. |
src | Record<string, any> | The source object. |
map? | Record<string, string> | The map of paths. |
Returns
Record<string, any>
The destination object.
Example
ts
extendByPathsMap({}, { user: { name: 'Ann' } }, { 'name': 'user.name' });
// => { name: 'Ann' }extendIfEmpty()
ts
function extendIfEmpty(dst, src): Record<string, any>;Defined in: src/extendIfEmpty.ts:10
Copies properties from src to dst only if the key in dst is falsy.
Parameters
| Parameter | Type | Description |
|---|---|---|
dst | Record<string, any> | The destination object. |
src | Record<string, any> | The source object. |
Returns
Record<string, any>
The destination object.
Example
ts
extendIfEmpty({ a: 1, b: 0 }, { b: 99, c: 3 }); // => { a: 1, b: 99, c: 3 }extendOwn()
ts
function extendOwn<TDst, TSrc>(dst, src): TDst & TSrc;Defined in: src/extendOwn.ts:13
Shallowly copies own enumerable properties from src to dst. Mutates and returns dst.
Type Parameters
| Type Parameter |
|---|
TDst extends Record<string, any> |
TSrc extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
dst | TDst | The destination object. |
src | TSrc | The source object. |
Returns
TDst & TSrc
The destination object.
Example
ts
extendOwn({ a: 1 }, { b: 2 }); // => { a: 1, b: 2 }filter()
ts
function filter<T>(
collection,
iteratee,
output?,
ctx?): T[];Defined in: src/filter.ts:12
Filters array‑like collection into an array.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The array to filter. |
iteratee | (value, index, collection) => boolean | The function to call for each item. |
output? | T[] | The array to filter into. |
ctx? | any | The this context to use for the function. |
Returns
T[]
The filtered array.
Example
ts
filter([1, 2, 3, 4], x => x % 2 === 0); // => [2, 4]filterIn()
ts
function filterIn<T>(
collection,
iteratee,
output?,
ctx?): Record<string, T>;Defined in: src/filterIn.ts:12
Filters object properties into a new object.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | Record<string, T> | The object to filter. |
iteratee | (value, key, collection) => any | The function to call for each property. |
output? | Record<string, T> | The object to filter into. |
ctx? | any | The this context to use for the function. |
Returns
Record<string, T>
The filtered object.
Example
ts
filterIn({ a: 1, b: 0, c: 2 }, v => v > 0); // => { a: 1, c: 2 }finallyAll()
ts
function finallyAll(fn, callback?): void;Defined in: src/finallyAll.ts:17
Wraps async workflow so that callback is called when internal counter drops to zero.
fn(inc, dec) should call inc() when starting an async task and dec() when it finishes.
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | (inc, dec) => void | The function to wrap. |
callback? | () => void | The callback to call when the counter drops to zero. |
Returns
void
void
Example
ts
finallyAll((inc, dec) => {
inc(); fetch('/a').finally(dec);
inc(); fetch('/b').finally(dec);
}, () => console.log('all done'));find()
ts
function find<T>(
collection,
iteratee,
ctx?): T;Defined in: src/find.ts:11
Finds first item in array‑like collection that satisfies predicate.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The array to search in. |
iteratee | (value, index, collection) => boolean | The function to call for each item. |
ctx? | any | The this context to use for the function. |
Returns
T
The first item that satisfies the predicate, or undefined if no item is found.
Example
ts
find([1, 2, 3], x => x > 1); // => 2findIn()
ts
function findIn<T>(
collection,
iteratee,
ctx?): T;Defined in: src/findIn.ts:11
Finds first value in object that satisfies predicate.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | Record<string, T> | The object to search in. |
iteratee | (value, key, collection) => boolean | The function to call for each property. |
ctx? | any | The this context to use for the function. |
Returns
T
The first value that satisfies the predicate, or undefined if no value is found.
Example
ts
findIn({ a: 1, b: 2 }, v => v > 1); // => 2findIndex()
ts
function findIndex<T>(
collection,
iteratee,
ctx?): number;Defined in: src/findIndex.ts:11
Finds index of first element in array‑like collection that satisfies predicate.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The array to search in. |
iteratee | (value, index, collection) => boolean | The function to call for each item. |
ctx? | any | The this context to use for the function. |
Returns
number
The index of the first item that satisfies the predicate, or -1 if no item is found.
Example
ts
findIndex([10, 20, 30], v => v > 15); // => 1findIndexLast()
ts
function findIndexLast<T>(
collection,
iteratee,
ctx?): number;Defined in: src/findIndexLast.ts:11
Finds index of last element in array‑like collection that satisfies predicate.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The array to search in. |
iteratee | (value, index, collection) => boolean | The function to call for each item. |
ctx? | any | The this context to use for the function. |
Returns
number
The index of the last item that satisfies the predicate, or -1 if no item is found.
Example
ts
findIndexLast([1, 2, 3, 2], v => v === 2); // => 3findKey()
ts
function findKey<T>(
collection,
iteratee,
ctx?): string;Defined in: src/findKey.ts:11
Finds first key in object that satisfies predicate.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | Record<string, T> | The object to search in. |
iteratee | (value, key, collection) => any | The function to call for each property. |
ctx? | any | The this context to use for the function. |
Returns
string
The first key that satisfies the predicate, or undefined if no key is found.
Example
ts
findKey({ x: 1, y: 2 }, v => v > 1); // => 'y'flags()
ts
function flags(flags, dst?): TFlagsObject;Defined in: src/flags.ts:20
Builds a nested flags object from an array of dot‑separated keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
flags | string[] | The array of dot‑separated keys to build the flags object from. |
dst? | TFlagsObject | The destination object to build the flags object into. |
Returns
TFlagsObject
The flags object.
Example
ts
flags(['apple', 'ban', 'test.use']);
// {
// apple: 1,
// ban: 1,
// test: { use: 1 }
// }flagsByString()
ts
function flagsByString(v, dst?): Record<string, any>;Defined in: src/flagsByString.ts:14
Parses space-separated flags string into an object with { key: 1 }.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | Space-separated string of flag names. |
dst? | Record<string, any> | Optional destination object to merge flags into. |
Returns
Record<string, any>
Object with each flag name mapped to 1.
Example
ts
flagsByString('a b c'); // => { a: 1, b: 1, c: 1 }
flagsByString('foo bar', {}); // => { foo: 1, bar: 1 }flattenDeep()
ts
function flattenDeep<T>(input): T[];Defined in: src/flattenDeep.ts:13
Flattens nested arrays into a single‑level array.
Uses an explicit stack to avoid recursion.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
input | any[] | The array to flatten. |
Returns
T[]
The flattened array.
Example
ts
flattenDeep([1, [2, [3, [4]]]]); // => [1, 2, 3, 4]forEach()
ts
function forEach<T>(
src,
fn,
ctx?): void;Defined in: src/forEach.ts:13
Iterates over an array and calls a function for each item.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
src | T[] | The array to iterate over. |
fn | (this, value, index, collection) => void | The function to call for each item. |
ctx? | any | The this context to use for the function. |
Returns
void
void
Example
ts
forEach([1, 2, 3], (v, i) => console.log(i, v)); // 0 1 / 1 2 / 2 3forIn()
ts
function forIn<T>(
obj,
iteratee,
ctx?): void;Defined in: src/forIn.ts:11
Iterates over all enumerable properties (own + inherited) of an object.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | T | The object to iterate over. |
iteratee | (this, value, key, obj) => void | The function to call for each property. |
ctx? | any | The this context to use for the function. |
Returns
void
void
Example
ts
forIn({ a: 1, b: 2 }, (v, k) => console.log(k, v)); // a 1 / b 2forInOwn()
ts
function forInOwn<T>(
obj,
iteratee,
ctx?): void;Defined in: src/forInOwn.ts:14
Iterates over own enumerable properties of obj and calls iteratee(value, key, obj) for each.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | T | The object to iterate over. |
iteratee | (this, value, key, obj) => void | The function to call for each property. |
ctx? | any | The this context to use for the function. |
Returns
void
void
Example
ts
forInOwn({ a: 1, b: 2 }, (v, k) => console.log(k, v)); // a 1 / b 2fromPairs()
ts
function fromPairs(entries, dst?): Record<string, any>;Defined in: src/fromPairs.ts:10
Converts array of [key, value] pairs into an object.
Parameters
| Parameter | Type | Description |
|---|---|---|
entries | [string, any][] | The array of [key, value] pairs to convert. |
dst? | Record<string, any> | The destination object to convert into. |
Returns
Record<string, any>
The converted object.
Example
ts
fromPairs([['a', 1], ['b', 2]]); // => { a: 1, b: 2 }get()
ts
function get(scope, path): any;Defined in: src/get.ts:67
Gets a value from an object by a dot path string.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | any | The object to get the value from. |
path | string | number | The dot path string to get the value from. |
Returns
any
The value, or null if the path is not found.
Example
ts
get({ a: { b: { c: 42 } } }, 'a.b.c') // => 42
get({ a: { b: { c: 42 } } }, 'a.b.[]') // => undefined
get({ a: { b: { c: 42 } } }, 'a.b.[]', 'd') // => undefined
get({ a: [3, 4, 9] }, 'a.1') // => 4
get({ a: [3, 4, 9] }, 'a[1]') // => 4
get({ a: [3, 4, 9] }, 'a[]') // => 9getBase()
ts
function getBase(scope, path): any;Defined in: src/get.ts:51
Gets a value from an object by a dot path string.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | any | The object to get the value from. |
path | ArrayLike<string | number> | The dot path string to get the value from. |
Returns
any
The value, or null if the path is not found.
Example
ts
getBase({ a: { b: { c: 42 } } }, ['a', 'b', 'c']) // => 42
getBase({ a: { b: { c: 42 } } }, ['a', 'b', '[]']) // => undefined
getBase({ a: { b: { c: 42 } } }, ['a', 'b', '[]', 'd']) // => undefined
getBase({ a: [3, 4, 9] }, ['a', '1']) // => 4
getBase({ a: [3, 4, 9] }, ['a', '[]']) // => 9getByType()
ts
function getByType(
args,
typesMap,
dst?): Record<string, any>;Defined in: src/getByType.ts:14
Maps arguments by their typeof according to typesMap.
typesMap key = typeof string; value = ordered list of output key names assigned to successive matching args.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | any[] | The arguments to map. |
typesMap | Record<string, string[]> | Map of typeof → output key names. |
dst? | Record<string, any> | The destination object. |
Returns
Record<string, any>
The mapped object.
Example
ts
getByType(['hello', 42], { string: ['s'], number: ['n'] });
// => { s: 'hello', n: 42 }getKeyPath()
ts
function getKeyPath(key): string[];Defined in: src/getKeyPath.ts:26
Gets a key path from a key.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The key to get the path from. |
Returns
string[]
The key path. Only bracket contents and the leading dot-path are parsed. Text between brackets (e.g. .name in user[0].name) is NOT captured.
Example
ts
getKeyPath('user.name') // => ['user', 'name']
getKeyPath('user[0]') // => ['user', '0']
getKeyPath('user[0][name]') // => ['user', '0', 'name']
getKeyPath('user[][1]') // => ['user', '[]', '1']
getKeyPath('user..age') // => ['user', '', 'age']
getKeyPath('user[name.age]') // => ['user', 'name', 'age']
getKeyPath(`user["name.age"]`) // => ['user', 'name', 'age']
getKeyPath(`user['name']['age']`) // => ['user', 'name', 'age']
getKeyPath(`user[name][age]`) // => ['user', 'name', 'age']getTree()
ts
function getTree(
src,
id,
dst?,
depth?): any[];Defined in: src/getTree.ts:58
Builds a tree structure from flat array of items with id and parent fields.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
src | { id?: any; parent?: any; }[] | undefined | The source array of items. |
id | any | undefined | The id of the parent item. |
dst? | any[] | undefined | The destination array. |
depth? | number | 10 | The depth of the tree. |
Returns
any[]
The tree structure.
Example
ts
const items = [
{ id: 1, parent: null },
{ id: 2, parent: 1 },
{ id: 3, parent: 1 },
];
getTree(items, null);
// => [{ id: 1, parent: null, childs: [{ id: 2, ... }, { id: 3, ... }] }]getUniqId()
ts
function getUniqId(prefix?): string;Defined in: src/getUniqId.ts:12
Generates an incrementing unique id, optionally prefixed.
Parameters
| Parameter | Type | Description |
|---|---|---|
prefix? | string | Optional prefix for the id. |
Returns
string
A string unique within the current process lifetime.
Example
ts
getUniqId(); // => '0', '1', '2', …
getUniqId('item-'); // => 'item-3', 'item-4', …getViewportSizeProvider()
ts
function getViewportSizeProvider(w): () => [number, number];Defined in: src/getViewportSizeProvider.ts:23
Creates provider of viewport size [width, height] for given window.
Parameters
| Parameter | Type | Description |
|---|---|---|
w | TViewportWindowContext | The window to get the viewport size from. |
Returns
The viewport size provider.
() => [number, number]
Example
ts
const getSize = getViewportSizeProvider(window);
getSize(); // => [1024, 768]getWithContext()
ts
function getWithContext(scope, path): [any, any];Defined in: src/get.ts:16
Gets a value from an object by a dot path string.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | any | The object to get the value from. |
path | ArrayLike<string | number> | The dot path string to get the value from. |
Returns
[any, any]
The value, or null if the path is not found.
Example
ts
getWithContext({ a: { b: { c: 42 } } }, ['a', 'b', 'c']) // => [ { c: 42 }, 42 ]
getWithContext({ a: { b: { c: 42 } } }, ['a', 'b', '[]']) // => [ { c: 42 }, undefined ]
getWithContext({ a: { b: { c: 42 } } }, ['a', 'b', '[]', 'd']) // => [ { c: 42 }, undefined ]
getWithContext({ a: [3, 4, 9] }, ['a', '1']) // => [ [3, 4, 9], 4 ]
getWithContext({ a: [3, 4, 9] }, ['a', '[]']) // => [ [3, 4, 9], 9 ]halfProvider()
ts
function halfProvider(indexOf): (input, separator, right?) => [string, string, string];Defined in: src/half.ts:7
Creates a half provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
indexOf | (input) => number | The index of the separator. |
Returns
The half provider.
(input, separator, right?) => [string, string, string]
includes()
ts
function includes<T>(self, item): boolean;Defined in: src/includes.ts:13
Safe wrapper around Array.prototype.includes with a manual fallback.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
self | ArrayLike<T> | The array to search in. |
item | T | The item to search for. |
Returns
boolean
true if the item is present, false otherwise.
Example
ts
includes([1, 2, 3], 2); // => true
includes(null, 1); // => falseindexOf()
ts
function indexOf<T>(collection, v): number;Defined in: src/indexOf.ts:13
Safe wrapper around Array.prototype.indexOf with a manual fallback.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | ArrayLike<T> | The array to search in. |
v | T | The item to search for. |
Returns
number
The index of the item, or -1 if not found.
Example
ts
indexOf([10, 20, 30], 20); // => 1
indexOf([10, 20], 99); // => -1invoke()
ts
function invoke(
scope,
path,
args?,
ctx?): any;Defined in: src/invoke.ts:38
Invokes a function by path in the scope.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | any | The scope to invoke the function in. |
path | string | number | ArrayLike<string> | The path to the function. |
args? | any[] | The arguments to pass to the function. |
ctx? | any | The context to use for the function. |
Returns
any
The result of the function.
Example
ts
invoke({ fn: (x: number) => x * 2 }, 'fn', [5]); // => 10invokeBase()
ts
function invokeBase(
scope,
path,
args?,
ctx?): any;Defined in: src/invoke.ts:14
Invokes a function by path in the scope.
Parameters
| Parameter | Type | Description |
|---|---|---|
scope | any | The scope to invoke the function in. |
path | ArrayLike<string> | The path to the function. |
args? | any[] | The arguments to pass to the function. |
ctx? | any | The context to use for the function. |
Returns
any
The result of the function.
kebabToCamelCase()
ts
function kebabToCamelCase(value): string;Defined in: src/kebabToCamelCase.ts:11
Converts kebab-case string to camelCase.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
Returns
string
The converted string.
Example
ts
kebabToCamelCase('hello-world') // "helloWorld"last()
ts
function last<T>(input): T;Defined in: src/last.ts:9
Returns the last element of an array‑like value.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
input | ArrayLike<T> | The array‑like value to get the last element of. |
Returns
T
The last element of the array‑like value.
Example
ts
last([1, 2, 3]) // => 3limitStream()
ts
function limitStream(stream, limit?): ILimitStream;Defined in: src/limitStream/index.ts:18
Wraps a readable stream and returns a next() function that resolves with up to limit items per read.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
stream | ReadableStream & { close?: () => void; } | undefined | Source readable stream. |
limit | number | DEFAULT_LIMIT | Maximum items per batch (default: 100). |
Returns
A next() function with a .close() method to stop the stream.
Example
ts
const next = limitStream(jsonlStream, 50);
const batch = await next(); // => up to 50 parsed objectslocalStorageProvider()
ts
function localStorageProvider(win): TLocalStorage;Defined in: src/localStorageProvider.ts:76
Creates a local storage provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
win | TLocalStorageWindowContext | The Window whose localStorage is managed. |
Returns
A reactive store with get, set, remove, getKeys, and clear.
Example
ts
const storage = localStorageProvider(window);
storage.set('user', { name: 'Alice' });
storage.get('user'); // => { name: 'Alice' }
storage.remove('user');loop()
ts
function loop(
length,
fn,
start?): void;Defined in: src/loop.ts:11
Simple synchronous loop utility that calls fn for indices [start, length).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
length | number | undefined | The length of the loop. |
fn | (index) => void | undefined | The function to call for each index. |
start | number | 0 | The start index. |
Returns
void
void
Example
ts
loop(10, (index) => console.log(index)); // => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9loopMap()
ts
function loopMap<T>(
length,
fn,
output?): T[];Defined in: src/loopMap.ts:16
Maps indices [i, length) to values using provided function.
If fn is not a function, wraps it with wrapper(fn).
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
length | number | The length of the loop. |
fn | any | The function to call for each index. |
output? | T[] | The output array to write the values to. |
Returns
T[]
The output array.
Example
ts
loopMap(10, (index) => index * 2); // => [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]lowerFirst()
ts
function lowerFirst(v): string;Defined in: src/lowerFirst.ts:11
Lowercases the first character of the string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to lowercase the first character of. |
Returns
string
The string with the first character lowercased.
Example
ts
lowerFirst('Hello') // => 'hello'map()
ts
function map<T, R>(
collection,
iteratee,
output?,
ctx?): R[];Defined in: src/map.ts:12
Maps array‑like collection to an array.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
R | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The collection to map. |
iteratee | (value, index, collection) => R | The function to call for each item. |
output? | R[] | The array to map into. |
ctx? | any | The this context to use for the function. |
Returns
R[]
The mapped array.
Example
ts
map([1, 2, 3], x => x * 2); // => [2, 4, 6]mapIn()
ts
function mapIn<T, R>(
collection,
iteratee,
output?,
ctx?): Record<string, R>;Defined in: src/mapIn.ts:12
Maps over object properties into an output object.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
R | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | Record<string, T> | The object to map. |
iteratee | (value, key, collection) => R | The function to call for each property. |
output? | Record<string, R> | The object to map into. |
ctx? | any | The this context to use for the function. |
Returns
Record<string, R>
The mapped object.
Example
ts
mapIn({ a: 1, b: 2 }, v => v * 10); // => { a: 10, b: 20 }mapperProvider()
ts
function mapperProvider(keys): TMapper;Defined in: src/mapperProvider.ts:22
Creates a new mapper provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
keys | string[] | The keys to map the values to. |
Returns
The mapper provider.
merge()
ts
function merge(
mergingSrc,
dst?,
asArray?): any;Defined in: src/merge.ts:20
Merges an array of values into a single value.
Parameters
| Parameter | Type | Description |
|---|---|---|
mergingSrc | any | The values to merge. |
dst? | any | The destination object. |
asArray? | boolean | Whether to treat the mergingSrc as an array. |
Returns
any
The merged value.
Example
ts
merge([1, 2, 3]) // => 3
merge([{ a: 1 }, { b: 2 }]) // => { a: 1, b: 2 }
merge([{ a: 1 }, { b: 2 }], { c: 3 }) // => { c: 3, a: 1, b: 2 }
merge([{ a: 1 }, { b: 2 }], { c: 3 }, true) // => [{ c: 3, a: 1 }, { c: 3, b: 2 }]noop()
ts
function noop(): void;Defined in: src/noop.ts:7
Empty function that does nothing.
Returns
void
Example
ts
subscribe(store, noop); // subscribe without reacting to changesnoopHandle()
ts
function noopHandle<T>(v): T;Defined in: src/noopHandle.ts:9
No-op handler that returns the value unchanged.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
v | T | The value to pass through. |
Returns
T
The same value unchanged.
Example
ts
[1, 2, 3].filter(noopHandle); // => [1, 2, 3] (keeps truthy values)normalizeStep()
ts
function normalizeStep(step?, limit?): number;Defined in: src/normalizeStep.ts:11
Normalizes a step value.
Parameters
| Parameter | Type | Description |
|---|---|---|
step? | string | The step value to normalize. |
limit? | number | The limit value to normalize the step value to. |
Returns
number
The normalized step value.
Example
ts
normalizeStep('10') // => 10
normalizeStep('10', 100) // => 10normalizeTimePart()
ts
function normalizeTimePart(n): string;Defined in: src/dateToUTCString.ts:7
Normalizes a time part.
Parameters
| Parameter | Type | Description |
|---|---|---|
n | number | The time part to normalize. |
Returns
string
The normalized time part.
once()
ts
function once<T>(func): T;Defined in: src/once.ts:11
Wraps a function so that it is executed only once.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
func | T | The function to wrap. |
Returns
T
The wrapped function.
Example
ts
const onceFunc = once(() => console.log('once'));
onceFunc(); // => 'once'
onceFunc();onEnterProvider()
ts
function onEnterProvider(handle): (e) => void;Defined in: src/onEnterProvider.ts:10
Creates key handler that calls handle on Enter key.
Parameters
| Parameter | Type | Description |
|---|---|---|
handle | () => void | The function to call when the Enter key is pressed. |
Returns
The function to call when the Enter key is pressed.
(e) => void
Example
ts
const onEnter = onEnterProvider(() => console.log('Enter key pressed'));
onEnter({ key: 'Enter' }); // => 'Enter key pressed'onlyBy()
ts
function onlyBy(
collection,
iteratee?,
compare?): any;Defined in: src/onlyBy.ts:22
Returns only one item from collection by applying comparator to iteratee result.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | ArrayLike<any> | undefined | The collection to search in. |
iteratee | (item, index, collection) => any | noopHandle | The iteratee to apply to each item. |
compare? | boolean | CompareFn | undefined | The comparator to use. |
Returns
any
The only item from the collection.
Example
ts
onlyBy([1, 2, 3], (item) => item, (v, w) => v > w); // => 3onlyByIn()
ts
function onlyByIn(
collection,
iteratee?,
compare?): any;Defined in: src/onlyBy.ts:57
Returns only one item from collection by applying comparator to iteratee result.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, any> | undefined | The collection to search in. |
iteratee | (item, key, collection) => any | noopHandle | The iteratee to apply to each item. |
compare? | boolean | CompareFn | undefined | The comparator to use. |
Returns
any
The only item from the collection.
Example
ts
onlyByIn({ a: 1, b: 2, c: 3 }, (item) => item, (v, w) => v > w); // => 3padEnd()
ts
function padEnd(
v,
length,
space?): string;Defined in: src/padEnd.ts:14
Polyfill-friendly padEnd implementation for strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to pad. |
length | number | The length to pad the string to. |
space? | string | The string to use for padding. |
Returns
string
The padded string.
Example
ts
padEnd('hello', 10, '0'); // => 'hello00000'padStart()
ts
function padStart(value, ...args): string;Defined in: src/padStart.ts:13
Polyfill-friendly padStart implementation for strings.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to pad. |
...args | [number, string] | - |
Returns
string
The padded string.
Example
ts
padStart('hello', 10, '0'); // => '00000hello'param()
ts
function param(v): string;Defined in: src/param.ts:13
Constructs a query string from a given object.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | any | The object to construct a query string from. |
Returns
string
The query string.
Example
ts
param({ a: 1, b: 'x' }); // => 'a=1&b=x'paramEscape()
ts
function paramEscape(v): string;Defined in: src/param.ts:49
Escapes a string for use in a query string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to escape. |
Returns
string
The escaped string.
Example
ts
paramEscape('a=1&b=x'); // => 'a%3D1%26b%3Dx'
paramEscape('a:1,b:x'); // => 'a%3A1%2Cb%3Ax'
paramEscape('a"1,b"x'); // => 'a%221%2Cb%22x'
paramEscape('a+1,b+x'); // => 'a%2B1%2Cb%2Bx'physicRenderProvider()
ts
function physicRenderProvider(
fn,
timestep,
runner?): {
isPlaying: () => boolean;
pause: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
play: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
};Defined in: src/physicRenderProvider.ts:16
Provides simple "physics" render loop with fixed timestep.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
fn | (timestep) => void | undefined | The function to call on each timestep. |
timestep | number | undefined | The timestep to use. |
runner | (fn, delayMs, args?, self?) => () => void | intervalAsync | The runner to use. |
Returns
ts
{
isPlaying: () => boolean;
pause: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
play: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
}The physic render provider.
| Name | Type | Defined in |
|---|---|---|
isPlaying() | () => boolean | src/physicRenderProvider.ts:54 |
pause() | () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; } | src/physicRenderProvider.ts:52 |
play() | () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; } | src/physicRenderProvider.ts:53 |
Example
ts
const physicRender = physicRenderProvider((timestep) => console.log(timestep));
physicRender.play(); // => void
physicRender.pause(); // => void
physicRender.isPlaying(); // => booleanpick()
ts
function pick(
input,
keys,
output?,
outOther?): Record<string, any>;Defined in: src/pick.ts:14
Picks keys from input into output. Optionally fills outOther with the rest.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | Record<string, any> | The input object to pick keys from. |
keys | (string | number)[] | The keys to pick. |
output? | Record<string, any> | The output object to write into. |
outOther? | Record<string, any> | The object to write the rest into. |
Returns
Record<string, any>
The picked object.
Example
ts
pick({ a: 1, b: 2, c: 3 }, ['a', 'c']); // => { a: 1, c: 3 }
pick({ a: 1, b: 2, c: 3 }, ['a', 'c'], {}, { b: 2, c: 3 }); // => { a: 1, c: 3 }pickByMap()
ts
function pickByMap<T, M>(
src,
map,
dst?): Partial<T>;Defined in: src/pickByMap.ts:13
Returns a new object containing only the fields of src for which map has a truthy value.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
M extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
src | T | The source object. |
map | M | The map object. |
dst? | Partial<T> | The destination object to write into. |
Returns
Partial<T>
The picked object.
Example
ts
pickByMap({ a: 1, b: 2, c: 3 }, { a: true, c: true }); // => { a: 1, c: 3 }
pickByMap({ a: 1, b: 2, c: 3 }, { a: true, c: true }, { b: 2 }); // => { a: 1, c: 3 } // => { a: 1, c: 3 }promisify()
ts
function promisify<F>(fn, PromiseCtor?): (this, ...args) => Promise<any>;Defined in: src/promisify.ts:13
Wraps node‑style callback function into Promise‑based one.
Type Parameters
| Type Parameter |
|---|
F extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | F | The function to wrap. |
PromiseCtor? | PromiseConstructor | The Promise constructor to use. |
Returns
The wrapped function.
(this, ...args) => Promise<any>
Example
ts
const fn = promisify((callback) => callback(null, 'hello'));
fn().then((result) => console.log(result)); // => 'hello'providerOfIsClass()
ts
function providerOfIsClass(getter): (instance) => boolean;Defined in: src/providerOfIsClass.ts:11
Creates predicate that checks instance of a class by getter.
Parameters
| Parameter | Type | Description |
|---|---|---|
getter | () => any | The getter to use. |
Returns
The predicate.
(instance) => boolean
Example
ts
const isClass = providerOfIsClass(() => Class);
isClass(new Class()); // => true
isClass(new Class2()); // => falsepush()
ts
function push<T>(self, ...items): T[];Defined in: src/push.ts:12
Pushes additional arguments into array self.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
self | T[] | The array to push the items into. |
...items | any[] | The items to push into the array. |
Returns
T[]
The array.
Example
ts
const arr = [1, 2];
push(arr, 3, 4); // => [1, 2, 3, 4]pushArray()
ts
function pushArray(dst, src): ArrayLike<any>;Defined in: src/pushArray.ts:13
Pushes an array into another array.
Parameters
| Parameter | Type | Description |
|---|---|---|
dst | ArrayLike<any> | The destination array. |
src | ArrayLike<any> | The source array. |
Returns
ArrayLike<any>
The destination array.
Example
ts
const dst = [1, 2];
pushArray(dst, [3, 4]); // => [1, 2, 3, 4]queueProvider()
ts
function queueProvider(options?): <A>(callback, milliseconds?) => (...args) => Promise<any>;Defined in: src/queueProvider.ts:15
Creates a queue provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | { onStart?: () => any; } | The options for the queue provider. |
options.onStart? | () => any | - |
Returns
The queue provider.
<A>(callback, milliseconds?) => (...args) => Promise<any>
Example
ts
const queue = queueProvider();
queue(async () => console.log('hello')); // => void
queue(async () => console.log('world')); // => voidrange()
ts
function range(
end,
start?,
step?): number[];Defined in: src/range.ts:15
Creates a numeric range from start (inclusive) to end (exclusive) with the given step (absolute value).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
end | number | undefined | End value (or count when start is 0). |
start | number | 0 | Start value (default: 0). |
step | number | 1 | Step size, always treated as positive (default: 1). |
Returns
number[]
Array of numbers from start to end (exclusive) by step.
Example
ts
range(5); // => [0, 1, 2, 3, 4]
range(5, 1); // => [1, 2, 3, 4]
range(1, 5, 2); // => [1, 3]
range(5, 1, 2); // => [5, 3, 1]readyProvider()
ts
function readyProvider(w): TReadyFn;Defined in: src/readyProvider.ts:35
Creates DOM ready helper for given window.
Parameters
| Parameter | Type | Description |
|---|---|---|
w | TReadyWindowContext | The window to create the DOM ready helper for. |
Returns
The DOM ready helper.
Example
ts
const ready = readyProvider(window);
ready(() => console.log('DOM is ready')); // => void
ready(() => console.log('DOM is ready')); // => voidreduce()
ts
function reduce(
collection,
iteratee,
accumulator): any;Defined in: src/reduce.ts:13
Reduces an array-like collection into a single value.
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | any | The collection to reduce. |
iteratee | (acc, value, index, collection) => any | The function to call for each item. |
accumulator | any | The initial accumulator value. |
Returns
any
The reduced value.
Example
ts
const sum = reduce([1, 2, 3], (acc, value) => acc + value, 0); // => 6reduceIn()
ts
function reduceIn(
collection,
iteratee,
accumulator,
ctx?): any;Defined in: src/reduceIn.ts:12
Reduces an object into a single value.
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | any | The object to reduce. |
iteratee | (acc, value, key, collection) => any | The function to call for each property. |
accumulator | any | The initial accumulator value. |
ctx? | any | The this context to use for the function. |
Returns
any
The reduced value.
Example
ts
const sum = reduceIn({ a: 1, b: 2, c: 3 }, (acc, value, key) => acc + value, 0); // => 6regexpMapperProvider()
ts
function regexpMapperProvider(regexp, keys): TRouteMapper;Defined in: src/regexpMapperProvider.ts:27
Creates a regexp mapper provider.
Parameters
| Parameter | Type | Description |
|---|---|---|
regexp | RegExp | The regexp to use. |
keys | string[] | ((values, dst?) => void) | The keys to use. |
Returns
The regexp mapper provider.
Example
ts
const mapper = regexpMapperProvider(/^([^/]*)/([^/]*)$/, ['all', 'begin', 'end']);
const params: any = {};
if (mapper('users/id6574334245', params)) {
// values = ['users/id6574334245', 'users', 'id6574334245']
// keys = ['all', 'begin', 'end']
console.log(params);
// {
// all: 'users/id6574334245',
// begin: 'users',
// end: 'id6574334245',
// }
}regexpNormalizeText()
ts
function regexpNormalizeText(v): string;Defined in: src/regexpNormalizeText.ts:15
Normalizes a separator to a regexp-safe source string. If input is a RegExp, returns its source; otherwise escapes the string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | RegExp | The string or regexp to normalize. |
Returns
string
The normalized string.
Example
ts
regexpNormalizeText('a/b'); // => 'a/b'
regexpNormalizeText(/a/b/); // => 'a/b'regexpParse()
ts
function regexpParse(v): RegExpExecArray;Defined in: src/regexpParse.ts:11
Parses a string like "/pattern/flags" into [fullMatch, pattern, flags].
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to parse. |
Returns
RegExpExecArray
The parsed result.
Example
ts
regexpParse('/users/:id'); // => ['/users/:id', 'users/:id', '']removeByIndex()
ts
function removeByIndex<T>(
collection,
index,
length?): T[];Defined in: src/removeByIndex.ts:13
Returns a new array with elements at [index, index+length) removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The collection to remove elements from. |
index | number | The index of the first element to remove. |
length? | number | The number of elements to remove. |
Returns
T[]
A new array with elements at [index, index+length) removed.
Example
ts
removeByIndex([1, 2, 3, 4, 5], 2, 2); // => [1, 2, 5]removeOf()
ts
function removeOf<T>(collection, v): number;Defined in: src/removeOf.ts:11
Removes all occurrences of value from the collection (in place). Returns the number of elements removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The collection to remove elements from. |
v | T | The value to remove from the collection. |
Returns
number
The number of elements removed.
Example
ts
removeOf([1, 2, 3, 4, 5], 3); // => 1repeat()
ts
function repeat(str, count): string;Defined in: src/repeat.ts:12
Repeats a string count times.
Parameters
| Parameter | Type | Description |
|---|---|---|
str | string | The string to repeat. |
count | number | The number of times to repeat the string. |
Returns
string
The repeated string.
Example
ts
repeat('a', 3); // => 'aaa'responsibilityChain()
ts
function responsibilityChain<TReq>(
chain,
req,
end,
onError?): any;Defined in: src/responsibilityChain.ts:29
Runs a chain of handlers; each calls next(req) to continue.
If a handler throws, the error is passed to onError (if provided) and the chain continues with the next handler — the error does not stop execution.
Type Parameters
| Type Parameter | Default type |
|---|---|
TReq | any |
Parameters
| Parameter | Type | Description |
|---|---|---|
chain | TChainHandler<TReq>[] | The chain of handlers. |
req | TReq | The request object. |
end | (req) => any | Called when the chain is exhausted. |
onError? | TChainErrorHandler<TReq> | Optional callback invoked when a handler throws. |
Returns
any
The result of the chain.
Examples
ts
responsibilityChain([(req, next) => next(req + 1)], 0, (req) => req); // => 1ts
responsibilityChain(
[(req, next) => { throw new Error('oops'); }],
{},
(req) => req,
(err) => console.error(err),
);routeParseProvider()
ts
function routeParseProvider(route): TRouteMapper;Defined in: src/routeParseProvider.ts:106
Parses a route and returns a RegExp mapper.
Parameters
| Parameter | Type | Description |
|---|---|---|
route | string | The route to parse. |
Returns
A RegExp mapper.
Example
ts
routeParseProvider('/user/:id'); // => /^(?:[^/]+)(?:/([^/]+))?$/
routeParseProvider('/user/:user.id'); // => /^(?:[^/]+)(?:/(?:[^/]+)(?:/(?:[^/]+))?)?$/
routeParseProvider('/user/:user.profile.id'); // => /^(?:[^/]+)(?:/(?:[^/]+)(?:/(?:[^/]+))?)?$/routeParseProviderBase()
ts
function routeParseProviderBase(route, keys): RegExp;Defined in: src/routeParseProvider.ts:57
Parses a route and returns a RegExp and a list of keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
route | string | The route to parse. |
keys | string[] | The list of keys to populate. |
Returns
RegExp
A RegExp and a list of keys.
Example
ts
routeParseProviderBase('/user/:id', ['all', 'id']); // => /^(?:[^/]+)(?:/([^/]+))?$/
routeParseProviderBase('/user/:user.id', ['all', 'user.id']); // => /^(?:[^/]+)(?:/(?:[^/]+)(?:/(?:[^/]+))?)?$/
routeParseProviderBase('/user/:user.profile.id', ['all', 'user.profile.id']); // => /^(?:[^/]+)(?:/(?:[^/]+)(?:/(?:[^/]+))?)?$/scopeJoin()
ts
function scopeJoin(
scope,
openChar?,
closeChar?): string;Defined in: src/scopeJoin.ts:27
Joins a nested scope tree back into a string using the given delimiters.
На вход подаётся структура, аналогичная результату scopeSplit: массив, содержащий строки и вложенные массивы (поддеревья скобок).
- Строки добавляются в результат как есть.
- Вложенный массив оборачивается
openChar/closeCharи рекурсивно разворачивается вовнутрь.
Совместим по форме с scopeSplit, но не навязывает конкретный формат узлов (любой ScopeNode[], где строки и вложенные массивы чередуются).
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
scope | ScopeNode[] | undefined | The scope to join. |
openChar | string | '(' | The open character. |
closeChar | string | ')' | The close character. |
Returns
string
The joined scope.
Example
ts
scopeJoin(['a', ['b'], 'c']); // => 'a(b)c'
scopeJoin(['a', ['b', ['c'], 'd'], 'e']); // => 'a(b(c)d)e'
scopeJoin(['pre', ['inner'], 'post'], '{{', '}}'); // => 'pre{{inner}}post'scopeSplit()
ts
function scopeSplit(
input,
openChar?,
closeChar?): ScopeNode[];Defined in: src/scopeSplit.ts:24
Splits a string into a nested tree of scopes using start/end tokens.
Возвращает массив, состоящий из строк и вложенных массивов:
- строки соответствуют тексту вне скобок на текущем уровне;
- вложенный массив представляет содержимое одной пары
openChar/closeChar, внутри которого та же структура (строки и массивы).
Многосимвольные разделители также поддерживаются.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
input | string | undefined | The input string to split. |
openChar | string | '(' | The open character. |
closeChar | string | ')' | The close character. |
Returns
The split scope.
Example
ts
scopeSplit('abc', '(', ')'); // => ['abc']
scopeSplit('a(b)c', '(', ')'); // => ['a', ['b'], 'c']
scopeSplit('a(b(c)d)e', '(', ')'); // => ['a', ['b', ['c'], 'd'], 'e']
scopeSplit('pre{{x}}post', '{{', '}}'); // => ['pre', ['x'], 'post']sendingQueue()
ts
function sendingQueue<F>(fn): {
(...args): Promise<any>;
drain: Promise<any>;
};Defined in: src/sendingQueue.ts:9
Creates a sending queue.
Type Parameters
| Type Parameter | Default type |
|---|---|
F extends (...args) => Promise<any> | (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | F | The function to send. |
Returns
The sending queue.
{ (...args): Promise<any>; drain: Promise<any>; }
| Name | Type | Defined in |
|---|---|---|
drain() | () => Promise<any> | src/sendingQueue.ts:13 |
Example
ts
sendingQueue((...args) => Promise.resolve()); // => { (...args: any[]): Promise<any>, drain(): Promise<any> }set()
ts
function set(
ctx,
path,
value): any;Defined in: src/set.ts:18
Устанавливает значение по строковому пути, разделённому точками.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | any | The context to set the value in. |
path | string | string[] | The path to set the value in. |
value | any | The value to set. |
Returns
any
The context.
Example
ts
const obj: any = {};
set(obj, 'user.profile.name', 'Vasya');
// obj.user.profile.name === 'Vasya'setStyleSheet()
ts
function setStyleSheet(
node,
text,
document): void;Defined in: src/setStyleSheet.ts:19
Устанавливает CSS‑текст для style‑элемента в документе.
Поддерживает как старый IE‑интерфейс (styleSheet.cssText), так и современный способ через textNode.
Parameters
| Parameter | Type | Description |
|---|---|---|
node | HTMLElement | The style element to update. |
text | string | The CSS text to set. |
document | TSetStyleSheetDocument | The document used to create text nodes. |
Returns
void
Example
ts
const style = document.createElement('style');
document.head.appendChild(style);
setStyleSheet(style, 'body { margin: 0; }', document);single()
ts
function single<T>(fn, ctx?): T & {
cancel: () => void;
};Defined in: src/single.ts:16
Wraps a function so that each new invocation cancels the previous one. The wrapped function returns a cancel handle (function or promise with .cancel).
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to wrap. |
ctx? | any | The context to wrap the function in. |
Returns
T & { cancel: () => void; }
The wrapped function.
Example
ts
const singleFunc = single(() => console.log('single'));
singleFunc(); // => 'single'
singleFunc();size()
ts
function size(v): number;Defined in: src/size.ts:12
Returns the number of enumerable values in a collection.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | unknown | The collection to get the size of. |
Returns
number
The size of the collection.
Example
ts
size({ a: 1, b: 2 }); // => 2
size([]); // => 0slice()
ts
function slice(
self,
start?,
end?): any[];Defined in: src/slice.ts:14
Slices an array-like collection.
Parameters
| Parameter | Type | Description |
|---|---|---|
self | ArrayLike<any> | The array-like collection to slice. |
start? | number | The start index. |
end? | number | The end index. |
Returns
any[]
The sliced array.
Example
ts
slice([1, 2, 3, 4], 1); // => [2, 3, 4]
slice([1, 2, 3, 4], 1, 3); // => [2, 3]snakeToCamelCase()
ts
function snakeToCamelCase(value): string;Defined in: src/snakeToCamelCase.ts:11
Converts snake_case string to camelCase.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | string | The string to convert. |
Returns
string
The converted string.
Example
ts
snakeToCamelCase('hello_world') // "helloWorld"some()
ts
function some<T>(collection, identity?): boolean;Defined in: src/some.ts:16
Checks if at least one element in the collection matches the identity. Identity can be a function or an object for isMatch.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T[] | The collection to search in. |
identity? | any | The identity to search for. |
Returns
boolean
true if at least one element matches, false otherwise.
Example
ts
some([1, 2, 3], v => v > 2); // => true
some([{ a: 1 }, { a: 2 }], { a: 2 }); // => truesomeIn()
ts
function someIn<T>(collection, identity?): boolean;Defined in: src/someIn.ts:16
Checks if at least one property in the collection matches the identity. Identity can be a function or an object for isMatch.
Type Parameters
| Type Parameter |
|---|
T extends Record<string, any> |
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | T | The collection to search in. |
identity? | any | The identity to search for. |
Returns
boolean
true if at least one property matches, false otherwise.
Example
ts
someIn({ a: 1, b: 3 }, v => v > 2); // => truesort()
ts
function sort<T>(src, iteratee?): T[];Defined in: src/sort.ts:14
Sorts an array in place using the provided compare function.
This is a thin wrapper around Array.prototype.sort to keep a consistent functional style.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
src | T[] | The array to sort. |
iteratee? | (a, b) => number | The function to compare two elements. |
Returns
T[]
The sorted array (mutates src).
Example
ts
sort([3, 1, 2]); // => [1, 2, 3]
sort([3, 1, 2], (a, b) => b - a); // => [3, 2, 1]sortBy()
ts
function sortBy<T>(src, iteratee): T[];Defined in: src/sortBy.ts:12
Sorts an array by the result of a function.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
src | T[] | The array to sort. |
iteratee | (item) => any | The function to get the value to sort by. |
Returns
T[]
The sorted array.
Example
ts
sortBy([{ name: 'John', age: 20 }, { name: 'Jane', age: 21 }], (u) => u.name.toLowerCase()); // => [{ name: 'Jane', age: 21 }, { name: 'John', age: 20 }]stackProvider()
ts
function stackProvider<T>(): IStack<T>;Defined in: src/stackProvider.ts:43
Simple FIFO stack/queue based on a linked list.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | any |
Returns
IStack<T>
A stack instance with push, pop, eachPop, and has methods.
Example
ts
const stack = stackProvider<number>();
stack.push(1); stack.push(2);
stack.pop(); // => 1startsWith()
ts
function startsWith(
self,
searchString,
position?): boolean;Defined in: src/startsWith.ts:17
Functional wrapper around String.prototype.startsWith with a fallback.
Parameters
| Parameter | Type | Description |
|---|---|---|
self | string | The string to check. |
searchString | string | The string to search for. |
position? | number | The position to start searching from. |
Returns
boolean
Whether the string starts with the search string.
Example
ts
startsWith('hello', 'he') // => true
startsWith('hello', 'hello') // => true
startsWith('hello', 'el', 1) // => truestorageInit()
ts
function storageInit(cookie): any;Defined in: src/cookieStorageProvider.ts:26
Initializes the storage.
Parameters
| Parameter | Type | Description |
|---|---|---|
cookie | string | The cookie to initialize the storage with. |
Returns
any
The initialized storage.
stripTags()
ts
function stripTags(v): string;Defined in: src/stripTags.ts:17
Strips HTML tags and normalizes whitespace into single spaces.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to strip tags from. |
Returns
string
The stripped string.
Example
ts
stripTags('<p>Hello <b>world</b></p>'); // => 'Hello world'stylesRenderProvider()
ts
function stylesRenderProvider(doc, prefix): (styles) => void;Defined in: src/stylesRenderProvider.ts:45
Создаёт функцию, которая по массиву описаний стилей монтирует/обновляет <style>‑элементы в документе.
Parameters
| Parameter | Type | Description |
|---|---|---|
doc | TStylesRenderDocument | The document in which <style> elements are managed. |
prefix | string | Prefix prepended to each style element's id attribute. |
Returns
A function that accepts an array of style items and syncs them to the DOM.
(styles) => void
Example
ts
const render = stylesRenderProvider(document, 'app-');
render([{ name: 'theme', revision: 1, content: 'body { color: red; }' }]);
// Inserts/updates <style id="app-theme"> with the given CSS.subscribe()
ts
function subscribe(collection, listeners): () => void;Defined in: src/subscribe.ts:11
Subscribes to a collection of listeners.
Parameters
| Parameter | Type | Description |
|---|---|---|
collection | any[] | The collection to subscribe to. |
listeners | any[] | The listeners to subscribe to. |
Returns
A function that, when called, removes all listeners from the collection.
() => void
Example
ts
const unsubscribe = subscribe(handlers, [myHandler]);
unsubscribe(); // removes myHandler from handlerstemplatePartsJoin()
ts
function templatePartsJoin(parts): (scope) => string;Defined in: src/templatePartsJoin.ts:13
Combines an array of template-part render functions into a single render function.
Each part receives scope and returns a string fragment; the results are concatenated in order.
Parameters
| Parameter | Type | Description |
|---|---|---|
parts | (scope) => any[] | Array of render functions produced by templateProvider. |
Returns
A single render function (scope) => string.
(scope) => string
Example
ts
const render = templatePartsJoin([() => 'Hello, ', (s) => s.name]);
render({ name: 'World' }); // => 'Hello, World'templateProvider()
ts
function templateProvider(
template,
parse?,
regexp?): (scope) => string;Defined in: src/templateProvider.ts:28
Creates a template function from a string with placeholders.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
template | string | undefined | The template to build. |
parse | (expression) => (scope) => any | null | The function to parse the expressions. |
regexp | RegExp | REGEXP | The regular expression to use. |
Returns
The template function.
(scope) => string
Example
ts
const render = templateProvider('Hello {{name}}!');
render({ name: 'World' }); // => 'Hello World!'
const render2 = templateProvider('{{a}} + {{b}} = {{a}}');
render2({ a: 1, b: 2 }); // => '1 + 2 = 1'textEllipsis()
ts
function textEllipsis(
text,
limit?,
suffix?): string;Defined in: src/textEllipsis.ts:13
Shortens text to the given limit and appends a suffix if truncated.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
text | unknown | undefined | The text to shorten. |
limit | number | 12 | The limit to shorten the text to. |
suffix | string | '...' | The suffix to append if the text is truncated. |
Returns
string
The shortened text.
Example
ts
textEllipsis('hello world', 5); // => 'hello...'
textEllipsis('hi', 5); // => 'hi'
textEllipsis('hello world', 5, ' …'); // => 'hello …'toHTML()
ts
function toHTML(v): string;Defined in: src/toHTML.ts:13
Escapes HTML and replaces line breaks with <br/>.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to convert to HTML. |
Returns
string
The HTML string.
Example
ts
toHTML('a < b\nfoo'); // => 'a < b<br/>foo'toLower()
ts
function toLower(v): string;Defined in: src/toLower.ts:9
Converts a string to lower case.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to convert to lower case. |
Returns
string
The lower case string.
Example
ts
toLower('Hello World'); // => 'hello world'toPlainFields()
ts
function toPlainFields(params): Record<string, any>;Defined in: src/toPlainFields.ts:10
Flattens nested structures into plain dotted paths.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | any | The parameters to flatten. |
Returns
Record<string, any>
The flattened parameters.
Example
ts
toPlainFields({ a: { b: 1 }, list: ['x', 'y'] })
// => { 'a.b': 1, 'list.0': 'x', 'list.1': 'y' }toSerializableJson()
ts
function toSerializableJson(value): any;Defined in: src/toSerializableJson.ts:15
Converts a value to a JSON‑compatible value.
- Functions and
undefinedare converted tonull - Objects and arrays are copied recursively
- Cyclic references are converted to
null
Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | The value to convert. |
Returns
any
The JSON‑compatible value.
Example
ts
const src = { fn: () => {}, value: 1 };
const safe = toSerializableJson(src);
// safe: { fn: null, value: 1 }toSerializableJsonBase()
ts
function toSerializableJsonBase(value, excludes): any;Defined in: src/toSerializableJson.ts:26
Converts a value to a JSON‑compatible value.
Parameters
| Parameter | Type | Description |
|---|---|---|
value | any | The value to convert. |
excludes | any[] | The values to exclude from the conversion. |
Returns
any
The JSON‑compatible value.
toUpper()
ts
function toUpper(v): string;Defined in: src/toUpper.ts:9
Converts a string to upper case.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to convert to upper case. |
Returns
string
The upper case string.
Example
ts
toUpper('hello'); // => 'HELLO'trim()
ts
function trim(v): string;Defined in: src/trim.ts:11
Trims whitespace from both ends of a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to trim. |
Returns
string
The trimmed string.
Example
ts
trim(' hello ') // => 'hello'trimQuote()
ts
function trimQuote(v): string;Defined in: src/trimQuote.ts:13
Trims whitespace from both ends of a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to trim. |
Returns
string
The trimmed string.
Example
ts
trimQuote('"hello"') // => 'hello'
trimQuote('`hello`') // => 'hello'
trimQuote('\'hello\'') // => 'hello'tryJsonParse()
ts
function tryJsonParse(s): any;Defined in: src/tryJsonParse.ts:10
Tries to parse a string as JSON.
Parameters
| Parameter | Type | Description |
|---|---|---|
s | string | The string to parse. |
Returns
any
Parsed value on success, or the original string on failure.
Example
ts
tryJsonParse('{"a":1}'); // => { a: 1 }
tryJsonParse('not json'); // => 'not json'uniqWith()
ts
function uniqWith<T>(
input,
comparator?,
output?): T[];Defined in: src/uniqWith.ts:15
Returns unique items from input using a custom comparator. Default comparator is isMatch (deep equality).
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
input | T[] | The input array to filter. |
comparator? | (a, b) => boolean | The comparator function to use. |
output? | T[] | The output array to write to. |
Returns
T[]
Array of unique items.
Example
ts
uniqWith([1, 2, 1, 3]); // => [1, 2, 3]
uniqWith([{a:1},{a:1},{a:2}], (x, y) => x.a === y.a); // => [{a:1},{a:2}]unparam()
ts
function unparam(query): TParams;Defined in: src/unparam.ts:48
Parses a URL query string into a key-value object.
Supports nested keys via dot notation. Values that look like JSON are parsed automatically.
Parameters
| Parameter | Type | Description |
|---|---|---|
query | string | Query string, optionally including the leading ?. |
Returns
Parsed parameters object.
Example
ts
unparam('?a=1&b=hello'); // => { a: '1', b: 'hello' }
unparam('x.y=2'); // => { x: { y: 2 } }unparamBase()
ts
function unparamBase(query, output?): TParams;Defined in: src/unparam.ts:9
Parameters
| Parameter | Type |
|---|---|
query | string |
output? | any |
Returns
unslash()
ts
function unslash(v): string;Defined in: src/unslash.ts:17
Normalizes backslash escaping:
\\\\→\\\\→ empty string (removes the escape)
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to process. |
Returns
string
String with backslash sequences resolved.
Example
ts
unslash('hello\\ world'); // => 'hello world'upperFirst()
ts
function upperFirst(v): string;Defined in: src/upperFirst.ts:11
Uppercases the first character of a string.
Parameters
| Parameter | Type | Description |
|---|---|---|
v | string | The string to transform. |
Returns
string
String with first character uppercased.
Example
ts
upperFirst('hello'); // => 'Hello'urlExtend()
ts
function urlExtend(_first?, _src?): TUrlProps;Defined in: src/urlExtend.ts:33
Merges two URL descriptors (string or TUrlProps) into a single TUrlProps.
Fields from _src override fields from _first; query objects are deep-merged.
Parameters
| Parameter | Type | Description |
|---|---|---|
_first? | | string | Partial<TUrlOptions> & { child?: Partial<TUrlOptions>; } | Base URL or partial URL object. |
_src? | | string | Partial<TUrlOptions> & { child?: Partial<TUrlOptions>; } | Override URL or partial URL object. |
Returns
Merged TUrlProps with a fully reconstructed href.
Example
ts
urlExtend('https://example.com/page', { query: { v: 2 } }).href;
// => 'https://example.com/page?v=2'urlParse()
ts
function urlParse(href): TUrlProps;Defined in: src/urlParse.ts:51
Parses a URL string into a structured TUrlProps object.
Parameters
| Parameter | Type | Description |
|---|---|---|
href | string | The URL string to parse. |
Returns
Parsed URL with protocol, hostname, port, path, query, hash, child and more.
Example
ts
urlParse('https://example.com/api?v=1#section').path; // => '/api'
urlParse('https://example.com/api?v=1#section').query; // => { v: '1' }urlTranslite()
ts
function urlTranslite(input, translite?): string;Defined in: src/urlTranslite.ts:23
Converts string to URL-friendly slug: lowercased, Cyrillic transliterated, non-word chars to dash, trimmed.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
input | string | undefined | The string to convert. |
translite | Record<string, string> | TRANSLITE | Custom transliteration map (defaults to Cyrillic → Latin). |
Returns
string
URL-safe slug string.
Example
ts
urlTranslite('Привет Мир'); // => 'privet-mir'
urlTranslite('Hello World!'); // => 'hello-world'values()
ts
function values(obj): any[];Defined in: src/values.ts:12
Returns enumerable values of an object.
Uses native Object.values when available, otherwise falls back to a simple for..in iteration.
Parameters
| Parameter | Type | Description |
|---|---|---|
obj | any | The object to extract values from. |
Returns
any[]
Array of enumerable values.
Example
ts
values({ a: 1, b: 2 }); // => [1, 2]variantsProvider()
ts
function variantsProvider(options): TVariants;Defined in: src/variantsProvider.ts:91
Фабрика разборщика вариантов: один раз готовит сплиттер по separator и порядок маркеров scope; на каждом вызове возвращаемой функции — один проход по строке без генератора и без аллокаций на токены OPEN/CLOSE (только накопление префиксных фрагментов в parts).
Семантика совпадает с экспортом variants из ./variants (тот же набор опций MN по умолчанию); variants — готовая фабрика, возвращающая кортеж [строки, maxDepth].
Правила совпадения с 1.x для ( ):
\\+ символ — один литерал префикса;- иначе границы (сначала более длинная подстрока, при равной длине —
scopeStart, затемscopeEnd), иначе один символ префикса.
Parameters
| Parameter | Type |
|---|---|
options | IVariantsProviderOptions |
Returns
wait()
ts
function wait<A>(millis?, params?): Promise<A>;Defined in: src/wait.ts:11
Returns a promise that resolves after the specified timeout.
Type Parameters
| Type Parameter |
|---|
A |
Parameters
| Parameter | Type | Description |
|---|---|---|
millis? | number | Timeout in milliseconds (defaults to 0). |
params? | A | Optional value to resolve with. |
Returns
Promise<A>
A Promise that resolves after the timeout.
Example
ts
await wait(200); // resolves after 200ms
await wait(100, 'done'); // resolves with 'done' after 100mswithDefer()
ts
function withDefer<T>(
fn,
ctx?,
result?): T;Defined in: src/withDefer.ts:14
Debounces a function using defer: only the last call is executed after the current tick.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to debounce. |
ctx? | any | Optional this context. |
result? | any | Value to return from each call (before the debounced fn runs). |
Returns
T
Debounced version of fn.
Example
ts
const save = withDefer(() => console.log('saved'));
save(); save(); save(); // 'saved' printed oncewithDelay()
ts
function withDelay<T>(
fn,
delayMs,
ctx?,
result?): T;Defined in: src/withDelay.ts:15
Debounces a function: only the last call within the delay window is executed.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to debounce. |
delayMs | number | Debounce window in milliseconds. |
ctx? | any | Optional this context. |
result? | any | Value to return from each call (before the debounced fn runs). |
Returns
T
Debounced version of fn.
Example
ts
const search = withDelay(query => fetch(query), 300);
search('a'); search('ab'); search('abc'); // only search('abc') runswithLock()
ts
function withLock<T>(
fn,
ctx?,
result?): T;Defined in: src/withLock.ts:12
Wraps a function so that concurrent invocations are ignored while one is running.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to protect. |
ctx? | any | Optional this context. |
result? | any | Value to return for ignored calls. |
Returns
T
Locked version of fn.
Example
ts
const handleClick = withLock(() => expensiveOp());
handleClick(); handleClick(); // second call is ignored while first runswithout()
ts
function without(
src,
withoutKeys,
dst?): Record<string, any>;Defined in: src/without.ts:13
Creates a shallow copy of src without the specified keys.
Parameters
| Parameter | Type | Description |
|---|---|---|
src | Record<string, any> | Source object. |
withoutKeys | any[] | Array of keys that should be excluded. |
dst? | Record<string, any> | Optional destination object to write into. |
Returns
Record<string, any>
Object that contains all properties of src whose keys are not in withoutKeys.
Example
ts
without({ a: 1, b: 2, c: 3 }, ['b']); // => { a: 1, c: 3 }withoutEmpty()
ts
function withoutEmpty(data, depth?): any;Defined in: src/withoutEmpty.ts:12
Recursively removes null, undefined, empty-string and empty-array values.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | any | The value to clean. |
depth? | number | How many levels deep to recurse (default 0 = shallow). |
Returns
any
Cleaned value, or null if the entire value was empty.
Example
ts
withoutEmpty({ a: 1, b: null, c: '' }); // => { a: 1 }
withoutEmpty({ a: { b: null } }, 1); // => nullwithoutEmptyBase()
ts
function withoutEmptyBase(src, depth): any;Defined in: src/withoutEmpty.ts:14
Parameters
| Parameter | Type |
|---|---|
src | any |
depth | number |
Returns
any
withReDelay()
ts
function withReDelay<T>(
fn,
delayMs,
ctx?): T & {
cancel: () => void;
};Defined in: src/withReDelay.ts:15
Wraps a function so each invocation resets the delay; previous pending call is cancelled.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to debounce. |
delayMs | number | Delay window in milliseconds. |
ctx? | any | Optional this context. |
Returns
T & { cancel: () => void; }
Debounced function with a cancel() method.
Example
ts
const save = withReDelay(() => console.log('saved'), 500);
save(); save(); // timer resets; 'saved' runs 500ms after the last callwithResult()
ts
function withResult<T, R>(
fn,
result,
ctx?): (...args) => R;Defined in: src/withResult.ts:14
Wraps a function so that it always returns the given constant result.
The original function is still executed for its side effects.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
R |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to call for side effects. |
result | R | The fixed return value. |
ctx? | any | Optional this context. |
Returns
Wrapper that always returns result.
(...args) => R
Example
ts
const handler = withResult(e => e.preventDefault(), false);
handler(event); // => falsewrapper()
ts
function wrapper<A>(v): () => A;Defined in: src/wrapper.ts:10
Creates a function that always returns the given constant value.
Type Parameters
| Type Parameter |
|---|
A |
Parameters
| Parameter | Type | Description |
|---|---|---|
v | A | The value to wrap. |
Returns
A zero-argument function that always returns v.
() => A
Example
ts
const getZero = wrapper(0);
getZero(); // => 0