Skip to content

fundamentool


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 ParameterDefault type
Tany

Implements

Constructors

Constructor
ts
new EventEmitter<T>(listeners?): EventEmitter<T>;

Defined in: src/EventEmitter/index.ts:19

Parameters
ParameterType
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

IEventEmitter.clear

destroy()
ts
destroy(): void;

Defined in: src/EventEmitter/index.ts:23

Destroys the emitter and clears all listeners.

Returns

void

Implementation of

IEventEmitter.destroy

emit()
ts
protected emit(data): void;

Defined in: src/EventEmitter/index.ts:27

Parameters
ParameterType
dataT
Returns

void

once()
ts
once(...listeners): () => void;

Defined in: src/EventEmitter/index.ts:46

Parameters
ParameterType
...listenersIEventEmitterListener<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
ParameterType
...listenersIEventEmitterListener<T>[]
Returns

() => void

Implementation of

IEventEmitter.subscribe


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
ParameterTypeDescription
optionsILineBasedFormatOptionsThe options for the line-based format.
Returns

LineBasedFormat

Properties

PropertyModifierTypeDescriptionDefined in
parsepublic(input) => anyParses a string into an array of values.src/LineBasedFormat.ts:38
stringifypublic(input) => stringStringifies 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 ParameterDefault type
Tany

Constructors

Constructor
ts
new LineDecoder<T>(options?): LineDecoder<T>;

Defined in: src/LineDecoder.ts:120

Creates a new line decoder.

Parameters
ParameterTypeDescription
optionsILineDecoderOptionsThe options for the line decoder.
Returns

LineDecoder<T>

The line decoder.

Properties

PropertyTypeDescriptionDefined 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 ParameterDefault type
Tany
Parameters
ParameterTypeDescription
optionsILineDecoderOptions<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 ParameterDefault type
Tany
Parameters
ParameterTypeDescription
parse(line) => TThe function to parse a line of text into a value.
Returns

ILineDecoderConstructor<T>

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

PortPolyfill

Inherited from
ts
EventTargetConstructor.constructor

Methods

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.

MDN Reference

Parameters
ParameterType
typestring
callbackEventListenerOrEventListenerObject
options?boolean | AddEventListenerOptions
Returns

void

Inherited from
ts
EventTargetConstructor.addEventListener
dispatchEvent()
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.

MDN Reference

Parameters
ParameterType
eventEvent
Returns

boolean

Inherited from
ts
EventTargetConstructor.dispatchEvent
postMessage()
ts
postMessage(data): void;

Defined in: src/PortPolyfill.ts:21

Sends a message to the port.

Parameters
ParameterTypeDescription
dataanyThe 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.

MDN Reference

Parameters
ParameterType
typestring
callbackEventListenerOrEventListenerObject
options?boolean | EventListenerOptions
Returns

void

Inherited from
ts
EventTargetConstructor.removeEventListener

Unsubscriber

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 subscriptions

Implements

Constructors

Constructor
ts
new Unsubscriber(unsubscribers?): Unsubscriber;

Defined in: src/Unsubscriber/index.ts:20

Parameters
ParameterType
unsubscribers?TUnsubscriberUnsubscribe[]
Returns

Unsubscriber

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
ParameterType
...unsubscribersTUnsubscriberUnsubscribe[]
Returns

IUnsubscriberUnsubscribeFn

Implementation of

IUnsubscriber.add

unsubscribe()
ts
unsubscribe(): void;

Defined in: src/Unsubscriber/index.ts:28

Calls all registered unsubscribers and clears the list.

Returns

void

Implementation of

IUnsubscriber.unsubscribe

Interfaces

BaseLineDecoder

Defined in: src/LineDecoder.ts:31

Type Parameters

Type ParameterDefault type
Tany

Methods

end()
ts
end(chunk?, output?): T[];

Defined in: src/LineDecoder.ts:47

Ends the decoder.

Parameters
ParameterTypeDescription
chunk?stringThe 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
ParameterTypeDescription
chunkstringThe 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

ParameterType
vstring
alt?boolean

Returns

string[]

Properties

PropertyTypeDefined in
base(rgbaColor, alt?) => string[]src/color.ts:20
double(v, start) => numbersrc/color.ts:18
normalize(v, alpha?, w?, l?) => [number, number, number, number]src/color.ts:19
one(v) => numbersrc/color.ts:17
rgbStringify(rgb) => stringsrc/color.ts:21

IColorRange()

Defined in: src/colorRange.ts:3

ts
IColorRange(colors, precision): string[];

Defined in: src/colorRange.ts:4

Parameters

ParameterType
colors[number, number, number, number][]
precisionnumber

Returns

string[]

Properties

PropertyTypeDefined in
base(input, precision) => [number, number, number, number][]src/colorRange.ts:5
rgba(rgbaColor) => stringsrc/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

ParameterType
dstTDst
srcTSrc
depthnumber

Returns

TDst | TSrc

Properties

PropertyTypeDefined 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

ParameterType
emitT

Returns

T

Properties

PropertyTypeDefined 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

PropertyTypeDefined in
add(...fns) => IDestroyersrc/destroyProvider.ts:9
child() => IDestroyersrc/destroyProvider.ts:11
clear() => IDestroyersrc/destroyProvider.ts:13
isDestroyed() => booleansrc/destroyProvider.ts:12
remove(fn) => IDestroyersrc/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 ParameterDefault type
Tany

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
ParameterType
...listenersIEventEmitterListener<T>[]
Returns

