@brandup/ui-helpers 1.0.44 → 2.0.2

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/mjs/index.js CHANGED
@@ -1,183 +1,12 @@
1
- function getProperty(obj, path) {
2
- if (!obj)
3
- return null;
4
- const props = path.split('.');
5
- for (let i = 0; i < props.length; i++) {
6
- const name = props[i];
7
- if (!(name in obj))
8
- return undefined;
9
- obj = obj[name];
10
- }
11
- return obj;
12
- }
13
- function hasProperty(obj, path) {
14
- if (!obj)
15
- return false;
16
- const props = path.split('.');
17
- for (let i = 0; i < props.length; i++) {
18
- const name = props[i];
19
- if (!(name in obj))
20
- return false;
21
- obj = obj[name];
22
- }
23
- return true;
24
- }
25
-
26
- var object = /*#__PURE__*/Object.freeze({
27
- __proto__: null,
28
- getProperty: getProperty,
29
- hasProperty: hasProperty
30
- });
31
-
32
- function isFunction(value) {
33
- return (typeof value === "function");
34
- }
35
- function isString(value) {
36
- return (typeof value === "string" || value instanceof String);
37
- }
38
-
39
- var type = /*#__PURE__*/Object.freeze({
40
- __proto__: null,
41
- isFunction: isFunction,
42
- isString: isString
43
- });
44
-
45
- const minWait = (func, minTime) => {
46
- if (!minTime)
47
- return func;
48
- const beginTime = Date.now();
49
- const ret = (...args) => {
50
- const rightTime = getRightTime(beginTime, minTime);
51
- if (rightTime)
52
- window.setTimeout(() => func(...args), rightTime);
53
- else
54
- func(...args);
55
- };
56
- return ret;
57
- };
58
- async function minWaitAsync(func, minTime, abort) {
59
- if (!minTime)
60
- return func();
61
- const beginTime = Date.now();
62
- const result = await func();
63
- const rightTime = getRightTime(beginTime, minTime);
64
- if (rightTime)
65
- await delay(rightTime, abort);
66
- return result;
67
- }
68
- const getRightTime = (start, minTime) => {
69
- const finishTime = Date.now();
70
- const w = minTime - (finishTime - start);
71
- return w > minTime * 0.1 ? w : 0;
72
- };
73
- function delay(time, abort) {
74
- return new Promise((resolve, reject) => {
75
- abort?.throwIfAborted();
76
- const onAbort = () => {
77
- window.clearTimeout(timer);
78
- reject(abort?.reason);
79
- };
80
- const timer = window.setTimeout(() => {
81
- abort?.removeEventListener("abort", onAbort);
82
- resolve();
83
- }, time);
84
- abort?.addEventListener("abort", onAbort, { once: true });
85
- });
86
- }
87
- function timeout(promise, timeout, abort) {
88
- return new Promise((resolve, reject) => {
89
- if (timeout <= 0)
90
- throw new Error("Invalid timeout value.");
91
- abort?.throwIfAborted();
92
- const onAbort = () => {
93
- window.clearTimeout(timer);
94
- reject(abort?.reason);
95
- };
96
- const timer = window.setTimeout(() => {
97
- abort?.removeEventListener("abort", onAbort);
98
- reject(TIMEOUT_REASON);
99
- }, timeout);
100
- abort?.addEventListener("abort", onAbort, { once: true });
101
- promise
102
- .then(result => resolve(result))
103
- .catch(reason => reject(reason))
104
- .finally(() => {
105
- window.clearTimeout(timer);
106
- abort?.removeEventListener("abort", onAbort);
107
- });
108
- });
109
- }
110
- const TIMEOUT_REASON = "Timeout";
111
-
112
- var func = /*#__PURE__*/Object.freeze({
113
- __proto__: null,
114
- TIMEOUT_REASON: TIMEOUT_REASON,
115
- delay: delay,
116
- minWait: minWait,
117
- minWaitAsync: minWaitAsync,
118
- timeout: timeout
119
- });
120
-
121
- function getWordEnd(count, word, one, two, five) {
122
- const tt = count % 100;
123
- if (tt >= 5 && tt <= 20)
124
- return word + (five || "");
125
- const t = count % 10;
126
- return (t === 1 ?
127
- (word + (one || "")) : ((t >= 2 && t <= 4) ? (word + (two || "")) : (word + (five || ""))));
128
- }
129
-
130
- var word = /*#__PURE__*/Object.freeze({
131
- __proto__: null,
132
- getWordEnd: getWordEnd
133
- });
134
-
135
- const createGuid = () => {
136
- var result;
137
- var i;
138
- var j;
139
- result = "";
140
- for (j = 0; j < 32; j++) {
141
- if (j == 8 || j == 12 || j == 16 || j == 20)
142
- result = result + '-';
143
- i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
144
- result = result + i;
145
- }
146
- return result;
147
- };
148
- const empty = "00000000-0000-0000-0000-000000000000";
149
-
150
- var guid = /*#__PURE__*/Object.freeze({
151
- __proto__: null,
152
- createGuid: createGuid,
153
- empty: empty
154
- });
155
-
156
- function formatText(template, ...args) {
157
- if (!args.length)
158
- return template;
159
- const obj = typeof args[0] === "object" ? args[0] : null;
160
- return template.replace(/\{([^}]+)\}/g, (_match, key) => {
161
- if (obj)
162
- return getProperty(obj, key) ?? "";
163
- else {
164
- const paramIndex = parseInt(key);
165
- if (!isNaN(paramIndex) && paramIndex < args.length)
166
- return args[paramIndex] ?? "";
167
- }
168
- return "";
169
- });
170
- }
171
-
172
- Object.prop = function (obj, path) {
173
- return getProperty(obj, path);
174
- };
175
- Object.hasProp = function (obj, path) {
176
- return hasProperty(obj, path);
177
- };
178
- String.prototype.format = function (...args) {
179
- return formatText(this.toString(), ...args);
180
- };
181
-
182
- export { func as FuncHelper, guid as Guid, object as ObjectHelper, type as TypeHelper, word as WordHelper, formatText };
1
+ import * as object from './helpers/object.js';
2
+ export { object as ObjectHelper };
3
+ import * as type from './helpers/type.js';
4
+ export { type as TypeHelper };
5
+ import * as func from './helpers/func.js';
6
+ export { func as FuncHelper };
7
+ import * as word from './helpers/word.js';
8
+ export { word as WordHelper };
9
+ import * as guid from './helpers/guid.js';
10
+ export { guid as Guid };
11
+ export { formatText } from './helpers/string.js';
183
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../source/helpers/object.ts","../../source/helpers/type.ts","../../source/helpers/func.ts","../../source/helpers/word.ts","../../source/helpers/guid.ts","../../source/helpers/string.ts","../../source/helpers/ext.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":[],"mappings":"AAAA,SAAS,WAAW,CAAC,GAAQ,EAAE,IAAY,EAAA;AAC1C,IAAA,IAAI,CAAC,GAAG;AACP,QAAA,OAAO,IAAI;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AAE7B,IAAA,KAAK,IAAI,CA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AI,CAAC,IAAI,CAAC,MAAM;AAAE,QAAA,OAAO,QAAQ;IAEjC,MAAM,GAAG,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;IAExD,OAAO,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,MAAM,EAAE,GAAG,KAAI;AACvD,QAAA,IAAI,GAAG;YAAE,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE;aACtC;AACJ,YAAA,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC;YAChC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM;AACjD,gBAAA,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;QAC/B;AAEA,QAAA,OAAO,EAAE;AACV,IAAA,CAAC,CAAC;AACH;;ACHA,MAAM,CAAC,IAAI,GAAG,UAAU,GAAQ,EAAE,IAAY,EAAA;AAC7C,IAAA,OAAO,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,UAAU,GAAQ,EAAE,IAAY,EAAA;AAChD,IAAA,OAAO,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC;AAC9B,CAAC;AAED,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,GAAG,IAAW,EAAA;IACjD,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,IAAI,CAAC;AAC5C,CAAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Reads a nested property value from an object by a dot-separated path.
3
+ *
4
+ * @param obj Source object to read from.
5
+ * @param path Dot-separated property path, e.g. `"header.value"`.
6
+ * @returns The resolved value; `null` when `obj` is falsy, or `undefined` when
7
+ * any segment of the path does not exist.
8
+ * @example
9
+ * getProperty({ header: { value: "Item" } }, "header.value"); // "Item"
10
+ */
1
11
  declare function getProperty(obj: any, path: string): any;
