@sevtech/kit 0.0.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/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { };
@@ -0,0 +1,89 @@
1
+ import * as i0 from '@angular/core';
2
+ import { PipeTransform, Provider, EnvironmentProviders } from '@angular/core';
3
+ import { Nil } from '@sevtech/kit/misc';
4
+ import { DatePipe, PercentPipe, DecimalPipe, CurrencyPipe } from '@angular/common';
5
+ import { Observable } from 'rxjs';
6
+ import { MaybeAsync } from '@sevtech/kit/ng-misc';
7
+
8
+ type LoadFunction<T> = () => Promise<T>;
9
+ type Plural = (value: number) => number;
10
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;
11
+ type AvailableLocales = Record<string, LocaleItem | LocaleItem['core']>;
12
+ interface ProviderConfig {
13
+ prefix: string;
14
+ suffix: string;
15
+ available: AvailableLocales;
16
+ }
17
+ interface LocaleItem {
18
+ core: LoadFunction<Plural | unknown[]>;
19
+ extra: LoadFunction<Plural | unknown[]>;
20
+ }
21
+
22
+ declare class LocaleDatePipe extends DatePipe implements PipeTransform {
23
+ transform(value: string | number | Date, locale: string, format?: string, timezone?: string): string | null;
24
+ transform(value: Nil, locale: string, format?: string, timezone?: string): null;
25
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocaleDatePipe, never>;
26
+ static ɵpipe: i0.ɵɵPipeDeclaration<LocaleDatePipe, "localeDate", true>;
27
+ }
28
+
29
+ declare class LocalePercentPipe extends PercentPipe implements PipeTransform {
30
+ transform(value: number | string, locale: string, digitsInfo?: string): string | null;
31
+ transform(value: Nil, locale: string, digitsInfo?: string): null;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocalePercentPipe, never>;
33
+ static ɵpipe: i0.ɵɵPipeDeclaration<LocalePercentPipe, "localePercent", true>;
34
+ }
35
+
36
+ declare class LocaleDecimalPipe extends DecimalPipe implements PipeTransform {
37
+ transform(value: number | string, locale: string, digitsInfo?: string): string | null;
38
+ transform(value: null | undefined, locale: string, digitsInfo?: string): null;
39
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocaleDecimalPipe, never>;
40
+ static ɵpipe: i0.ɵɵPipeDeclaration<LocaleDecimalPipe, "localeDecimal", true>;
41
+ }
42
+
43
+ type CurrencyDisplay = boolean | 'code' | 'symbol' | 'symbol-narrow' | (string & {});
44
+ declare class LocaleCurrencyPipe extends CurrencyPipe implements PipeTransform {
45
+ private readonly defaultCurrencyCode;
46
+ transform(value: number | string, locale: string, code?: string, display?: CurrencyDisplay, digitsInfo?: string): string | null;
47
+ transform(value: Nil, locale: string, code?: string, display?: CurrencyDisplay, digitsInfo?: string): null;
48
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocaleCurrencyPipe, never>;
49
+ static ɵpipe: i0.ɵɵPipeDeclaration<LocaleCurrencyPipe, "localCurrency", true>;
50
+ }
51
+
52
+ declare class LocalizationService {
53
+ private readonly weekStart$;
54
+ private readonly localizationConfig;
55
+ readonly locales: string[];
56
+ readonly weekStart$$: i0.Signal<WeekDay>;
57
+ readonly locale$$: i0.Signal<string>;
58
+ setLocale(locale: string): void;
59
+ private normalizeWeekStart;
60
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocalizationService, never>;
61
+ static ɵprov: i0.ɵɵInjectableDeclaration<LocalizationService>;
62
+ }
63
+
64
+ declare class LocalizationError extends Error {
65
+ readonly name: string;
66
+ payload: unknown;
67
+ constructor(message: string, payload?: unknown, cause?: unknown);
68
+ }
69
+
70
+ declare const enum Feature {
71
+ weekStart = 3,
72
+ localeSync = 0,
73
+ localeStart = 1,
74
+ defaultLocale = 2
75
+ }
76
+ type i18nProvider<Brand extends Feature> = Provider & {
77
+ __brand: Brand;
78
+ };
79
+ type i18nProviders = ReturnType<typeof withWeekStart> | ReturnType<typeof withLocaleSync> | ReturnType<typeof withLocaleStart> | ReturnType<typeof withDefaultLocale>;
80
+ declare function withLocaleStart(locale: string): i18nProvider<Feature.localeStart>;
81
+ declare function withLocaleStart(factory: () => Observable<string | Nil>): i18nProvider<Feature.localeStart>;
82
+ declare function withDefaultLocale(locale: string): i18nProvider<Feature.defaultLocale>;
83
+ declare function withWeekStart(factory: () => MaybeAsync<number>): i18nProvider<Feature.weekStart>;
84
+ declare function withLocaleSync(syncFunction: () => (locale: string) => void): i18nProvider<Feature.localeSync>;
85
+ declare function provideLocaleKit(available: AvailableLocales, ...providers: i18nProviders[]): EnvironmentProviders;
86
+ declare function provideLocaleKit(config: ProviderConfig, ...providers: i18nProviders[]): EnvironmentProviders;
87
+
88
+ export { LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocalePercentPipe, LocalizationError, LocalizationService, provideLocaleKit, withDefaultLocale, withLocaleStart, withLocaleSync, withWeekStart };
89
+ export type { AvailableLocales };
@@ -0,0 +1,509 @@
1
+ /**
2
+ * Тип для осознанного использования any, а также для быстрого поиска в случае рефакторинга
3
+ * @example
4
+ * function logValue(value: SafeAny): void {
5
+ * console.log(value);
6
+ * }
7
+ */
8
+ type SafeAny = any;
9
+ /**
10
+ * Значение или массив значений заданного типа
11
+ * @example
12
+ * function processItems(items: MaybeArray<string>): void {
13
+ * const arr = Array.isArray(items) ? items : [items];
14
+ * }
15
+ */
16
+ type MaybeArray<T> = T | T[];
17
+ /**
18
+ * Значение или функция возвращающая значение
19
+ * @example
20
+ * function resolve<T>(value: MaybeFunction<T>): T {
21
+ * return isFunction(value) ? value() : value;
22
+ * }
23
+ */
24
+ type MaybeFunction<T> = T | (() => T);
25
+ /**
26
+ *
27
+ * @example
28
+ * function getUser(id: ID): User | Nil {
29
+ * // ... возвращает User или null/undefined
30
+ * }
31
+ */
32
+ type Nil = null | undefined;
33
+ /**
34
+ * Тип для представления «пустых» значений (null/undefined/''/[])
35
+ * @description Включает:
36
+ * - null и undefined (Nil)
37
+ * - Пустую строку
38
+ * - Пустой массив
39
+ *
40
+ * @example
41
+ * function isEmpty(value: Empty | unknown): boolean {
42
+ * return value === '' || value === null || value === undefined || value?.length === 0;
43
+ * }
44
+ */
45
+ type Empty = Nil | '' | [];
46
+ /**
47
+ * Универсальный тип идентификатора
48
+ * @description Может представлять строковые или числовые идентификаторы
49
+ *
50
+ * @example
51
+ * interface User {
52
+ * id: ID; // string | number
53
+ * name: string;
54
+ * }
55
+ */
56
+ type ID = `${number}` | number;
57
+ /**
58
+ * Тип для представления UUID
59
+ */
60
+ type UUID = `${string}-${string}-${string}-${string}-${string}`;
61
+ /**
62
+ * Тип конструктора класса
63
+ */
64
+ type ConstructorTypeOf<T> = new (...args: SafeAny[]) => T;
65
+ /**
66
+ * Все примитивные типы TypeScript
67
+ * @description Включает все базовые типы, не являющиеся объектами:
68
+ * - string, number, bigint, boolean, symbol
69
+ * - null и undefined
70
+ *
71
+ * @example
72
+ * function isPrimitive(value: Primitive | object): boolean {
73
+ * return typeof value !== 'object' || value === null;
74
+ * }
75
+ */
76
+ type Primitive = string | number | bigint | boolean | symbol | null | undefined;
77
+
78
+ /**
79
+ * Извлекает тип элементов из коллекций (массивов, Set, Map и т.д.)
80
+ * @example
81
+ * type T = ExtractType<string[]>; // string
82
+ * type T = ExtractType<Set<number>>; // number
83
+ */
84
+ type ExtractType<T> = T extends (Array<infer U> | Set<infer U> | Map<PropertyKey, infer U> | WeakMap<WeakKey, infer U> | WeakSet<infer U> | Record<PropertyKey, infer U>) ? U : never;
85
+
86
+ /**
87
+ * Допустимые CSS единицы измерения
88
+ */
89
+ type CSSUnits = 'px' | 'em' | 'rem' | '%' | 'vw' | 'vh' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'ex' | 'fr';
90
+ /**
91
+ * CSS размер с единицами измерения
92
+ * @example
93
+ * type Width = CSSDimension<'px'|'%'>; // `${number}px` | `${number}%`
94
+ */
95
+ type CSSDimension<Units extends CSSUnits = never> = [Units] extends [never] ? `${number}${CSSUnits}` : `${number}${Extract<CSSUnits, Units>}`;
96
+ /**
97
+ * HEX-представление цвета
98
+ * @example
99
+ * const hex: CSSHexColor = '#f00' || '#ff0000' || '#f00a' || '#ff0000ff';
100
+ */
101
+ type CSSHexColor = `#${string}`;
102
+ /**
103
+ * RGB/RGBA представление цвета
104
+ * @example
105
+ * const rgb: CSSRGBColor = 'rgb(255, 0, 0)' || 'rgba(255, 0, 0, 0.5)' || 'rgba(0, 0, 0, 25%)'
106
+ */
107
+ type CSSRGBColor = `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number}%)` | `rgba(${number},${number},${number},${number})`;
108
+ /**
109
+ * Специальные цветовые значения
110
+ */
111
+ type CSSSpecialColor = 'currentColor' | 'transparent' | 'inherit' | 'initial' | 'revert' | 'revert-layer' | 'unset';
112
+ /**
113
+ * Комплексный тип для CSS-цветов
114
+ */
115
+ type CSSColor = CSSHexColor | CSSRGBColor | CSSSpecialColor;
116
+
117
+ /**
118
+ * Преобразует snake_case строку в camelCase
119
+ * @example
120
+ * type T = CamelCase<'hello_world'> // 'helloWorld'
121
+ * type T = CamelCase<'MY_VAR'> // 'MYVAR' (сохраняет регистр)
122
+ */
123
+ type CamelCase<T extends string> = T extends `${infer A}_${infer B}` ? `${A}${CamelCase<Capitalize<B>>}` : T;
124
+ /**
125
+ * Преобразует camelCase строку в snake_case
126
+ * @example
127
+ * type T = SnakeCase<'helloWorld'> // 'hello_world'
128
+ * type T = SnakeCase<'MyVar'> // '_my_var'
129
+ */
130
+ type SnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Capitalize<T> ? '_' : ''}${Lowercase<T>}${SnakeCase<U>}` : S;
131
+ /**
132
+ * Получает объединение обязательных ключей объекта
133
+ * @example
134
+ * type T = RequiredKeys<{ a: number; b?: string }> // 'a'
135
+ */
136
+ type RequiredKeys<T extends object> = keyof {
137
+ [K in keyof T as T extends Record<K, T[K]> ? K : never]: K;
138
+ };
139
+ /**
140
+ * Получает объединение опциональных ключей объекта
141
+ * @example
142
+ * type T = OptionalKeys<{ a: number; b?: string }> // 'b'
143
+ */
144
+ type OptionalKeys<T extends object> = keyof {
145
+ [K in keyof T as T extends Record<K, T[K]> ? never : K]: K;
146
+ };
147
+ /**
148
+ * Рекурсивно получает тип свойства по цепочке ключей
149
+ * @example
150
+ * type T = PickKey<{ a: { b: number } }, 'a.b'> // number
151
+ * type T = PickKey<{ a: string[] }, 'a.0'> // never
152
+ */
153
+ type PickKey<Object, Key extends string, Separator extends string = '.'> = Object extends object ? Key extends `${infer Head}${Separator}${infer Tail}` ? Head extends keyof Object ? PickKey<Object[Head], Tail, Separator> : never : Key extends keyof Object ? Object[Key] : never : never;
154
+ type Join<K, P, Separator extends string = '.'> = K extends string ? P extends string ? `${K}${Separator}${P}` : never : never;
155
+ /**
156
+ * Возвращает возможные сочетания ключей объекта, в виде строк
157
+ * разделенных указанным разделителем (по умолчанию ".") и с максимально глубиной погружения до 8 уровня
158
+ * @example
159
+ * type T = DeepKeys<{ a: { b: number } }> // 'a.b'
160
+ * type T = DeepKeys<{ a: string[], b: { c: number }}, '/'> // 'b/c'
161
+ */
162
+ type DeepKeys<Object, Separator extends string = '.', MaxDepth extends number = 8, Depth extends any[] = []> = Depth['length'] extends MaxDepth ? string : Object extends object ? {
163
+ [K in keyof Object & string]: K | (Object[K] extends Record<string, unknown> ? Join<K, DeepKeys<Object[K], Separator, MaxDepth, [...Depth, 1]>, Separator> : never);
164
+ }[keyof Object & string] : string;
165
+ /**
166
+ * Рекурсивно делает все свойства объекта опциональными
167
+ * @example
168
+ * type T = DeepPartial<{ a: { b: number } }> // { a?: { b?: number } }
169
+ */
170
+ type DeepPartial<T> = T extends object ? {
171
+ [K in keyof T]?: DeepPartial<T[K]>;
172
+ } : T;
173
+ /**
174
+ * Рекурсивно делает все свойства объекта обязательными
175
+ * @example
176
+ * type T = DeepRequired<{ a?: { b?: number } }> // { a: { b: number } }
177
+ */
178
+ type DeepRequired<T> = T extends object ? {
179
+ [K in keyof T]-?: DeepRequired<T[K]>;
180
+ } : T;
181
+
182
+ /**
183
+ * Генерирует UUID 4 версии
184
+ * @example
185
+ * const id = randomUUID(); // 'f47ac10b-58cc-4372-a567-0e02b2c3d479'
186
+ */
187
+ declare function randomUUID(): UUID;
188
+
189
+ /**
190
+ * Пустая функция-заглушка, возвращающая саму себя
191
+ * @description
192
+ * - Не имеет побочных эффектов
193
+ * - Может использоваться для инициализации или подмены функций
194
+ *
195
+ * @example
196
+ * const callback = noop; // Безопасная заглушка
197
+ * callback(); // Возвращает саму функцию noop
198
+ */
199
+ declare const noop: () => typeof noop;
200
+ /**
201
+ * Преобразует значение в boolean по правилам Angular
202
+ * @example
203
+ * toBoolean(null) // false
204
+ * toBoolean('false') // false
205
+ * toBoolean(0) // true
206
+ * toBoolean({}) // true
207
+ */
208
+ declare function toBoolean(value: unknown): boolean;
209
+ /**
210
+ * Генерирует случайное целое число в заданном диапазоне
211
+ * @example
212
+ * randomNumber(1, 5) // 3
213
+ * randomNumber(10, 10) // 10
214
+ */
215
+ declare function randomNumber(min: number, max: number): number;
216
+ /**
217
+ * Возвращает случайный элемент массива или null
218
+ * @example
219
+ * randomArrayItem([1, 2, 3]) // 2
220
+ * randomArrayItem([]) // null
221
+ * randomArrayItem('test') // null
222
+ */
223
+ declare function randomArrayItem<T>(array: T[]): T;
224
+ declare function randomArrayItem<T extends Exclude<SafeAny, []>>(item: T): null;
225
+ /**
226
+ * Возвращает первое значение не равное null или undefined из списка аргументов
227
+ * @example
228
+ * coalesce(null, undefined, 42) // 42
229
+ * coalesce('', 0, false) // ''
230
+ */
231
+ declare function coalesce<Arg>(...args: Arg[]): NonNullable<Arg> | null;
232
+ /**
233
+ * Безопасно вызывает функцию, если она определена
234
+ * @example
235
+ * safeFnCall(console.log, 'test') // выводит 'test'
236
+ * safeFnCall(undefined, 'test') // undefined
237
+ */
238
+ declare function safeFnCall<Fn extends ((...args: SafeAny[]) => SafeAny)>(fn: Fn | undefined, ...args: Parameters<Fn>): ReturnType<Fn> | undefined;
239
+ /**
240
+ * Преобразует значение или массив значений в массив
241
+ * @example
242
+ * toArray(1) // [1]
243
+ * toArray([1, 2]) // [1, 2]
244
+ */
245
+ declare function toArray<T>(value: MaybeArray<T>): T[];
246
+ /**
247
+ * Возвращаем значение или вызывает функцию для получения значения
248
+ * @example
249
+ * resolveMaybeFn(42) // 42
250
+ * resolveMaybeFn(() => 42) // 42
251
+ */
252
+ declare function resolveMaybeFn<T>(value: MaybeFunction<T>): T;
253
+
254
+ type SplitPath = Record<'dirname' | 'filename' | 'extension' | 'params', string>;
255
+ /**
256
+ * Разбивает файловый путь на структурные компоненты
257
+ * @example
258
+ * splitPath('src/app/components/header.component.ts?param=1#hash')
259
+ * // Returns:
260
+ * // {
261
+ * // dirname: 'src/app/components/',
262
+ * // filename: 'header.component',
263
+ * // extension: '.ts',
264
+ * // params: '?param=1#hash'
265
+ * // }
266
+ */
267
+ declare function splitPath(path: string): SplitPath;
268
+
269
+ /**
270
+ * Парсит JSON строку с явной типизацией результата
271
+ * @example
272
+ * const data = parseJSON<{ id: number }>('{"id": 123}'); // { id: 123 }
273
+ * parseJSON(null) // null
274
+ * parseJSON('d: 123') // SyntaxError
275
+ */
276
+ declare function parseJSON(json: string | null): null;
277
+ declare function parseJSON<ReturnType>(json: string | null): ReturnType | null;
278
+ /**
279
+ * Безопасный парсинг JSON с обработкой ошибок и fallback значением
280
+ * @example
281
+ * safeParseJSON('invalid') // null
282
+ * safeParseJSON('[1,2,3]') // [1,2,3]
283
+ * safeParseJSON('{invalid}', []) // []
284
+ */
285
+ declare function safeParseJSON(json: string | null): null;
286
+ declare function safeParseJSON<ReturnType>(json: string | null): ReturnType | null;
287
+ declare function safeParseJSON<ReturnType, Fallback = null>(json: string | null, fallback: Fallback): ReturnType | Fallback;
288
+
289
+ /**
290
+ * Типизированная обёртка для Object.keys()
291
+ * @example
292
+ * objectKeys({ a: 1, b: 2 }) // ['a', 'b'] с типом ('a' | 'b')[]
293
+ * objectKeys([1, 2, 3]) // ['0', '1', '2'] с типом string[]
294
+ * objectKeys('test') // [] с типом string[]
295
+ * objectKeys(null) // Ошибка типа
296
+ */
297
+ declare function objectKeys<T extends Nil>(object: T): never;
298
+ declare function objectKeys<T extends Primitive | SafeAny[]>(object: T): string[];
299
+ declare function objectKeys<T extends Record<PropertyKey, SafeAny>>(object: T): Array<keyof T>;
300
+ /**
301
+ * Типизированная обёртка для Object.entries()
302
+ * @example
303
+ * objectEntries({ a: 1, b: '2' }) // [['a', 1], ['b', '2']] с типом (['a', number] | ['b', string])[]
304
+ * objectEntries([10, 20]) // [['0', 10], ['1', 20]] с типом [string, number][]
305
+ * objectEntries(new Set([1,2])) // [] с типом []
306
+ * objectEntries('test') // [] с типом []
307
+ */
308
+ declare function objectEntries<T extends Nil>(object: T): never;
309
+ declare function objectEntries<T extends Set<SafeAny> | Map<SafeAny, SafeAny> | Primitive>(object: T): [];
310
+ declare function objectEntries<T extends SafeAny[]>(object: T): [string, keyof T][];
311
+ declare function objectEntries<T extends Record<Readonly<string>, SafeAny>>(object: T): Array<[keyof T, T[keyof T]]>;
312
+ declare function objectEntries<T>(object: Record<string, T> | ArrayLike<T>): [string, T][];
313
+
314
+ /**
315
+ * Безопасно извлекает значение из объекта по пути в виде строки.
316
+ * @example
317
+ * const obj = { a: { b: 42 }, c: 'hello' };
318
+ * pickKey(obj, 'a.b'); // 42
319
+ * pickKey(obj, 'a.x', 'default'); // 'default'
320
+ * pickKey(obj, 'c'); // 'hello'
321
+ *
322
+ * // Использование кастомного разделителя
323
+ * const obj2 = { a: { b: { c: 1 } } };
324
+ * pickKey(obj2, 'a/b/c', undefined, '/'); // 1
325
+ */
326
+ declare function pickKey<Object extends Record<string, SafeAny>, Path extends DeepKeys<Object, Separator>, Fallback extends unknown = undefined, Separator extends string = '.'>(object: Object | Nil, path: Path, fallback?: Fallback, separator?: Separator): PickKey<Object, Path> extends Object ? Fallback : PickKey<Object, Path>;
327
+
328
+ /**
329
+ * Базовый type guard с возможностью кастомизации проверки.
330
+ * @example
331
+ * if(isTypeWith<MyType>(someValue)) {
332
+ * // someValue is MyType
333
+ * }
334
+ */
335
+ declare function isTypeWith<T>(data: unknown): data is T;
336
+ /**
337
+ * Базовый type guard с кастомной функцией валидации
338
+ * @example
339
+ * const result = isTypeWith<number>(someValue, (data: unknown) => typeof data === 'number');
340
+ */
341
+ declare function isTypeWith<T>(data: unknown, validator: (data: unknown) => boolean): data is T;
342
+ /**
343
+ * Фабрика для создания кастомных type guard'ов
344
+ * @example
345
+ * const isBoolean = guardFactory<boolean>(data =>
346
+ * typeof data === 'boolean'
347
+ * );
348
+ *
349
+ * if (isBoolean(someValue)) {
350
+ * // someValue is boolean
351
+ * }
352
+ *
353
+ */
354
+ declare function guardFactory<T>(fn: (data: unknown) => boolean): (data: unknown) => data is T;
355
+
356
+ /**
357
+ * Проверяет HEX-цвета без альфа-канала (3 или 6 символов)
358
+ * @example #f00, #ff0000
359
+ */
360
+ declare const isHexWithoutAlpha: (data: unknown) => data is `#${string}`;
361
+ /**
362
+ * Проверяет HEX-цвета с альфа-каналом (4 или 8 символов)
363
+ * @example #f00a, #ff0000ff
364
+ */
365
+ declare const isHexWithAlpha: (data: unknown) => data is `#${string}`;
366
+ /**
367
+ * Проверяет любой валидный HEX-цвет
368
+ * @example #f00, #ff0000, #f00a, #ff0000ff
369
+ */
370
+ declare const isHexColor: (data: unknown) => data is `#${string}`;
371
+
372
+ /**
373
+ * Проверяет, является ли значение массивом (включая readonly массивы)
374
+ * @example
375
+ * const arr = [1, 2, 3];
376
+ * if (isArray(arr)) {
377
+ * // arr is number[]
378
+ * }
379
+ */
380
+ declare function isArray<T>(data: unknown): data is T[] | readonly T[];
381
+ /**
382
+ * Проверяет, является ли значение пустым массивом
383
+ * @example
384
+ * const arr: unknown = [];
385
+ * if (isEmptyArray(arr)) {
386
+ * // arr is unknown[]
387
+ * }
388
+ */
389
+ declare function isEmptyArray<T>(data: unknown): data is T[];
390
+ /**
391
+ * Проверяет, является ли значение непустым массивом
392
+ * @example
393
+ * const arr: unknown = [1, 2, 3];
394
+ * if (isNonEmptyArray<number>(arr)) {
395
+ * // arr is number[] и доступен arr[0]
396
+ * }
397
+ */
398
+ declare function isNonEmptyArray<T>(data: unknown): data is T[];
399
+ type PlainObject<T> = [
400
+ unknown
401
+ ] extends [T] ? Record<PropertyKey, unknown> : T extends object ? T extends Iterable<SafeAny> ? never : T : never;
402
+ /**
403
+ * Проверяет, является ли значение простым объектом (не массивом, не классом)
404
+ * @example
405
+ * const obj = { key: 'value' };
406
+ * if (isPlainObject(obj)) {
407
+ * // obj is plain object
408
+ * }
409
+ */
410
+ declare function isPlainObject<T>(data: T): data is PlainObject<T>;
411
+ /**
412
+ * Проверяет, является ли значение функцией
413
+ * @example
414
+ * const fn = () => console.log('test');
415
+ * if (isFunction(fn)) {
416
+ * // fn is Function
417
+ * }
418
+ */
419
+ declare function isFunction(data: unknown): data is Function;
420
+ /**
421
+ * Проверяет принадлежность значения к определенному классу
422
+ * @example
423
+ * class MyClass {}
424
+ * const instance = new MyClass();
425
+ * if (isInstance(instance, MyClass)) {
426
+ * // instance is MyClass
427
+ * }
428
+ */
429
+ declare function isInstance<T>(target: unknown, constructor: ConstructorTypeOf<T>): target is T;
430
+ /**
431
+ * Проверяет, является ли значение объектом Window
432
+ * @example
433
+ * if (isWindow(document)) {
434
+ * // document is Window
435
+ * }
436
+ */
437
+ declare function isWindow<T extends Window = Window>(data: unknown): data is T;
438
+
439
+ /**
440
+ * Проверяет, является ли значение булевым типом
441
+ * @example
442
+ * isBoolean(true) // => true
443
+ * isBoolean('false') // => false
444
+ */
445
+ declare const isBoolean: (data: unknown) => data is boolean;
446
+ /**
447
+ * Проверяет, является ли значение числом (исключает массивы и NaN)
448
+ * @example
449
+ * isNumber(42) // => true
450
+ * isNumber('42') // => true
451
+ * isNumber('42t') // => false
452
+ * isNumber(NaN) // => false
453
+ */
454
+ declare const isNumber: (data: unknown) => data is number;
455
+ /**
456
+ * Проверяет, является ли значение строкой
457
+ * @example
458
+ * isString('hello') // => true
459
+ * isString(123) // => false
460
+ */
461
+ declare const isString: (data: unknown) => data is string;
462
+ /**
463
+ * Проверяет, является ли значение пустой строкой
464
+ * @example
465
+ * isEmptyString(' ') // => true
466
+ * isEmptyString('') // => true
467
+ * isEmptyString(' test ') // => false
468
+ */
469
+ declare const isEmptyString: (data: unknown) => data is string;
470
+ /**
471
+ * Проверяет, является ли значение непустой строкой
472
+ * @example
473
+ * isNonEmptyString('test') // => true
474
+ * isNonEmptyString(' ') // => false
475
+ */
476
+ declare const isNonEmptyString: (data: unknown) => data is string;
477
+ /**
478
+ * Проверяет, является ли значение undefined
479
+ * @example
480
+ * isUndefined(undefined) // => true
481
+ * isUndefined(null) // => false
482
+ */
483
+ declare const isUndefined: (data: unknown) => data is undefined;
484
+ /**
485
+ * Проверяет, является ли значение null или undefined
486
+ * @example
487
+ * isNil(null) // => true
488
+ * isNil(undefined) // => true
489
+ * isNil(0) // => false
490
+ */
491
+ declare const isNil: (data: unknown) => data is Nil;
492
+ /**
493
+ * Проверяет, что значение определено (не null и не undefined)
494
+ * @example
495
+ * isDefined('test') // => true
496
+ * isDefined(null) // => false
497
+ */
498
+ declare function isDefined<T>(data: T): data is Exclude<T, Nil>;
499
+ /**
500
+ * Проверяет, что переданное значение является UUID
501
+ * @example
502
+ * isValidUUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8') // true
503
+ * isValidUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479') // true
504
+ * isValidUUID('6ba7b810-9eee-e1d1-80b4-00c04fd43') // false
505
+ */
506
+ declare const isValidUUID: (data: unknown) => data is `${string}-${string}-${string}-${string}-${string}`;
507
+
508
+ export { coalesce, guardFactory, isArray, isBoolean, isDefined, isEmptyArray, isEmptyString, isFunction, isHexColor, isHexWithAlpha, isHexWithoutAlpha, isInstance, isNil, isNonEmptyArray, isNonEmptyString, isNumber, isPlainObject, isString, isTypeWith, isUndefined, isValidUUID, isWindow, noop, objectEntries, objectKeys, parseJSON, pickKey, randomArrayItem, randomNumber, randomUUID, resolveMaybeFn, safeFnCall, safeParseJSON, splitPath, toArray, toBoolean };
509
+ export type { CSSColor, CSSDimension, CSSHexColor, CSSRGBColor, CSSSpecialColor, CSSUnits, CamelCase, ConstructorTypeOf, DeepKeys, DeepPartial, DeepRequired, Empty, ExtractType, ID, MaybeArray, MaybeFunction, Nil, OptionalKeys, PickKey, Primitive, RequiredKeys, SafeAny, SnakeCase, UUID };