IEventEmitterUnsubscribe


IEventEmitterListener()

Defined in: src/EventEmitter/types.ts:7

Listener callback passed to subscribe.

Type Parameters

Type ParameterDefault type
Tany
ts
IEventEmitterListener(value): void;

Defined in: src/EventEmitter/types.ts:8

Listener callback passed to subscribe.

Parameters

ParameterType
valueT

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

PropertyTypeDefined in
close() => voidsrc/limitStream/index.ts:5

ILineBasedFormatOptions

Defined in: src/LineBasedFormat.ts:1

Properties

PropertyTypeDescriptionDefined in
parse(input) => anyParses a string into an array of values.src/LineBasedFormat.ts:8
stringify(input) => stringStringifies an array of values into a string.src/LineBasedFormat.ts:15

ILineDecoderBaseOptions

Defined in: src/LineDecoder.ts:3

Extended by

Properties

PropertyTypeDescriptionDefined in
skipEmptyLines?booleanWhether to skip empty lines. Default falsesrc/LineDecoder.ts:9

ILineDecoderConstructor

Defined in: src/LineDecoder.ts:21

Type Parameters

Type ParameterDefault type
Tany

Constructors

Constructor
ts
new ILineDecoderConstructor(options?): BaseLineDecoder<T>;

Defined in: src/LineDecoder.ts:28

Creates a new line decoder.

Parameters
ParameterTypeDescription
options?ILineDecoderBaseOptionsThe options for the line decoder.
Returns

BaseLineDecoder<T>

The line decoder.


ILineDecoderOptions

Defined in: src/LineDecoder.ts:11

Extends

Type Parameters

Type ParameterDefault type
Tany

Properties

PropertyTypeDescriptionInherited fromDefined in
parse?(line) => TParses a line of text into a value.-src/LineDecoder.ts:18
skipEmptyLines?booleanWhether to skip empty lines. Default falseILineDecoderBaseOptions.skipEmptyLinessrc/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

ParameterTypeDescription
ctxanyThe context object.
pathstringThe dot-separated path to the property to remove.

Returns

any

The context object.

Example

ts
remove({ a: { b: 1 } }, 'a.b'); // => { a: {} }

Properties

PropertyTypeDescriptionDefined in
base(ctx, path) => anyRemoves 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
ParameterTypeDescription
iteratee(item) => voidThe 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
ParameterTypeDescription
dataTThe item to push.
Returns

void


IStringifyCss()

Defined in: src/cssPropertiesStringifyProvider.ts:8

ts
IStringifyCss(props, important?): string;

Defined in: src/cssPropertiesStringifyProvider.ts:9

Parameters

ParameterType
propsTCssProps
important?boolean

Returns

string

Properties

PropertyTypeDefined in
prefixedAttrsTPrefixedAttrssrc/cssPropertiesStringifyProvider.ts:10
prefixesTPrefixessrc/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 once

Methods

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
ParameterType
...unsubscribersTUnsubscriberUnsubscribe[]
Returns

IUnsubscriberUnsubscribeFn

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