12
+ /**
13
+ * Determines whether an object has a nested property at the given dot-separated path.
14
+ *
15
+ * @param obj Source object to inspect.
16
+ * @param path Dot-separated property path, e.g. `"header.value"`.
17
+ * @returns `true` if every segment of the path exists, otherwise `false`.
18
+ * @example
19
+ * hasProperty({ header: { value: "Item" } }, "header.value"); // true
20
+ */
2
21
  declare function hasProperty(obj: any, path: string): boolean;
3
22
 
4
23
  declare const object_getProperty: typeof getProperty;
@@ -10,7 +29,21 @@ declare namespace object {
10
29
  };
11
30
  }
12
31
 
32
+ /**
33
+ * Determines whether the given value is a function.
34
+ *
35
+ * @param value Value to test.
36
+ * @returns `true` if the value is a function, otherwise `false`.
37
+ */
13
38
  declare function isFunction(value: any): boolean;
39
+ /**
40
+ * Determines whether the given value is a string.
41
+ *
42
+ * Returns `true` for both string primitives and `String` object instances.
43
+ *
44
+ * @param value Value to test.
45
+ * @returns `true` if the value is a string, otherwise `false`.
46
+ */
14
47
  declare function isString(value: any): value is string | String;
15
48
 
16
49
  declare const type_isFunction: typeof isFunction;
