@dxtmisha/functional-basic 0.7.1 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/library.d.ts +136 -18
- package/dist/library.js +1205 -1079
- package/package.json +2 -2
package/dist/library.d.ts
CHANGED
|
@@ -86,14 +86,14 @@ export declare class Api {
|
|
|
86
86
|
* Изменить функцию перед запросом.
|
|
87
87
|
* @param callback function for call/ функция для вызова
|
|
88
88
|
*/
|
|
89
|
-
static setPreparation(callback: () => Promise<void>): Api;
|
|
89
|
+
static setPreparation(callback: (apiFetch: ApiFetch) => Promise<void>): Api;
|
|
90
90
|
/**
|
|
91
91
|
* Modify the function after the request.
|
|
92
92
|
*
|
|
93
93
|
* Изменить функцию после запроса.
|
|
94
94
|
* @param callback function for call/ функция для вызова
|
|
95
95
|
*/
|
|
96
|
-
static setEnd(callback: (query: Response) => Promise<ApiPreparationEnd>): Api;
|
|
96
|
+
static setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): Api;
|
|
97
97
|
/**
|
|
98
98
|
* To execute a request.
|
|
99
99
|
*
|
|
@@ -144,7 +144,7 @@ export declare class Api {
|
|
|
144
144
|
* @param queryReturn custom function for reading data/ кастомная функция для чтения данных
|
|
145
145
|
* @param end finalization data/ данные финализации
|
|
146
146
|
*/
|
|
147
|
-
protected static readData(query: Response, queryReturn: ApiFetch['queryReturn'], end: ApiPreparationEnd): Promise<
|
|
147
|
+
protected static readData<T>(query: Response, queryReturn: ApiFetch['queryReturn'], end: ApiPreparationEnd): Promise<ApiData<T>>;
|
|
148
148
|
/**
|
|
149
149
|
* Executing the request.
|
|
150
150
|
*
|
|
@@ -159,17 +159,31 @@ export declare class Api {
|
|
|
159
159
|
* @param data data for transformation/ данные для преобразования
|
|
160
160
|
* @param toData is it necessary to process the data/ нужно ли обрабатывать данные
|
|
161
161
|
*/
|
|
162
|
-
protected static makeData<T>(data: ApiData<T>, toData: boolean): T
|
|
162
|
+
protected static makeData<T>(data: ApiData<T>, toData: boolean): ApiData<T>;
|
|
163
|
+
/**
|
|
164
|
+
* Appends the status object to the response data if possible.
|
|
165
|
+
*
|
|
166
|
+
* Добавляет объект статуса к данным ответа, если это возможно.
|
|
167
|
+
* @param data response data/ данные ответа
|
|
168
|
+
* @param status status object/ объект статуса
|
|
169
|
+
*/
|
|
170
|
+
protected static makeStatus<T>(data: ApiData<T>, status: ApiStatus): ApiData<T>;
|
|
163
171
|
}
|
|
164
172
|
|
|
165
173
|
/**
|
|
166
174
|
* Shape of API response data wrapper/ Структура обёртки данных ответа API
|
|
167
175
|
*/
|
|
168
|
-
export declare type ApiData<T> = T & {
|
|
176
|
+
export declare type ApiData<T = any> = T & {
|
|
169
177
|
/** Primary payload (optional)/ Основная полезная нагрузка (опционально) */
|
|
170
178
|
data?: T;
|
|
171
179
|
/** Success flag/ Флаг успешности */
|
|
172
180
|
success?: boolean;
|
|
181
|
+
/** Status/ Статус */
|
|
182
|
+
status?: ApiStatusType;
|
|
183
|
+
/** Message/ Сообщение */
|
|
184
|
+
message?: string;
|
|
185
|
+
/** Status object/ Объект статуса */
|
|
186
|
+
statusObject?: ApiStatusItem;
|
|
173
187
|
};
|
|
174
188
|
|
|
175
189
|
/**
|
|
@@ -256,6 +270,8 @@ export declare type ApiFetch = {
|
|
|
256
270
|
globalEnd?: boolean;
|
|
257
271
|
/** Additional fetch() options/ Дополнительные опции fetch() */
|
|
258
272
|
init?: RequestInit;
|
|
273
|
+
/** AbortController for canceling the request/ AbortController для отмены запроса */
|
|
274
|
+
controller?: AbortController;
|
|
259
275
|
};
|
|
260
276
|
|
|
261
277
|
/**
|
|
@@ -322,9 +338,9 @@ export declare enum ApiMethodItem {
|
|
|
322
338
|
*/
|
|
323
339
|
export declare class ApiPreparation {
|
|
324
340
|
/** Function for call before the request/ Функция для вызова перед запросом */
|
|
325
|
-
protected callback?: () => Promise<void>;
|
|
341
|
+
protected callback?: (apiFetch: ApiFetch) => Promise<void>;
|
|
326
342
|
/** Function for call after the request/ Функция для вызова после запроса */
|
|
327
|
-
protected callbackEnd?: (query: Response) => Promise<ApiPreparationEnd>;
|
|
343
|
+
protected callbackEnd?: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>;
|
|
328
344
|
/** Is the preparation in progress/ Идет ли подготовка */
|
|
329
345
|
protected loading: boolean;
|
|
330
346
|
/**
|
|
@@ -332,43 +348,47 @@ export declare class ApiPreparation {
|
|
|
332
348
|
*
|
|
333
349
|
* Подготовка перед выполнением запроса.
|
|
334
350
|
* @param active is preparation active/ активна ли подготовка
|
|
351
|
+
* @param apiFetch request options/ опции запроса
|
|
335
352
|
*/
|
|
336
|
-
make(active: boolean): Promise<void>;
|
|
353
|
+
make(active: boolean, apiFetch: ApiFetch): Promise<void>;
|
|
337
354
|
/**
|
|
338
355
|
* Analysis of the request after execution.
|
|
339
356
|
*
|
|
340
357
|
* Анализ запроса после выполнения.
|
|
341
358
|
* @param active is preparation active/ активна ли подготовка
|
|
342
359
|
* @param query data received in the request/ данные, полученные в запросе
|
|
360
|
+
* @param apiFetch request options/ опции запроса
|
|
343
361
|
*/
|
|
344
|
-
makeEnd(active: boolean, query: Response): Promise<ApiPreparationEnd>;
|
|
362
|
+
makeEnd(active: boolean, query: Response, apiFetch: ApiFetch): Promise<ApiPreparationEnd>;
|
|
345
363
|
/**
|
|
346
364
|
* The function is modified for a call before the request.
|
|
347
365
|
*
|
|
348
366
|
* Изменить функцию перед запросом.
|
|
349
367
|
* @param callback function for call/ функция для вызова
|
|
350
368
|
*/
|
|
351
|
-
set(callback: () => Promise<void>): this;
|
|
369
|
+
set(callback: (apiFetch: ApiFetch) => Promise<void>): this;
|
|
352
370
|
/**
|
|
353
371
|
* Modify the function after the request.
|
|
354
372
|
*
|
|
355
373
|
* Изменить функцию после запроса.
|
|
356
374
|
* @param callback function for call/ функция для вызова
|
|
357
375
|
*/
|
|
358
|
-
setEnd(callback: (query: Response) => Promise<ApiPreparationEnd>): this;
|
|
376
|
+
setEnd(callback: (query: Response, apiFetch: ApiFetch) => Promise<ApiPreparationEnd>): this;
|
|
359
377
|
/**
|
|
360
378
|
* To execute preparation.
|
|
361
379
|
*
|
|
362
380
|
* Выполнить подготовку.
|
|
381
|
+
* @param apiFetch request options/ опции запроса
|
|
363
382
|
*/
|
|
364
|
-
protected go(): Promise<void>;
|
|
383
|
+
protected go(apiFetch: ApiFetch): Promise<void>;
|
|
365
384
|
/**
|
|
366
385
|
* Analysis of the request after execution.
|
|
367
386
|
*
|
|
368
387
|
* Анализ запроса после выполнения.
|
|
369
388
|
* @param query data received in the request/ данные, полученные в запросе
|
|
389
|
+
* @param apiFetch request options/ опции запроса
|
|
370
390
|
*/
|
|
371
|
-
protected end(query: Response): Promise<ApiPreparationEnd>;
|
|
391
|
+
protected end(query: Response, apiFetch: ApiFetch): Promise<ApiPreparationEnd>;
|
|
372
392
|
}
|
|
373
393
|
|
|
374
394
|
/**
|
|
@@ -381,6 +401,11 @@ export declare type ApiPreparationEnd = {
|
|
|
381
401
|
data?: any;
|
|
382
402
|
};
|
|
383
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Class for working with API responses.
|
|
406
|
+
*
|
|
407
|
+
* Класс для работы с ответами API.
|
|
408
|
+
*/
|
|
384
409
|
export declare class ApiResponse {
|
|
385
410
|
protected readonly requestDefault: ApiDefault;
|
|
386
411
|
/** List of first-time API requests/ Список первичных API запросов */
|
|
@@ -536,6 +561,12 @@ export declare class ApiStatus {
|
|
|
536
561
|
* Возвращает текст статуса выполнения.
|
|
537
562
|
*/
|
|
538
563
|
getStatusText(): string | undefined;
|
|
564
|
+
/**
|
|
565
|
+
* Returns the last status type.
|
|
566
|
+
*
|
|
567
|
+
* Возвращает последний тип статуса.
|
|
568
|
+
*/
|
|
569
|
+
getStatusType(): ApiStatusType | undefined;
|
|
539
570
|
/**
|
|
540
571
|
* Returns the script execution error.
|
|
541
572
|
*
|
|
@@ -583,6 +614,13 @@ export declare class ApiStatus {
|
|
|
583
614
|
* @param response response data/ данные ответа
|
|
584
615
|
*/
|
|
585
616
|
setLastResponse(response?: any): this;
|
|
617
|
+
/**
|
|
618
|
+
* Sets the last status.
|
|
619
|
+
*
|
|
620
|
+
* Устанавливает последний статус.
|
|
621
|
+
* @param status status/ статус
|
|
622
|
+
*/
|
|
623
|
+
setLastStatus(status?: ApiStatusType): this;
|
|
586
624
|
/**
|
|
587
625
|
* Sets messages from the last request.
|
|
588
626
|
*
|
|
@@ -601,19 +639,29 @@ export declare class ApiStatus {
|
|
|
601
639
|
}
|
|
602
640
|
|
|
603
641
|
export declare type ApiStatusItem = {
|
|
642
|
+
/** HTTP status code/ Код статуса HTTP */
|
|
604
643
|
status?: number;
|
|
644
|
+
/** HTTP status text/ Текст статуса HTTP */
|
|
605
645
|
statusText?: string;
|
|
646
|
+
/** Error message/ Сообщение об ошибке */
|
|
606
647
|
error?: string;
|
|
648
|
+
/** Last response/ Последний ответ */
|
|
607
649
|
lastResponse?: any;
|
|
650
|
+
/** Last status/ Последний статус */
|
|
651
|
+
lastStatus?: ApiStatusType;
|
|
652
|
+
/** Last message/ Последнее сообщение */
|
|
608
653
|
lastMessage?: string;
|
|
609
654
|
};
|
|
610
655
|
|
|
656
|
+
/** API status type/ Тип статуса API */
|
|
657
|
+
export declare type ApiStatusType = 'success' | 'error' | 'warning' | 'info';
|
|
658
|
+
|
|
611
659
|
/**
|
|
612
660
|
* Applies a template to the text, replacing keys with values from the replacement object
|
|
613
661
|
*
|
|
614
662
|
* Применяет шаблон к тексту, заменяя ключи на значения из объекта замены
|
|
615
|
-
* @param text text with a template containing keys in square brackets, for example "[key]"/
|
|
616
|
-
* текст с шаблоном, содержащим ключи в квадратных скобках, например "[key]"
|
|
663
|
+
* @param text text with a template containing keys in square or curly brackets, for example "[key]" or "{key}"/
|
|
664
|
+
* текст с шаблоном, содержащим ключи в квадратных или фигурных скобках, например "[key]" или "{key}"
|
|
617
665
|
* @param replacement an object containing key-value pairs for replacement/
|
|
618
666
|
* объект, содержащий пары ключ-значение для замены
|
|
619
667
|
*/
|
|
@@ -1769,8 +1817,10 @@ export declare function executePromise<T>(callback: (() => Promise<T>) | (() =>
|
|
|
1769
1817
|
* @param data object for iteration/ объект для перебора
|
|
1770
1818
|
* @param callback a function to execute for each element in the array/
|
|
1771
1819
|
* функция, которая будет вызвана для каждого элемента
|
|
1820
|
+
* @param saveUndefined if true, the function will return an array with undefined values/
|
|
1821
|
+
* если true, функция вернет массив с undefined значениями
|
|
1772
1822
|
*/
|
|
1773
|
-
export declare function forEach<T, R, D extends T[] | Record<string, T> | Map<string, T> = T[] | Record<string, T> | Map<string, T>, K = D extends T[] ? number : string>(data: D & (T[] | Record<string, T> | Map<string, T>), callback: (item: T, key: K, dataMain: typeof data) => R): R[];
|
|
1823
|
+
export declare function forEach<T, R, D extends T[] | Record<string, T> | Map<string, T> = T[] | Record<string, T> | Map<string, T>, K = D extends T[] ? number : string>(data: D & (T[] | Record<string, T> | Map<string, T>), callback: (item: T, key: K, dataMain: typeof data) => R, saveUndefined?: boolean): R[];
|
|
1774
1824
|
|
|
1775
1825
|
/**
|
|
1776
1826
|
* Cyclically calls requestAnimationFrame until next returns true
|
|
@@ -2625,7 +2675,7 @@ export declare function getExp(value: string, flags?: string, pattern?: string):
|
|
|
2625
2675
|
* @param item object for work/ объект для работы
|
|
2626
2676
|
* @param path data path/ путь к данным
|
|
2627
2677
|
*/
|
|
2628
|
-
export declare function getItemByPath<T extends Record<string, any
|
|
2678
|
+
export declare function getItemByPath<T extends Record<string, any>, R = string>(item: T, path: string): R | undefined;
|
|
2629
2679
|
|
|
2630
2680
|
/**
|
|
2631
2681
|
* Returns the pressed key.
|
|
@@ -2792,6 +2842,16 @@ export declare function goScroll(selector: string, elementTo: HTMLElement | unde
|
|
|
2792
2842
|
*/
|
|
2793
2843
|
export declare function goScrollSmooth<E extends HTMLElement>(element: E, options?: ScrollIntoViewOptions, shift?: number): void;
|
|
2794
2844
|
|
|
2845
|
+
/**
|
|
2846
|
+
* Scrolls the container to make the target element visible.
|
|
2847
|
+
*
|
|
2848
|
+
* Прокручивает контейнер, чтобы целевой элемент стал видимым.
|
|
2849
|
+
* @param element container element/ элемент контейнера
|
|
2850
|
+
* @param elementTo target element/ целевой элемент
|
|
2851
|
+
* @param behavior scroll behavior/ режим прокрутки
|
|
2852
|
+
*/
|
|
2853
|
+
export declare function goScrollTo(element?: HTMLElement, elementTo?: HTMLElement, behavior?: ScrollBehavior): void;
|
|
2854
|
+
|
|
2795
2855
|
/**
|
|
2796
2856
|
* Working with data stored in hash.
|
|
2797
2857
|
*
|
|
@@ -3017,8 +3077,9 @@ export declare function isDomRuntime(): boolean;
|
|
|
3017
3077
|
*
|
|
3018
3078
|
* Проверяет, является ли нажатая клавиша Enter или Space.
|
|
3019
3079
|
* @param event event object/ объект события
|
|
3080
|
+
* @param isInputElement whether the element is an input element/ является ли элемент полем ввода
|
|
3020
3081
|
*/
|
|
3021
|
-
export declare const isEnter: (event: KeyboardEvent) => boolean;
|
|
3082
|
+
export declare const isEnter: (event: KeyboardEvent, isInputElement?: boolean) => boolean;
|
|
3022
3083
|
|
|
3023
3084
|
/**
|
|
3024
3085
|
* Checks if the field is filled.
|
|
@@ -3053,6 +3114,14 @@ export declare function isFunction<T>(callback: T): callback is Extract<T, Funct
|
|
|
3053
3114
|
*/
|
|
3054
3115
|
export declare function isInDom<E extends ElementOrWindow>(element?: ElementOrString<E>): boolean;
|
|
3055
3116
|
|
|
3117
|
+
/**
|
|
3118
|
+
* Checks if the element is an input field or editable.
|
|
3119
|
+
*
|
|
3120
|
+
* Проверяет, является ли элемент полем ввода или редактируемым.
|
|
3121
|
+
* @param element element to check/ проверяемый элемент
|
|
3122
|
+
*/
|
|
3123
|
+
export declare const isInput: (element: HTMLElement | EventTarget | null) => boolean;
|
|
3124
|
+
|
|
3056
3125
|
/**
|
|
3057
3126
|
* Checks if the value is between integers.
|
|
3058
3127
|
*
|
|
@@ -4471,6 +4540,18 @@ export declare function splice<I>(array: ObjectItem<I>, replacement?: ObjectItem
|
|
|
4471
4540
|
*/
|
|
4472
4541
|
export declare function strFill(value: string, count: number): string;
|
|
4473
4542
|
|
|
4543
|
+
/**
|
|
4544
|
+
* Splits a string by a separator, limited to a certain number of elements.
|
|
4545
|
+
* If a limit is specified, the last element will contain the remainder of the string.
|
|
4546
|
+
*
|
|
4547
|
+
* Разделяет строку по разделителю, ограничивая количество элементов.
|
|
4548
|
+
* Если указан лимит, последний элемент будет содержать остаток строки.
|
|
4549
|
+
* @param value input value/ входное значение
|
|
4550
|
+
* @param separator separator/ разделитель
|
|
4551
|
+
* @param limit limit/ лимит
|
|
4552
|
+
*/
|
|
4553
|
+
export declare function strSplit(value: number | string, separator: string, limit?: number): string[];
|
|
4554
|
+
|
|
4474
4555
|
/**
|
|
4475
4556
|
* Преобразует значение в массив.
|
|
4476
4557
|
* Если переданное значение уже является массивом, возвращается оно само.
|
|
@@ -4655,6 +4736,13 @@ export declare class Translate {
|
|
|
4655
4736
|
* @param data list of texts in the form of key-value/ список текстов в виде ключ-значение
|
|
4656
4737
|
*/
|
|
4657
4738
|
static addNormalOrSync(data: Record<string, string>): Promise<void>;
|
|
4739
|
+
/**
|
|
4740
|
+
* Adds texts synchronously by location.
|
|
4741
|
+
*
|
|
4742
|
+
* Добавляет тексты синхронно по местоположению.
|
|
4743
|
+
* @param data list of texts by location/ список текстов по местоположению
|
|
4744
|
+
*/
|
|
4745
|
+
static addSyncByLocation(data: Record<string, Record<string, string>>): void;
|
|
4658
4746
|
/**
|
|
4659
4747
|
* Change the path to the script for obtaining the translation.
|
|
4660
4748
|
*
|
|
@@ -4663,6 +4751,20 @@ export declare class Translate {
|
|
|
4663
4751
|
*/
|
|
4664
4752
|
static setUrl(url: string): Translate;
|
|
4665
4753
|
static setPropsName(name: string): Translate;
|
|
4754
|
+
/**
|
|
4755
|
+
* Checks for translation by code, taking into account fallback options.
|
|
4756
|
+
*
|
|
4757
|
+
* Проверяет наличие перевода по коду с учетом запасных вариантов.
|
|
4758
|
+
* @param name code name/ название кода
|
|
4759
|
+
*/
|
|
4760
|
+
protected static hasName(name: string): boolean;
|
|
4761
|
+
/**
|
|
4762
|
+
* Retrieves translation text by code, returning the first matching fallback.
|
|
4763
|
+
*
|
|
4764
|
+
* Получает текст перевода по коду, возвращая первое совпадение из запасных вариантов.
|
|
4765
|
+
* @param name code name/ название кода
|
|
4766
|
+
*/
|
|
4767
|
+
protected static getText(name: string): string | undefined;
|
|
4666
4768
|
/**
|
|
4667
4769
|
* Getting the full title for translation.
|
|
4668
4770
|
*
|
|
@@ -4670,6 +4772,20 @@ export declare class Translate {
|
|
|
4670
4772
|
* @param name code name/ название кода
|
|
4671
4773
|
*/
|
|
4672
4774
|
protected static getName(name: string): string;
|
|
4775
|
+
/**
|
|
4776
|
+
* Getting the title for translation by language.
|
|
4777
|
+
*
|
|
4778
|
+
* Получение названия для перевода по языку.
|
|
4779
|
+
* @param name code name/ название кода
|
|
4780
|
+
*/
|
|
4781
|
+
protected static getNameByLanguage(name: string): string;
|
|
4782
|
+
/**
|
|
4783
|
+
* Getting the title for translation globally.
|
|
4784
|
+
*
|
|
4785
|
+
* Получение названия для перевода глобально.
|
|
4786
|
+
* @param name code name/ название кода
|
|
4787
|
+
*/
|
|
4788
|
+
protected static getNameByGlobal(name: string): string;
|
|
4673
4789
|
/**
|
|
4674
4790
|
* Returns a list of names that are not yet in the list.
|
|
4675
4791
|
*
|
|
@@ -4699,6 +4815,8 @@ export declare class Translate {
|
|
|
4699
4815
|
protected static make(): Promise<void>;
|
|
4700
4816
|
}
|
|
4701
4817
|
|
|
4818
|
+
export declare const TRANSLATE_GLOBAL_PREFIX = "global";
|
|
4819
|
+
|
|
4702
4820
|
export declare type TranslateCode = string | string[];
|
|
4703
4821
|
|
|
4704
4822
|
export declare type TranslateItemOrList<T extends TranslateCode> = T extends string[] ? TranslateList<T> : string;
|