PropertyTypeDescriptionDefined in
maxDepthnumberМаксимальная глубина вложенности пар scope. Number.POSITIVE_INFINITY — без ограничения. Любое конечное <= 0 (в т.ч. отрицательные) — как 0: группы запрещены. NaN — ошибка при создании провайдера (TypeError). Конечное > 0 — лимит уровней. Удобно, если то же поле приходит из внешнего конфига в широком диапазоне без отдельной нормализации под этот модуль.src/variantsProvider.ts:28
maxOutputCount?numberВерхняя граница числа строк в результате развёртки (длина массива до unslash). undefined / Number.POSITIVE_INFINITY — без ограничения. Конечное <= 0 — как 0 (любая непустая развёртка — ошибка при вызове). NaNTypeError при создании фабрики. При превышении лимита — RangeError на вызове возвращаемой функции (после полной сборки массива строк в variantsBuildSplit).src/variantsProvider.ts:36
scopeEndstringЗакрывающая граница группы (в MN по умолчанию )). Допускается любая непустая подстрока, отличная от scopeStart.src/variantsProvider.ts:20
scopeStartstringОткрывающая граница группы (в MN по умолчанию (). Допускается любая непустая подстрока.src/variantsProvider.ts:18
separatorstringРазделитель альтернатив внутри группы (в MN по умолчанию `). Может быть подстрокой — см. escapedSplitProvider`.

Store

Defined in: src/store.ts:22

A store.

Type Parameters

Type ParameterDescription
TThe 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
ParameterTypeDescription
fn(state) => UThe 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
ParameterTypeDescription
fnWatcher<T>The function to watch the store.
Returns

Unsubscribe

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

ParameterType
...argsany[]

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

ParameterType
emitT

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

NameTypeDescriptionDefined in
setState()(next) => voidSets the state of the store.src/store.ts:58

Type Parameters

Type ParameterDescription
TThe type of the state.

TChainErrorHandler

ts
type TChainErrorHandler<TReq> = (error, req) => void;

Defined in: src/responsibilityChain.ts:6

Type Parameters

Type ParameterDefault type
TReqany

Parameters

ParameterType
errorunknown
reqTReq

Returns

void


TChainHandler

ts
type TChainHandler<TReq> = (req, next) => any;

Defined in: src/responsibilityChain.ts:1

Type Parameters

Type ParameterDefault type
TReqany

Parameters

ParameterType
reqTReq
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

NameTypeDefined in
clear()() => TCookieStoragesrc/cookieStorageProvider.ts:15
get()(key) => anysrc/cookieStorageProvider.ts:12
getKeys()() => string[]src/cookieStorageProvider.ts:14
remove()(key) => TCookieStoragesrc/cookieStorageProvider.ts:13
set()(key, value) => TCookieStoragesrc/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

NameTypeDefined in
cookiestringsrc/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

NameTypeDescriptionDefined in
clear()() => TLocalStorageClears the local storage.src/localStorageProvider.ts:52
get()(key) => anyGets 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) => TLocalStorageRemoves a value from the local storage.src/localStorageProvider.ts:40
set()(key, value) => TLocalStorageSets 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

NameTypeDefined in
lengthnumbersrc/localStorageProvider.ts:8
getItem()(key) => stringsrc/localStorageProvider.ts:10
key()(index) => stringsrc/localStorageProvider.ts:9
removeItem()(key) => voidsrc/localStorageProvider.ts:12
setItem()(key, value) => voidsrc/localStorageProvider.ts:11

Methods

addEventListener()
ts
addEventListener(
   type, 
   listener, 
   options?): void;

Defined in: src/localStorageProvider.ts:14

Parameters
ParameterType
typestring
listener(event) => void
options?any
Returns

void

removeEventListener()
ts
removeEventListener(
   type, 
   listener, 
   options?): void;

Defined in: src/localStorageProvider.ts:15

Parameters
ParameterType
typestring
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

ParameterTypeDescription
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
ParameterType
typestring
listener(e) => void
useCapture?boolean
Returns

void

removeEventListener()
ts
removeEventListener(
   type, 
   listener, 
   useCapture?): void;

Defined in: src/readyProvider.ts:8

Parameters
ParameterType
typestring
listener(e) => void
useCapture?boolean
Returns

void


TReadyFn

ts
type TReadyFn = (fn, args?, ctx?) => TReadyUnsubscribe | void;

Defined in: src/readyProvider.ts:19

Parameters

ParameterType
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
ParameterType
typestring
listener(e) => void
useCapture?boolean
Returns

void

removeEventListener()
ts
removeEventListener(
   type, 
   listener, 
   useCapture?): void;

Defined in: src/readyProvider.ts:14

Parameters
ParameterType
typestring
listener(e) => void
useCapture?boolean
Returns

void


TRouteMapper

ts
type TRouteMapper = (text, dst?) => boolean;

Defined in: src/regexpMapperProvider.ts:4

Parameters

ParameterType
textstring
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
ParameterType
datastring
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

NameTypeDefined in
head| { appendChild: any; removeChild?: any; } | null | undefinedsrc/stylesRenderProvider.ts:5
createElement()(tagName) => anysrc/stylesRenderProvider.ts:6
getElementById()(id) => anysrc/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

NameTypeDefined in
basePathstringsrc/urlParse.ts:26
child?Partial<TUrlProps> | nullsrc/urlParse.ts:39
emailstringsrc/urlParse.ts:38
filenamestringsrc/urlParse.ts:32
hashstringsrc/urlParse.ts:25
hoststringsrc/urlParse.ts:29
hrefstringsrc/urlParse.ts:22
loginstringsrc/urlParse.ts:37
pathstringsrc/urlParse.ts:27
portstringsrc/urlParse.ts:30
searchstringsrc/urlParse.ts:23
unaliasstringsrc/urlParse.ts:31
unextensionstringsrc/urlParse.ts:33
unhashstringsrc/urlParse.ts:24
unpathstringsrc/urlParse.ts:28
unsearchstringsrc/urlParse.ts:34
usernamestringsrc/urlParse.ts:36
userpartstringsrc/urlParse.ts:35

TVariants

ts
type TVariants = (value, applyUnslash?) => TVariantsResult;

Defined in: src/variantsProvider.ts:12

Функция разбора: строка выражения и опционально отключение unslash для сырого вывода.

Parameters

ParameterType
valuestring
applyUnslash?boolean

Returns

TVariantsResult

Кортеж [массив вариантов, максимальная глубина вложенности 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

NameTypeDefined in
documentElement{ clientHeight: number; clientWidth: number; }src/getViewportSizeProvider.ts:7
documentElement.clientHeightnumbersrc/getViewportSizeProvider.ts:9
documentElement.clientWidthnumbersrc/getViewportSizeProvider.ts:8
height?numbersrc/getViewportSizeProvider.ts:6
width?numbersrc/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

ParameterTypeDescription
stateTThe 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
ParameterTypeDescription
oobjectObject 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
ParameterTypeDescription
oobjectObject to use as a prototype. May be null
propertiesPropertyDescriptorMap & 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 prototype

entries

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
ParameterTypeDescription
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
ParameterTypeDescription
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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
valueanyThe value to parse.
def?numberThe default value returned when parsing fails (default 0).
minVal?numberOptional minimum clamp value.
maxVal?numberOptional maximum clamp value.

Returns

number

The float value, or def if parsing fails.

Example

ts
floatval('3.14'); // => 3.14
floatval('abc'); // => 0

formatTime

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

ParameterTypeDescription
datestring | number | DateThe date to get the data for.
utc?booleanWhether 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

ParameterTypeDescription
oanyThe 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.prototype

getRFC3339

ts
const getRFC3339: (time, utc?) => string;

Defined in: src/formatTime.ts:158

Gets the RFC3339 format for a date.

Parameters

ParameterTypeDescription
timestring | number | DateThe date to get the RFC3339 format for.
utc?booleanWhether 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

ParameterTypeDescription
inputstringThe input string to split.
separatorstringThe separator to split the string by.
right?number | booleanIf 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

ParameterTypeDescription
inputstringThe input string to split.
separatorstringThe separator to split the string by.
right?number | booleanIf 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

ParameterTypeDescription
oobjectAn object.
vPropertyKeyA 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'); // => false

intval

ts
const intval: (value, def?, minVal?, maxVal?) => number;

Defined in: src/numval.ts:55

Parses a number string and returns the integer value.

Parameters

ParameterTypeDescription
valueanyThe value to parse.
def?numberThe default value.
minVal?numberThe minimum value.
maxVal?numberThe 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

ParameterTypeDescription
objRecord<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

ParameterTypeDescription
...itemsany[]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

ParameterTypeDescription
start?numberThe beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.
end?numberThe 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

ParameterTypeDescription
datestring | number | DateThe 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.14

remove

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 => 1

Functions

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

ParameterTypeDescription
collectionT[]The array to add the item to.
itemTThe 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

ParameterTypeDescription
funcsAnyFn[]The functions to aggregate.
aggregatorAggregatorThe 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

ParameterTypeDescription
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 fetch

attachEvent()

ts
function attachEvent(
   ctx, 
   type, 
   listener, 
   options?): TUnsubscribe;

Defined in: src/attachEvent.ts:16

Attaches an event listener and returns an unsubscribe function.

Parameters

ParameterTypeDescription
ctxEventTargetTarget to attach event to.
typestringEvent type (e.g. "click").
listener(event) => anyEvent handler.
options?TEventListenerOptionsNative 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 listener

baseSet()

ts
function baseSet(
   ctx, 
   path, 
   value): any;

Defined in: src/set.ts:31

Sets a value in a context by a path array.

Parameters

ParameterTypeDescription
ctxanyThe context to set the value in.
pathArrayLike<string>The path to set the value in.
valueanyThe 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

ParameterTypeDescription
fnFFunction to bind.
ctxanythis 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

ParameterTypeDescription
selfTThe object whose methods to bind.
methodskeyof 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

ParameterTypeDescription
valuestringThe string to convert.
delimiterstringThe 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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
clearFn(id) => voidThe function to clear.
idanyThe 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 timeout

changeProviderProvider()

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

ParameterTypeDescription
set(partial) => voidState 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

ParameterTypeDescription
set(partial) => voidFunction 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

ParameterTypeDescription
ParentTParentThe parent class to wrap.
constructor(self, superFn, ...args) => voidThe 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

ParameterTypeDescription
ParentanyThe parent class to wrap.
constructor(self, props?) => voidThe constructor to wrap.
proto?Record<string, any>The prototype to extend.

Returns

The child class.

{ (): void; prototype: any; }

NameTypeDefined in
prototypeanysrc/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

ParameterTypeDescription
inputstringCompact gradient description string.
alt?booleanWhether 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

ParameterTypeDescription
inputstringThe 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

ParameterTypeDescription
ctxTCookieWindowContextThe Window whose document.cookie is managed.

Returns

TCookieStorage

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

ParameterTypeDescription
storeStoreWritable<T>The store to create the api for.
shapeEThe 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

ParameterTypeDefault valueDescription
callback(...args) => anyundefinedThe callback to call when the interval is ready.
delaynumber250The delay to call the callback.
args?any[]undefinedThe arguments to pass to the callback.
ctx?anyundefinedThe 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 interval

createStore()

ts
function createStore<T>(initial): StoreWritable<T>;

Defined in: src/store.ts:67

Creates a new store.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
initialTThe initial state.

Returns

StoreWritable<T>

The store.


createTimeout()

ts
function createTimeout(
   callback, 
   timeout?, 
   args?, 
   ctx?): () => void;

Defined in: src/createTimeout.ts:13

Creates a timeout.

Parameters

ParameterTypeDescription
callback(...args) => anyThe callback to call when the timeout is ready.
timeout?numberThe timeout to call the callback.
args?ArrayLike<any>The arguments to pass to the callback.
ctx?anyThe 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 fires

cssPropertiesParseSimple()

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

ParameterTypeDescription
textstringCSS string to parse.
output?TCssMapOptional destination object to merge into.

Returns

TCssMap

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

ParameterTypeDescription
prefixedAttrsTPrefixedAttrsThe prefixed attributes.
prefixesTPrefixesThe prefixes.

Returns

IStringifyCss

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

ParameterTypeDescription
fnFThe function to curry.
ctx?anyThe 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); // => 8

dateToUTCString()

ts
function dateToUTCString(time): string;

Defined in: src/dateToUTCString.ts:18

Converts a date to a UTC string.

Parameters

ParameterTypeDescription
timenumber | DateThe 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

ParameterTypeDescription
emitTThe function to decorate.
decoratorsDecorator<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

ParameterTypeDescription
fnFnThe function to defer.
args?ArrayLike<any>The arguments to pass to the function.
ctx?anyThe 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 runs

deflags()

ts
function deflags(flags): string[];

Defined in: src/deflags.ts:13

Returns an array of keys for which the flag value is truthy.

Parameters

ParameterTypeDescription
flagsRecord<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

ParameterTypeDescription
srcRecord<string, any>The object to build the flags string from.
suffix?stringThe 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

ParameterTypeDescription
valuestringThe string to convert.
delimiterstringThe 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

ParameterTypeDescription
initial?TDestroyFn[]The initial destroyer functions.

Returns

IDestroyer

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 ParameterDefault type
Tany
C extends Record<string, T> | T[]Record<string, T> | T[]

Parameters

ParameterTypeDescription
collectionCThe collection to iterate over.
iteratee(this, value, key, collection) => voidThe function to invoke for each item.
ctx?anyThe 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 1

eachApply()

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

ParameterTypeDescription
funcsTThe functions to apply.
args?any[]The arguments to pass to the functions.
context?anyThe 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 ParameterDefault type
T extends Record<string, TFn> | TFn[]-
Rany

Parameters

ParameterTypeDescription
fnsTThe functions to apply.
args?any[]The arguments to pass to the functions.
ctx?anyThe 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

ParameterTypeDescription
funcsanyArray or object of functions to call.
args?any[]Arguments forwarded to each function.
context?anyOptional this context.
onError?(err) => voidOptional 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

ParameterTypeDescription
separatorstringThe separator to use.
escaped?stringThe 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

ParameterTypeDescription
separatorstringThe separator to use.
escaped?stringThe 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

ParameterTypeDescription
vstringThe string to escape.

Returns

string

The escaped string.

Example

ts
escapeHTML('<b>hi</b>'); // => '&lt;b&gt;hi&lt;/b&gt;'

escapeQuote()

ts
function escapeQuote(v): string;

Defined in: src/escapeQuote.ts:11

Escapes double quotes and backslashes.

Parameters

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
collectionArrayLike<T>The collection to check.
identity(value, index, collection) => anyThe identity to check.

Returns

boolean

true if all elements satisfy the predicate, false otherwise.

Example

ts
every([2, 4, 6], v => v % 2 === 0); // => true

everyIn()

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

ParameterTypeDescription
collectionTThe object to check.
identity(value, key, collection) => anyPredicate called with (value, key, collection).
ctx?anyOptional 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); // => true