@@ -22,20 +55,72 @@ declare namespace type {
22
55
  };
23
56
  }
24
57
 
58
+ /**
59
+ * Wraps a callback so that, when invoked, it runs no sooner than `minTime` milliseconds
60
+ * after this wrapper was created.
61
+ *
62
+ * The deadline is measured from the moment `minWait` is called. If `minTime` is omitted
63
+ * or falsy, the original function is returned unchanged.
64
+ *
65
+ * @param func Callback to defer.
66
+ * @param minTime Minimum delay in milliseconds before the callback may run.
67
+ * @returns A wrapped function with the same arguments as `func`.
68
+ */
25
69
  declare const minWait: (func: (...args: any[]) => void, minTime?: number) => (...args: any[]) => void;
70
+ /**
71
+ * Awaits an async operation and guarantees the returned promise settles no sooner than
72
+ * `minTime` milliseconds after invocation, padding with an extra delay when needed.
73
+ *
74
+ * Useful for keeping spinners/loading states visible for a minimum duration. If `minTime`
75
+ * is omitted or falsy, `func` is awaited and its result returned without padding.
76
+ *
77
+ * @typeParam TResult Result type produced by `func`.
78
+ * @param func Factory returning the promise to await.
79
+ * @param minTime Minimum total duration in milliseconds.
80
+ * @param abort Optional signal used to cancel the padding delay.
81
+ * @returns The result produced by `func`.
82
+ */
26
83
  declare function minWaitAsync<TResult = unknown>(func: () => Promise<TResult>, minTime?: number, abort?: AbortSignal): Promise<TResult>;
84
+ /**
85
+ * Returns a promise that resolves after the given number of milliseconds.
86
+ *
87
+ * If an already-aborted signal is supplied the promise rejects immediately; otherwise
88
+ * aborting before the delay elapses clears the timer and rejects with the abort reason.
89
+ *
90
+ * @param time Delay in milliseconds.
91
+ * @param abort Optional signal used to cancel the delay.
92
+ * @returns A promise that resolves when the delay elapses.
93
+ */
27
94
  declare function delay(time: number, abort?: AbortSignal): Promise<void>;
95
+ /**
96
+ * Races a promise against a timeout.
97
+ *
98
+ * Resolves/rejects with the original promise if it settles in time. If the timeout elapses
99
+ * first the returned promise rejects with a {@link TimeoutError}. Aborting via `abort`
100
+ * rejects with the signal's reason.
101
+ *
102
+ * @typeParam T Resolved value type of the wrapped promise.
103
+ * @param promise Promise to guard with a timeout.
104
+ * @param timeout Timeout in milliseconds; must be greater than `0`.
105
+ * @param abort Optional signal used to cancel the wait.
106
+ * @returns A promise mirroring `promise` unless the timeout or abort fires first.
107
+ * @throws {Error} When `timeout` is not greater than `0`.
108
+ */
28
109
  declare function timeout<T = unknown>(promise: Promise<T>, timeout: number, abort?: AbortSignal): Promise<T>;
29
- declare const TIMEOUT_REASON = "Timeout";
110
+ /** Thrown by {@link timeout} when the time limit is exceeded. */
111
+ declare class TimeoutError extends Error {
112
+ constructor();
113
+ }
30
114
 
31
- declare const func_TIMEOUT_REASON: typeof TIMEOUT_REASON;
115
+ type func_TimeoutError = TimeoutError;
116
+ declare const func_TimeoutError: typeof TimeoutError;
32
117
  declare const func_delay: typeof delay;
33
118
  declare const func_minWait: typeof minWait;
34
119
  declare const func_minWaitAsync: typeof minWaitAsync;
35
120
  declare const func_timeout: typeof timeout;
