@dxtmisha/functional-basic 0.10.1 → 0.11.1

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 CHANGED
@@ -183,7 +183,12 @@ export declare class Api {
183
183
  /**
184
184
  * Shape of API response data wrapper/ Структура обёртки данных ответа API
185
185
  */
186
- export declare type ApiData<T = any> = T & {
186
+ export declare type ApiData<T = any> = T extends any[] ? T : ApiDataItem<T>;
187
+
188
+ /**
189
+ * Type of API response data item/ Тип элемента данных ответа API
190
+ */
191
+ export declare type ApiDataItem<T = any> = T & {
187
192
  /** Primary payload (optional)/ Основная полезная нагрузка (опционально) */
188
193
  data?: T;
189
194
  /** Success flag/ Флаг успешности */
@@ -677,6 +682,12 @@ export declare type ApiStatusType = 'success' | 'error' | 'warning' | 'info';
677
682
  */
678
683
  export declare const applyTemplate: (text: string, replacement?: Record<string, string | number> | string[]) => string;
679
684
 
685
+ /**
686
+ * Converts an array type to an item type (extracts the item type from an array)/
687
+ * Преобразует тип массива в тип элемента (извлекает тип элемента из массива)
688
+ */
689
+ export declare type ArrayToItem<T> = T extends any[] ? T[number] : T;
690
+
680
691
  /**
681
692
  * The method creates an array of "count" elements with values equal to `value`.
682
693
  *
@@ -1615,9 +1626,11 @@ export declare type EventActivityItem<E extends ElementOrWindow> = {
1615
1626
  };
1616
1627
 
1617
1628
  /**
1618
- * Class for working with events.
1629
+ * Advanced wrapper for managing event listeners on DOM elements or the `window` object.
1630
+ * It simplifies the entire event lifecycle (start, stop, toggle, reset) and provides built-in optimizations for high-frequency events like `resize` and `scroll-sync`.
1619
1631
  *
1620
- * Класс для работы с событиями.
1632
+ * Продвинутая обертка для управления слушателями событий на DOM-элементах или объекте `window`.
1633
+ * Упрощает весь жизненный цикл событий (запуск, остановка, переключение, сброс) и предоставляет встроенные оптимизации для высокочастотных событий, таких как `resize` и `scroll-sync`.
1621
1634
  */
1622
1635
  export declare class EventItem<E extends ElementOrWindow, O extends Event, D extends Record<string, any> = Record<string, any>> {
1623
1636
  protected listener?: EventListenerDetail<O, D> | undefined;
@@ -1659,15 +1672,14 @@ export declare class EventItem<E extends ElementOrWindow, O extends Event, D ext
1659
1672
  protected activity: boolean;
1660
1673
  protected activityItems: EventActivityItem<E>[];
1661
1674
  /**
1662
- * Classes Constructor
1663
- * @param elementSelector element/ элемент
1664
- * @param type type/ тип
1665
- * @param listener the object that receives a notification (an object that implements the
1666
- * Event interface) when an event of the specified type occurs/ объект, который принимает
1667
- * уведомление, когда событие указанного типа произошло
1668
- * @param options object that specifies characteristics/ объект options
1669
- * @param detail an event-dependent value associated with the event/ зависимое от события
1670
- * значение, связанное с событием
1675
+ * Constructor for EventItem.
1676
+ *
1677
+ * Конструктор для EventItem.
1678
+ * @param elementSelector target element or selector where the listener should be attached / целевой элемент или селектор, к которому должен быть прикреплен слушатель
1679
+ * @param type event type (e.g., 'click'), array of types, or special optimization types ('resize', 'scroll-sync') / тип события (например, 'click'), массив типов или специальные типы оптимизации ('resize', 'scroll-sync')
1680
+ * @param listener the handler function to be executed when the event occurs / функция-обработчик, которая будет выполнена при возникновении события
1681
+ * @param options standard EventListenerOptions or boolean for useCapture / стандартные EventListenerOptions или логическое значение для useCapture
1682
+ * @param detail additional data provided to the listener via the custom Event interaction / дополнительные данные, предоставляемые слушателю через кастомное взаимодействие с событием
1671
1683
  */
1672
1684
  constructor(elementSelector?: ElementOrString<E>, type?: string | string[], listener?: EventListenerDetail<O, D> | undefined, options?: EventOptions, detail?: D | undefined);
1673
1685
  /**
@@ -1720,13 +1732,12 @@ export declare class EventItem<E extends ElementOrWindow, O extends Event, D ext
1720
1732
  */
1721
1733
  setDetail(detail?: D): this;
1722
1734
  /**
1723
- * The method of the EventTarget sends an Event to the object, (synchronously) invoking
1724
- * the affected EventListeners in the appropriate order.
1735
+ * Triggers the events on the target element, optionally with a new detail value.
1736
+ * This method manually initiates a `CustomEvent` dispatch for all specified types.
1725
1737
  *
1726
- * Отправляет событие в общую систему событий. Это событие подчиняется тем же правилам
1727
- * поведения "Захвата" и "Всплывания" как и непосредственно инициированные события.
1728
- * @param detail an event-dependent value associated with the event/ зависимое от события
1729
- * значение, связанное с событием
1738
+ * Инициирует события на целевом элементе, опционально с новым значением detail.
1739
+ * Этот метод вручную запускает диспетчеризацию `CustomEvent` для всех указанных типов.
1740
+ * @param detail the value to be passed as the event detail / значение, которое будет передано как detail события
1730
1741
  */
1731
1742
  dispatch(detail?: D | undefined): this;
1732
1743
  /**
@@ -1825,11 +1836,11 @@ export declare function forEach<T, R, D extends T[] | Record<string, T> | Map<st
1825
1836
  * Class for formatting a list of data based on provided options.
1826
1837
  *
1827
1838
  * Класс для форматирования списка данных на основе предоставленных параметров.
1828
- * @template Item - type of items in the list/ тип элементов в списке.
1829
- * @template Options - type of formatting options/ тип параметров форматирования.
1830
- * @template List - type of the list of items/ тип списка элементов.
1839
+ * @template Options - type of formatting options / тип параметров форматирования.
1840
+ * @template List - type of the list of items (can be an array or a single item) / тип списка элементов (может быть массивом или одним элементом).
1841
+ * @template Item - type of a single item in the list / тип одного элемента в списке.
1831
1842
  */
1832
- export declare class Formatters<Item extends FormattersListItem, Options extends FormattersOptionsList, List extends FormattersList<Item> = FormattersList<Item>> {
1843
+ export declare class Formatters<Options extends FormattersOptionsList = FormattersOptionsList, List extends FormattersListProp = FormattersListProp, Item extends FormattersItemProp<List> = FormattersItemProp<List>> {
1833
1844
  protected options: Options;
1834
1845
  protected list?: List | undefined;
1835
1846
  /**
@@ -1841,13 +1852,36 @@ export declare class Formatters<Item extends FormattersListItem, Options extends
1841
1852
  * @param list initial list of data to format/ начальный список данных для форматирования
1842
1853
  */
1843
1854
  constructor(options: Options, list?: List | undefined);
1855
+ /**
1856
+ * Checks if the list is set.
1857
+ *
1858
+ * Проверяет, установлен ли список.
1859
+ * @returns true if the list is set, false otherwise/ true, если список установлен, иначе false
1860
+ */
1861
+ is(): boolean;
1862
+ /**
1863
+ * Checks if the list is an array.
1864
+ *
1865
+ * Проверяет, является ли список массивом.
1866
+ * @returns true if the list is an array, false otherwise/ true, если список является массивом, иначе false
1867
+ */
1868
+ isArray(): this is this & {
1869
+ list: FormattersList<Item>;
1870
+ };
1871
+ /**
1872
+ * Returns the count of records in the list.
1873
+ *
1874
+ * Возвращает количество записей в списке.
1875
+ * @returns count of records/ количество записей
1876
+ */
1877
+ length(): number;
1844
1878
  /**
1845
1879
  * Returns the current list of data.
1846
1880
  *
1847
1881
  * Возвращает текущий список данных.
1848
1882
  * @returns the list of data or undefined if not set/ список данных или undefined, если не задан
1849
1883
  */
1850
- getList(): List | undefined;
1884
+ getList(): FormattersList<Item>;
1851
1885
  /**
1852
1886
  * Returns the current formatting options.
1853
1887
  *
@@ -1862,17 +1896,17 @@ export declare class Formatters<Item extends FormattersListItem, Options extends
1862
1896
  * @param list list of data/ список данных
1863
1897
  * @returns the Formatters instance for chaining/ экземпляр Formatters для цепочки вызовов
1864
1898
  */
1865
- setList(list: List): this;
1899
+ setList(list?: List): this;
1866
1900
  /**
1867
- * Formats the entire list based on the provided options.
1901
+ * Formats the entire list or a single item based on the provided options.
1868
1902
  * Adds formatted values with the suffix 'Format' to each item.
1869
1903
  *
1870
- * Форматирует весь список на основе предоставленных параметров.
1904
+ * Форматирует весь список или один элемент на основе предоставленных параметров.
1871
1905
  * Добавляет отформатированные значения с суффиксом 'Format' к каждому элементу.
1872
- * @returns the list of items with additional formatted columns/
1873
- * список элементов с дополнительными отформатированными столбцами
1906
+ * @returns formatted data (list or single item) with additional formatted columns /
1907
+ * отформатированные данные (список или один элемент) с дополнительными отформатированными столбцами
1874
1908
  */
1875
- to(): FormattersListColumns<Item, Options>;
1909
+ to(): FormattersReturn<List, Options>;
1876
1910
  /**
1877
1911
  * Generates formatted data for a single item based on options.
1878
1912
  *
@@ -1960,73 +1994,247 @@ export declare class Formatters<Item extends FormattersListItem, Options extends
1960
1994
  protected formatUnit(value: any, options?: FormattersOptionsUnit): string;
1961
1995
  }
1962
1996
 
1997
+ /**
1998
+ * Utility type to capitalize a camelCase or dot-notated string.
1999
+ *
2000
+ * Вспомогательный тип для капитализации строки.
2001
+ *
2002
+ * @template K - The string to capitalize / Строка для капитализации.
2003
+ */
1963
2004
  export declare type FormattersCapitalize<K extends string> = K extends `${infer First}.${infer Rest}` ? `${First}${Capitalize<FormattersCapitalize<Rest>>}` : K;
1964
2005
 
2006
+ /**
2007
+ * Utility type to extract column keys from formatting options.
2008
+ *
2009
+ * Вспомогательный тип для извлечения ключей столбцов.
2010
+ *
2011
+ * @template T - The formatting options list type / Тип списка параметров форматирования.
2012
+ */
1965
2013
  export declare type FormattersColumns<T extends FormattersOptionsList> = (keyof T & string)[];
1966
2014
 
2015
+ /**
2016
+ * Represents a data item with additional formatted properties.
2017
+ *
2018
+ * Представляет элемент данных с доп. отформатированными свойствами.
2019
+ *
2020
+ * @template T - The original item type / Исходный тип элемента.
2021
+ * @template KT - Array of property keys / Массив ключей свойств.
2022
+ */
1967
2023
  export declare type FormattersDataItem<T extends FormattersListItem, KT extends string[]> = {
1968
2024
  [K in keyof T | FormattersKey<KT[number]>]: K extends keyof T ? T[K] : string;
1969
2025
  };
1970
2026
 
2027
+ /**
2028
+ * Extracts the single item type from a single item or a list of items.
2029
+ *
2030
+ * Извлекает тип одного элемента из одного элемента или из списка элементов.
2031
+ *
2032
+ * @template List - The type of the input data / Тип входных данных.
2033
+ */
2034
+ export declare type FormattersItemProp<List extends FormattersListProp> = ArrayToItem<List>;
2035
+
2036
+ /**
2037
+ * Utility type to generate a formatted property key.
2038
+ *
2039
+ * Вспомогательный тип для генерации ключа отформатированного свойства.
2040
+ *
2041
+ * @template K - The original property key / Ключ исходного свойства.
2042
+ * @template A - The suffix to add / Суффикс.
2043
+ */
1971
2044
  export declare type FormattersKey<K, A extends string = 'Format'> = K extends string ? `${FormattersCapitalize<K>}${A}` : never;
1972
2045
 
2046
+ /**
2047
+ * An array of data items to be formatted.
2048
+ *
2049
+ * Массив элементов данных для форматирования.
2050
+ *
2051
+ * @template Item - The type of data items / Тип элементов данных.
2052
+ */
1973
2053
  export declare type FormattersList<Item extends FormattersListItem> = Item[];
1974
2054
 
2055
+ /**
2056
+ * A single data item formatted based on the provided options list.
2057
+ *
2058
+ * Один элемент данных, отформатированный на основе параметров.
2059
+ *
2060
+ * @template T - The original item type / Исходный тип элемента.
2061
+ * @template O - The formatting options / Параметры форматирования.
2062
+ */
2063
+ export declare type FormattersListColumnItem<T extends FormattersListItem, O extends FormattersOptionsList> = FormattersDataItem<T, FormattersColumns<O>>;
2064
+
2065
+ /**
2066
+ * A list of data items formatted based on the provided options list.
2067
+ *
2068
+ * Список элементов данных, отформатированных на основе параметров.
2069
+ *
2070
+ * @template T - The original item type / Исходный тип элемента.
2071
+ * @template O - The formatting options / Параметры форматирования.
2072
+ */
1975
2073
  export declare type FormattersListColumns<T extends FormattersListItem, O extends FormattersOptionsList> = FormattersListFormat<T, FormattersColumns<O>>;
1976
2074
 
2075
+ /**
2076
+ * An array of data items with additional formatted properties.
2077
+ *
2078
+ * Массив элементов данных с доп. отформатированными свойствами.
2079
+ *
2080
+ * @template T - The original item type / Исходный тип элемента.
2081
+ * @template K - Array of property keys / Массив ключей свойств.
2082
+ */
1977
2083
  export declare type FormattersListFormat<T extends FormattersListItem, K extends string[]> = FormattersDataItem<T, K>[];
1978
2084
 
2085
+ /**
2086
+ * Represents a single data item as a key-value record.
2087
+ *
2088
+ * Представляет один элемент данных как запись "ключ-значение".
2089
+ */
1979
2090
  export declare type FormattersListItem = Record<string, any>;
1980
2091
 
2092
+ /**
2093
+ * Possible formats for input data: either a single item or a list of items.
2094
+ *
2095
+ * Возможные форматы входных данных: либо один элемент, либо список элементов.
2096
+ */
2097
+ export declare type FormattersListProp = FormattersList<FormattersListItem> | FormattersListItem;
2098
+
2099
+ /**
2100
+ * Options for currency formatting.
2101
+ *
2102
+ * Параметры для форматирования валюты.
2103
+ */
1981
2104
  export declare type FormattersOptionsCurrency = {
2105
+ /** The name of the property in the data item that contains the currency code / Имя свойства в элементе данных, которое содержит код валюты. */
1982
2106
  currencyPropName?: string;
2107
+ /** Currency code or international number format options / Код валюты или международные параметры форматирования чисел. */
1983
2108
  options?: string | Intl.NumberFormatOptions;
2109
+ /** If true, only the numeric value will be returned / Если true, будет возвращено только числовое значение. */
1984
2110
  numberOnly?: boolean;
1985
2111
  };
1986
2112
 
2113
+ /**
2114
+ * Options for date formatting.
2115
+ *
2116
+ * Параметры для форматирования даты.
2117
+ */
1987
2118
  export declare type FormattersOptionsDate = {
2119
+ /** The type of date representation / Тип представления даты. */
1988
2120
  type?: GeoDate;
2121
+ /** International date-time format options / Междунар. параметры форматирования даты и времени. */
1989
2122
  options?: Intl.DateTimeFormatOptions['month'] | Intl.DateTimeFormatOptions;
2123
+ /** Use 24-hour format if true / Использовать 24-часовой формат, если true. */
1990
2124
  hour24?: boolean;
1991
2125
  };
1992
2126
 
2127
+ /**
2128
+ * Mapping of formatter types to their respective option types.
2129
+ *
2130
+ * Соответствие типов форматировщиков их типам параметров.
2131
+ *
2132
+ * @template Type - The formatter type / Тип форматировщика.
2133
+ */
1993
2134
  export declare type FormattersOptionsInformation<Type extends FormattersType> = Type extends FormattersType.currency ? FormattersOptionsCurrency : Type extends FormattersType.date ? FormattersOptionsDate : Type extends FormattersType.name ? FormattersOptionsName : Type extends FormattersType.number ? FormattersOptionsNumber : Type extends FormattersType.plural ? FormattersOptionsPlural : Type extends FormattersType.unit ? FormattersOptionsUnit : Record<string, any>;
1994
2135
 
2136
+ /**
2137
+ * Configuration for a single property formatter.
2138
+ *
2139
+ * Конфигурация для форматировщика одного свойства.
2140
+ *
2141
+ * @template Type - The type of formatter / Тип форматировщика.
2142
+ * @template R - The return type / Возвращаемый тип.
2143
+ */
1995
2144
  export declare type FormattersOptionsItem<Type extends FormattersType = FormattersType, R = string> = {
2145
+ /** The type of formatter / Тип форматировщика. */
1996
2146
  type?: Type;
2147
+ /** Custom transformation function / Пользовательская функция преобразования. */
1997
2148
  transformation?: (valueOriginal: any, item: any, options?: FormattersOptionsInformation<Type>) => R;
2149
+ /** Options for the specified formatter type / Параметры для указанного типа форматировщика. */
1998
2150
  options?: FormattersOptionsInformation<Type>;
1999
2151
  };
2000
2152
 
2153
+ /**
2154
+ * A dictionary mapping property paths to their formatting configurations.
2155
+ *
2156
+ * Словарь, сопоставляющий пути к свойствам с их конфигурациями форматирования.
2157
+ */
2001
2158
  export declare type FormattersOptionsList = Record<string, FormattersOptionsItem>;
2002
2159
 
2160
+ /**
2161
+ * Options for name formatting.
2162
+ *
2163
+ * Параметры для форматирования имени.
2164
+ */
2003
2165
  export declare type FormattersOptionsName = {
2166
+ /** Property name for the last name / Имя свойства для фамилии. */
2004
2167
  lastPropName?: string;
2168
+ /** Property name for the first name / Имя свойства для имени. */
2005
2169
  firstPropName?: string;
2170
+ /** Property name for the middle name / Имя свойства для отчества. */
2006
2171
  surname?: string;
2172
+ /** If true, returns a short version of the name / Если true, возвращает сокращенную версию имени. */
2007
2173
  short?: boolean;
2008
2174
  };
2009
2175
 
2176
+ /**
2177
+ * Options for number formatting.
2178
+ *
2179
+ * Параметры для форматирования чисел.
2180
+ */
2010
2181
  export declare type FormattersOptionsNumber = {
2182
+ /** International number format options / Междунар. параметры форматирования чисел. */
2011
2183
  options?: Intl.NumberFormatOptions;
2012
2184
  };
2013
2185
 
2186
+ /**
2187
+ * Options for plural forms formatting.
2188
+ *
2189
+ * Параметры для форматирования форм множественного числа.
2190
+ */
2014
2191
  export declare type FormattersOptionsPlural = {
2192
+ /** A string containing plural forms / Строка, содержащая формы множественного числа. */
2015
2193
  words: string;
2194
+ /** International plural rules options / Междунар. параметры правил множественного числа. */
2016
2195
  options?: Intl.PluralRulesOptions;
2196
+ /** International number format options for the numeric part / Междунар. параметры форматирования чисел для числовой части. */
2017
2197
  optionsNumber?: Intl.NumberFormatOptions;
2018
2198
  };
2019
2199
 
2200
+ /**
2201
+ * Options for unit formatting.
2202
+ *
2203
+ * Параметры для форматирования единиц измерения.
2204
+ */
2020
2205
  export declare type FormattersOptionsUnit = {
2206
+ /** The unit to format or international number format options / Ед. изм. для форматирования или междунар. параметры форматирования чисел. */
2021
2207
  unit: string | Intl.NumberFormatOptions;
2022
2208
  };
2023
2209
 
2210
+ /**
2211
+ * The return type of the formatter, matching the structure of the input data.
2212
+ *
2213
+ * Возвращаемый тип форматировщика, соответствующий структуре входных данных.
2214
+ *
2215
+ * @template List - The input data type / Тип входных данных.
2216
+ * @template Options - The formatting options / Параметры форматирования.
2217
+ * @template Item - The type of a single item / Тип одного элемента.
2218
+ */
2219
+ export declare type FormattersReturn<List extends FormattersListProp, Options extends FormattersOptionsList = FormattersOptionsList, Item extends FormattersItemProp<List> = FormattersItemProp<List>> = List extends any[] ? FormattersListColumns<Item, Options> : (FormattersListColumnItem<Item, Options> | undefined);
2220
+
2221
+ /**
2222
+ * Enumeration of available formatter types.
2223
+ *
2224
+ * Перечисление доступных типов форматировщиков.
2225
+ */
2024
2226
  export declare enum FormattersType {
2227
+ /** Currency formatting / Форматирование валюты. */
2025
2228
  currency = "currency",
2229
+ /** Date formatting / Форматирование даты. */
2026
2230
  date = "date",
2231
+ /** Name formatting / Форматирование имени. */
2027
2232
  name = "name",
2233
+ /** Number formatting / Форматирование чисел. */
2028
2234
  number = "number",
2235
+ /** Plural forms formatting / Форматирование форм множественного числа. */
2029
2236
  plural = "plural",
2237
+ /** Unit formatting (e.g., meters, kilograms) / Форматирование единиц измерения (например, метры, килограммы). */
2030
2238
  unit = "unit"
2031
2239
  }
2032
2240
 
@@ -2599,6 +2807,18 @@ export declare class GeoIntl {
2599
2807
  * @param compareFn a function for sorting/ функция для сортировки
2600
2808
  */
2601
2809
  sort<T>(data: T[], compareFn?: (a: T, b: T) => [string, string]): T[];
2810
+ /**
2811
+ * Checks if the Intl object is available.
2812
+ *
2813
+ * Проверяет доступность объекта Intl.
2814
+ */
2815
+ private hasIntl;
2816
+ /**
2817
+ * Checks if the Intl.DateTimeFormat object is available.
2818
+ *
2819
+ * Проверяет доступность объекта Intl.DateTimeFormat.
2820
+ */
2821
+ private hasIntlDateTimeFormat;
2602
2822
  /**
2603
2823
  * The object enables language-sensitive number formatting.
2604
2824
  *
@@ -3281,6 +3501,14 @@ export declare function initScrollbarOffset(): Promise<void>;
3281
3501
  */
3282
3502
  export declare function intersectKey<T, KT extends keyof T, C, KC extends keyof C>(data?: T, comparison?: C): Record<KT & KC, T[KT]>;
3283
3503
 
3504
+ /**
3505
+ * Checks if the API response is successful.
3506
+ *
3507
+ * Проверяет, является ли ответ API успешным.
3508
+ * @param data API response data/ данные ответа API
3509
+ */
3510
+ export declare const isApiSuccess: <T>(data: ApiData<T>) => boolean;
3511
+
3284
3512
  /**
3285
3513
  * Checks if the values are arrays.
3286
3514
  *