executeTry()

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

ParameterTypeDescription
fn(...args) => TThe function to execute.
args?IArguments | any[]The arguments to pass to the function.
context?anyThe context to pass to the function.
onError?(error) => voidThe error handler.

Returns

T

The result of the function, or undefined if an error occurred.

Example

ts
executeTry(() => JSON.parse('bad'));            // => undefined
executeTry(() => 42);                           // => 42

extend()

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

ParameterTypeDescription
dstDThe destination object.
src?SThe 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

ParameterTypeDescription
dstRecord<string, any>The destination object.
srcRecord<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

ParameterTypeDescription
dstRecord<string, any>The destination object.
srcRecord<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

ParameterTypeDescription
dstTDstThe destination object.
srcTSrcThe 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

ParameterTypeDescription
collectionT[]The array to filter.
iteratee(value, index, collection) => booleanThe function to call for each item.
output?T[]The array to filter into.
ctx?anyThe 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

ParameterTypeDescription
collectionRecord<string, T>The object to filter.
iteratee(value, key, collection) => anyThe function to call for each property.
output?Record<string, T>The object to filter into.
ctx?anyThe 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

ParameterTypeDescription
fn(inc, dec) => voidThe function to wrap.
callback?() => voidThe 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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
collectionT[]The array to search in.
iteratee(value, index, collection) => booleanThe function to call for each item.
ctx?anyThe 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); // => 2