36
121
  declare namespace func {
37
122
  export {
38
- func_TIMEOUT_REASON as TIMEOUT_REASON,
123
+ func_TimeoutError as TimeoutError,
39
124
  func_delay as delay,
40
125
  func_minWait as minWait,
41
126
  func_minWaitAsync as minWaitAsync,
@@ -43,6 +128,23 @@ declare namespace func {
43
128
  };
44
129
  }
45
130
 
131
+ /**
132
+ * Returns a word combined with the grammatical ending that agrees with the given count.
133
+ *
134
+ * Implements Russian-style pluralization rules: the ending is chosen depending on
135
+ * whether the count ends in 1, in 2–4, or in 0/5–9 (with 11–14 treated as the "five" form).
136
+ *
137
+ * @param count Quantity that the word refers to.
138
+ * @param word Word stem to which the ending is appended.
139
+ * @param one Ending used for counts ending in 1 (but not 11).
140
+ * @param two Ending used for counts ending in 2–4 (but not 12–14).
141
+ * @param five Ending used for counts ending in 0, 5–9 and 11–20.
142
+ * @returns The word with the appropriate ending appended.
143
+ * @example
144
+ * getWordEnd(1, "товар", "", "а", "ов"); // "товар"
145
+ * getWordEnd(3, "товар", "", "а", "ов"); // "товара"
146
+ * getWordEnd(5, "товар", "", "а", "ов"); // "товаров"
147
+ */
46
148
  declare function getWordEnd(count: number, word: string, one?: string, two?: string, five?: string): string;
47
149
 
48
150
  declare const word_getWordEnd: typeof getWordEnd;
@@ -52,7 +154,15 @@ declare namespace word {
52
154
  };
53
155
  }
54
156
 
157
+ /**
158
+ * Generates a RFC 4122 UUID v4 string using `crypto.randomUUID()`.
159
+ *
160
+ * @returns A newly generated UUID string in `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` form.
161
+ * @example
162
+ * createGuid(); // e.g. "3f2a1b4c-9d8e-4a23-b123-456789abcdef"
163
+ */
55
164
  declare const createGuid: () => string;
165
+ /** The empty (all-zero) GUID value `"00000000-0000-0000-0000-000000000000"`. */
56
166
  declare const empty = "00000000-0000-0000-0000-000000000000";
57
167
 
58
168
  declare const guid_createGuid: typeof createGuid;
@@ -64,16 +174,21 @@ declare namespace guid {
64
174
  };
65
175
  }
66
176
 
67
- declare global {
68
- interface String {
69
- format(...args: any[]): string;
70
- }
71
- interface ObjectConstructor {
72
- prop(obj: any, path: string): any;
73
- hasProp(obj: any, path: string): boolean;
74
- }
75
- }
76
-
77
- declare function formatText(template: string, ...args: any[]): any;
177
+ /**
178
+ * Formats a template string by substituting `{...}` placeholders.
179
+ *
180
+ * When the first argument is an object, placeholders are treated as dot-separated
181
+ * property paths resolved against that object (see {@link getProperty}). Otherwise
182
+ * placeholders are treated as zero-based indexes into the remaining arguments.
183
+ * Unresolved placeholders are replaced with an empty string.
184
+ *
185
+ * @param template Template containing `{name}` or `{0}` placeholders.
186
+ * @param args Either a single model object, or positional arguments.
187
+ * @returns The formatted string.
188
+ * @example
189
+ * formatText("Hello, {name}", { name: "Dmitry" }); // "Hello, Dmitry"
190
+ * formatText("Hello, {0}", "Dmitry"); // "Hello, Dmitry"
191
+ */
192
+ declare function formatText(template: string, ...args: any[]): string;
78
193
 
79
194
  export { func as FuncHelper, guid as Guid, object as ObjectHelper, type as TypeHelper, word as WordHelper, formatText };
package/package.json CHANGED
@@ -22,10 +22,18 @@
22
22
  "email": "it@brandup.online"
23
23
  },
24
24
  "license": "Apache-2.0",
25
- "version": "1.0.44",
25
+ "version": "2.0.2",
26
26
  "main": "dist/cjs/index.js",
27
27
  "module": "dist/mjs/index.js",
28
28
  "types": "dist/types.d.ts",
29
+ "sideEffects": false,
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/types.d.ts",
33
+ "import": "./dist/mjs/index.js",
34
+ "require": "./dist/cjs/index.js"
35
+ }
36
+ },
29
37
  "files": [
30
38
  "dist",
31
39
  "tsconfig.json",
package/tsconfig.json CHANGED
@@ -24,7 +24,9 @@
24
24
  "esModuleInterop": true,
25
25
  "forceConsistentCasingInFileNames": true,
26
26
  "skipLibCheck": true,
27
- "allowSyntheticDefaultImports": true
27
+ "allowSyntheticDefaultImports": true,
28
+ "typeRoots": ["../../node_modules/@types", "./node_modules/@types"],
29
+ "types": ["jest"]
28
30
  },
29
31
  "include": [
30
32
  "source",