findIn()

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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
collectionRecord<string, T>The object to search in.
iteratee(value, key, collection) => booleanThe function to call for each property.
ctx?anyThe 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); // => 2

findIndex()

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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
collectionT[]The array to search in.
iteratee(value, index, collection) => booleanThe function to call for each item.
ctx?anyThe 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); // => 1

findIndexLast()

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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
collectionT[]The array to search in.
iteratee(value, index, collection) => booleanThe function to call for each item.
ctx?anyThe 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); // => 3

findKey()

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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
collectionRecord<string, T>The object to search in.
iteratee(value, key, collection) => anyThe function to call for each property.
ctx?anyThe 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

ParameterTypeDescription
flagsstring[]The array of dot‑separated keys to build the flags object from.
dst?TFlagsObjectThe 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

ParameterTypeDescription
vstringSpace-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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
inputany[]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

ParameterTypeDescription
srcT[]The array to iterate over.
fn(this, value, index, collection) => voidThe function to call for each item.
ctx?anyThe 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 3

forIn()

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

ParameterTypeDescription
objTThe object to iterate over.
iteratee(this, value, key, obj) => voidThe function to call for each property.
ctx?anyThe 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 2

forInOwn()

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

ParameterTypeDescription
objTThe object to iterate over.
iteratee(this, value, key, obj) => voidThe function to call for each property.
ctx?anyThe 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 2

fromPairs()

ts
function fromPairs(entries, dst?): Record<string, any>;

Defined in: src/fromPairs.ts:10

Converts array of [key, value] pairs into an object.

Parameters

ParameterTypeDescription
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

ParameterTypeDescription
scopeanyThe object to get the value from.
pathstring | numberThe 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[]') // => 9

getBase()

ts
function getBase(scope, path): any;

Defined in: src/get.ts:51

Gets a value from an object by a dot path string.

Parameters

ParameterTypeDescription
scopeanyThe object to get the value from.
pathArrayLike<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', '[]']) // => 9

getByType()

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

ParameterTypeDescription
argsany[]The arguments to map.
typesMapRecord<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

ParameterTypeDescription
keystringThe 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

ParameterTypeDefault valueDescription
src{ id?: any; parent?: any; }[]undefinedThe source array of items.
idanyundefinedThe id of the parent item.
dst?any[]undefinedThe destination array.
depth?number10The 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

ParameterTypeDescription
prefix?stringOptional 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

ParameterTypeDescription
wTViewportWindowContextThe 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

ParameterTypeDescription
scopeanyThe object to get the value from.
pathArrayLike<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

ParameterTypeDescription
indexOf(input) => numberThe 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

ParameterTypeDescription
selfArrayLike<T>The array to search in.
itemTThe 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);      // => false

indexOf()

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

ParameterTypeDescription
collectionArrayLike<T>The array to search in.
vTThe 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);     // => -1

invoke()

ts
function invoke(
   scope, 
   path, 
   args?, 
   ctx?): any;

Defined in: src/invoke.ts:38

Invokes a function by path in the scope.

Parameters

ParameterTypeDescription
scopeanyThe scope to invoke the function in.
pathstring | number | ArrayLike<string>The path to the function.
args?any[]The arguments to pass to the function.
ctx?anyThe context to use for the function.

Returns

any

The result of the function.

Example

ts
invoke({ fn: (x: number) => x * 2 }, 'fn', [5]); // => 10

invokeBase()

ts
function invokeBase(
   scope, 
   path, 
   args?, 
   ctx?): any;

Defined in: src/invoke.ts:14

Invokes a function by path in the scope.

Parameters

ParameterTypeDescription
scopeanyThe scope to invoke the function in.
pathArrayLike<string>The path to the function.
args?any[]The arguments to pass to the function.
ctx?anyThe 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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
inputArrayLike<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]) // => 3

limitStream()

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

ParameterTypeDefault valueDescription
streamReadableStream & { close?: () => void; }undefinedSource readable stream.
limitnumberDEFAULT_LIMITMaximum items per batch (default: 100).

Returns

ILimitStream

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 objects

localStorageProvider()

ts
function localStorageProvider(win): TLocalStorage;

Defined in: src/localStorageProvider.ts:76

Creates a local storage provider.

Parameters

ParameterTypeDescription
winTLocalStorageWindowContextThe Window whose localStorage is managed.

Returns

TLocalStorage

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

ParameterTypeDefault valueDescription
lengthnumberundefinedThe length of the loop.
fn(index) => voidundefinedThe function to call for each index.
startnumber0The start index.

Returns

void

void

Example

ts
loop(10, (index) => console.log(index)); // => 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

loopMap()

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 ParameterDefault type
Tany

Parameters

ParameterTypeDescription
lengthnumberThe length of the loop.
fnanyThe 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

ParameterTypeDescription
vstringThe 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 ParameterDefault type
Tany
Rany

Parameters

ParameterTypeDescription
collectionT[]The collection to map.
iteratee(value, index, collection) => RThe function to call for each item.
output?R[]The array to map into.
ctx?anyThe 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 ParameterDefault type
Tany
Rany

Parameters

ParameterTypeDescription
collectionRecord<string, T>The object to map.
iteratee(value, key, collection) => RThe function to call for each property.
output?Record<string, R>The object to map into.
ctx?anyThe 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

ParameterTypeDescription
keysstring[]The keys to map the values to.

Returns

TMapper

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

ParameterTypeDescription
mergingSrcanyThe values to merge.
dst?anyThe destination object.
asArray?booleanWhether 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 changes

noopHandle()

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

ParameterTypeDescription
vTThe 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

ParameterTypeDescription
step?stringThe step value to normalize.
limit?numberThe limit value to normalize the step value to.

Returns

number

The normalized step value.

Example

ts
normalizeStep('10') // => 10
normalizeStep('10', 100) // => 10

normalizeTimePart()

ts
function normalizeTimePart(n): string;

Defined in: src/dateToUTCString.ts:7

Normalizes a time part.

Parameters

ParameterTypeDescription
nnumberThe 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

ParameterTypeDescription
funcTThe 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

ParameterTypeDescription
handle() => voidThe 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

ParameterTypeDefault valueDescription
collectionArrayLike<any>undefinedThe collection to search in.
iteratee(item, index, collection) => anynoopHandleThe iteratee to apply to each item.
compare?boolean | CompareFnundefinedThe comparator to use.

Returns

any

The only item from the collection.

Example

ts
onlyBy([1, 2, 3], (item) => item, (v, w) => v > w); // => 3

onlyByIn()

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

ParameterTypeDefault valueDescription
collectionRecord<string, any>undefinedThe collection to search in.
iteratee(item, key, collection) => anynoopHandleThe iteratee to apply to each item.
compare?boolean | CompareFnundefinedThe 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); // => 3

padEnd()

ts
function padEnd(
   v, 
   length, 
   space?): string;

Defined in: src/padEnd.ts:14

Polyfill-friendly padEnd implementation for strings.

Parameters

ParameterTypeDescription
vstringThe string to pad.
lengthnumberThe length to pad the string to.
space?stringThe 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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
vanyThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDefault valueDescription
fn(timestep) => voidundefinedThe function to call on each timestep.
timestepnumberundefinedThe timestep to use.
runner(fn, delayMs, args?, self?) => () => voidintervalAsyncThe runner to use.

Returns

ts
{
  isPlaying: () => boolean;
  pause: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
  play: () => { pause: () => ...; play: () => ...; isPlaying: () => boolean; };
}

The physic render provider.

NameTypeDefined in
isPlaying()() => booleansrc/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(); // => boolean

pick()

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

ParameterTypeDescription
inputRecord<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

ParameterTypeDescription
srcTThe source object.
mapMThe 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

ParameterTypeDescription
fnFThe function to wrap.
PromiseCtor?PromiseConstructorThe 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

ParameterTypeDescription
getter() => anyThe getter to use.

Returns

The predicate.

(instance) => boolean

Example

ts
const isClass = providerOfIsClass(() => Class);
isClass(new Class()); // => true
isClass(new Class2()); // => false

push()

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

ParameterTypeDescription
selfT[]The array to push the items into.
...itemsany[]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

ParameterTypeDescription
dstArrayLike<any>The destination array.
srcArrayLike<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

ParameterTypeDescription
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')); // => void

range()

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

ParameterTypeDefault valueDescription
endnumberundefinedEnd value (or count when start is 0).
startnumber0Start value (default: 0).
stepnumber1Step 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

ParameterTypeDescription
wTReadyWindowContextThe window to create the DOM ready helper for.

Returns

TReadyFn

The DOM ready helper.

Example

ts
const ready = readyProvider(window);
ready(() => console.log('DOM is ready')); // => void
ready(() => console.log('DOM is ready')); // => void

reduce()

ts
function reduce(
   collection, 
   iteratee, 
   accumulator): any;

Defined in: src/reduce.ts:13

Reduces an array-like collection into a single value.

Parameters

ParameterTypeDescription
collectionanyThe collection to reduce.
iteratee(acc, value, index, collection) => anyThe function to call for each item.
accumulatoranyThe initial accumulator value.

Returns

any

The reduced value.

Example

ts
const sum = reduce([1, 2, 3], (acc, value) => acc + value, 0); // => 6

reduceIn()

ts
function reduceIn(
   collection, 
   iteratee, 
   accumulator, 
   ctx?): any;

Defined in: src/reduceIn.ts:12

Reduces an object into a single value.

Parameters

ParameterTypeDescription
collectionanyThe object to reduce.
iteratee(acc, value, key, collection) => anyThe function to call for each property.
accumulatoranyThe initial accumulator value.
ctx?anyThe 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); // => 6

regexpMapperProvider()

ts
function regexpMapperProvider(regexp, keys): TRouteMapper;

Defined in: src/regexpMapperProvider.ts:27

Creates a regexp mapper provider.

Parameters

ParameterTypeDescription
regexpRegExpThe regexp to use.
keysstring[] | ((values, dst?) => void)The keys to use.

Returns

TRouteMapper

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

ParameterTypeDescription
vstring | RegExpThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
collectionT[]The collection to remove elements from.
indexnumberThe index of the first element to remove.
length?numberThe 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

ParameterTypeDescription
collectionT[]The collection to remove elements from.
vTThe value to remove from the collection.

Returns

number

The number of elements removed.

Example

ts
removeOf([1, 2, 3, 4, 5], 3); // => 1

repeat()

ts
function repeat(str, count): string;

Defined in: src/repeat.ts:12

Repeats a string count times.

Parameters

ParameterTypeDescription
strstringThe string to repeat.
countnumberThe 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 ParameterDefault type
TReqany

Parameters

ParameterTypeDescription
chainTChainHandler<TReq>[]The chain of handlers.
reqTReqThe request object.
end(req) => anyCalled 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); // => 1
ts
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

ParameterTypeDescription
routestringThe route to parse.

Returns

TRouteMapper

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

ParameterTypeDescription
routestringThe route to parse.
keysstring[]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

ParameterTypeDefault valueDescription
scopeScopeNode[]undefinedThe scope to join.
openCharstring'('The open character.
closeCharstring')'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

ParameterTypeDefault valueDescription
inputstringundefinedThe input string to split.
openCharstring'('The open character.
closeCharstring')'The close character.

Returns

ScopeNode[]

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 ParameterDefault type
F extends (...args) => Promise<any>(...args) => any

Parameters

ParameterTypeDescription
fnFThe function to send.

Returns

The sending queue.

{ (...args): Promise<any>; drain: Promise<any>; }

NameTypeDefined 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

ParameterTypeDescription
ctxanyThe context to set the value in.
pathstring | string[]The path to set the value in.
valueanyThe 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

ParameterTypeDescription
nodeHTMLElementThe style element to update.
textstringThe CSS text to set.
documentTSetStyleSheetDocumentThe 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

ParameterTypeDescription
fnTThe function to wrap.
ctx?anyThe 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

ParameterTypeDescription
vunknownThe collection to get the size of.

Returns

number

The size of the collection.

Example

ts
size({ a: 1, b: 2 }); // => 2
size([]); // => 0

slice()

ts
function slice(
   self, 
   start?, 
   end?): any[];

Defined in: src/slice.ts:14

Slices an array-like collection.

Parameters

ParameterTypeDescription
selfArrayLike<any>The array-like collection to slice.
start?numberThe start index.
end?numberThe 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

ParameterTypeDescription
valuestringThe 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

ParameterTypeDescription
collectionT[]The collection to search in.
identity?anyThe 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 });   // => true

someIn()

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

ParameterTypeDescription
collectionTThe collection to search in.
identity?anyThe 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); // => true

sort()

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

ParameterTypeDescription
srcT[]The array to sort.
iteratee?(a, b) => numberThe 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

ParameterTypeDescription
srcT[]The array to sort.
iteratee(item) => anyThe 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 ParameterDefault type
Tany

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(); // => 1

startsWith()

ts
function startsWith(
   self, 
   searchString, 
   position?): boolean;

Defined in: src/startsWith.ts:17

Functional wrapper around String.prototype.startsWith with a fallback.

Parameters

ParameterTypeDescription
selfstringThe string to check.
searchStringstringThe string to search for.
position?numberThe 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) // => true

storageInit()

ts
function storageInit(cookie): any;

Defined in: src/cookieStorageProvider.ts:26

Initializes the storage.

Parameters

ParameterTypeDescription
cookiestringThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
docTStylesRenderDocumentThe document in which <style> elements are managed.
prefixstringPrefix 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

ParameterTypeDescription
collectionany[]The collection to subscribe to.
listenersany[]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 handlers

templatePartsJoin()

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

ParameterTypeDescription
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

ParameterTypeDefault valueDescription
templatestringundefinedThe template to build.
parse(expression) => (scope) => anynullThe function to parse the expressions.
regexpRegExpREGEXPThe 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

ParameterTypeDefault valueDescription
textunknownundefinedThe text to shorten.
limitnumber12The limit to shorten the text to.
suffixstring'...'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

ParameterTypeDescription
vstringThe string to convert to HTML.

Returns

string

The HTML string.

Example

ts
toHTML('a < b\nfoo'); // => 'a &lt; b<br/>foo'

toLower()

ts
function toLower(v): string;

Defined in: src/toLower.ts:9

Converts a string to lower case.

Parameters

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
paramsanyThe 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 undefined are converted to null
  • Objects and arrays are copied recursively
  • Cyclic references are converted to null

Parameters

ParameterTypeDescription
valueanyThe 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

ParameterTypeDescription
valueanyThe value to convert.
excludesany[]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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
sstringThe 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

ParameterTypeDescription
inputT[]The input array to filter.
comparator?(a, b) => booleanThe 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

ParameterTypeDescription
querystringQuery string, optionally including the leading ?.

Returns

TParams

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

ParameterType
querystring
output?any

Returns

TParams


unslash()

ts
function unslash(v): string;

Defined in: src/unslash.ts:17

Normalizes backslash escaping:

  • \\\\\\
  • \\ → empty string (removes the escape)

Parameters

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
vstringThe 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

ParameterTypeDescription
_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

TUrlProps

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

ParameterTypeDescription
hrefstringThe URL string to parse.

Returns

TUrlProps

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

ParameterTypeDefault valueDescription
inputstringundefinedThe string to convert.
transliteRecord<string, string>TRANSLITECustom 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

ParameterTypeDescription
objanyThe 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

ParameterType
optionsIVariantsProviderOptions

Returns

TVariants


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

ParameterTypeDescription
millis?numberTimeout in milliseconds (defaults to 0).
params?AOptional 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 100ms

withDefer()

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

ParameterTypeDescription
fnTThe function to debounce.
ctx?anyOptional this context.
result?anyValue 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 once

withDelay()

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

ParameterTypeDescription
fnTThe function to debounce.
delayMsnumberDebounce window in milliseconds.
ctx?anyOptional this context.
result?anyValue 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') runs

withLock()

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

ParameterTypeDescription
fnTThe function to protect.
ctx?anyOptional this context.
result?anyValue 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 runs

without()

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

ParameterTypeDescription
srcRecord<string, any>Source object.
withoutKeysany[]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

ParameterTypeDescription
dataanyThe value to clean.
depth?numberHow 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);    // => null

withoutEmptyBase()

ts
function withoutEmptyBase(src, depth): any;

Defined in: src/withoutEmpty.ts:14

Parameters

ParameterType
srcany
depthnumber

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

ParameterTypeDescription
fnTThe function to debounce.
delayMsnumberDelay window in milliseconds.
ctx?anyOptional 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 call

withResult()

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

ParameterTypeDescription
fnTThe function to call for side effects.
resultRThe fixed return value.
ctx?anyOptional this context.

Returns

Wrapper that always returns result.

(...args) => R

Example

ts
const handler = withResult(e => e.preventDefault(), false);
handler(event); // => false

wrapper()

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

ParameterTypeDescription
vAThe value to wrap.

Returns

A zero-argument function that always returns v.

() => A

Example

ts
const getZero = wrapper(0);
getZero(); // => 0

MIT License