@dxtmisha/functional-basic 1.6.3 → 1.7.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/CHANGELOG.md +12 -0
- package/ai-doc.md +74 -280
- package/dist/classes/ApiInstance.d.ts +3 -0
- package/dist/classes/ServerStorage.d.ts +2 -1
- package/dist/functions/getLast.d.ts +8 -0
- package/dist/library.d.ts +1 -0
- package/dist/library.js +78 -68
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.7.1] - 2026-07-14
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- **ApiInstance**: Refactored URL generation to use a protected `geo` (`GeoInstance`) field initialized via `Geo.getObject()`, calling instance-level methods instead of static `Geo` class methods.
|
|
9
|
+
- **ServerStorage**: Added an optional `storageList` parameter to `set()` and forwarded the resolved storage block from `get()` to prevent resolving the storage context multiple times.
|
|
10
|
+
|
|
11
|
+
## [1.7.0] - 2026-07-11
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
- **getLast**: Introduced a new `getLast` utility function to safely retrieve the last element from arrays or objects, with full bilingual JSDocs.
|
|
15
|
+
- **Tests**: Created a comprehensive unit test suite (`getLast.test.ts`) to validate last-element extraction across multiple data types.
|
|
16
|
+
|
|
5
17
|
## [1.6.2] - 2026-07-06
|
|
6
18
|
|
|
7
19
|
### Changed
|
package/ai-doc.md
CHANGED
|
@@ -1,347 +1,141 @@
|
|
|
1
|
-
|
|
1
|
+
# @dxtmisha/functional-basic Reference
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
If you are developing in Vue, ALWAYS look for the required functionality (composables, reactive wrappers) inside the `@dxtmisha/functional` library FIRST.
|
|
5
|
-
And ONLY if there is no reactive or Vue-specific analog there, you may use the functionality directly from this library (@dxtmisha/functional-basic).
|
|
3
|
+
Framework-agnostic utility library. **Vue developers MUST search `@dxtmisha/functional` first**; use this ONLY if no reactive/Vue-specific analog exists.
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
CLASS STRUCTURE & CODING STANDARDS (RULES FOR AI)
|
|
9
|
-
=============================================================================
|
|
10
|
-
|
|
11
|
-
To maintain consistency and high industrial quality across the dxt-ui codebase, all TypeScript classes inside `@dxtmisha/functional-basic` must strictly adhere to the following rules regarding structure, member ordering, and styles.
|
|
12
|
-
|
|
13
|
-
1. ORDER OF MEMBERS WITHIN A CLASS
|
|
14
|
-
Members in every class MUST be ordered in the following sequence:
|
|
15
|
-
|
|
16
|
-
A. Class Properties / Member Variables:
|
|
17
|
-
- Placed at the very top of the class body.
|
|
18
|
-
- Ordered by visibility: Public first, then Protected, and Private last.
|
|
19
|
-
- Within each visibility level, group by logical connection or alphabetically.
|
|
20
|
-
- Initialize default values directly on declaration when possible.
|
|
21
|
-
|
|
22
|
-
B. Constructor:
|
|
23
|
-
- Placed immediately after all property declarations.
|
|
24
|
-
- Parameter properties (e.g., `protected url: string`) are allowed to simplify declaration.
|
|
25
|
-
|
|
26
|
-
C. Public Methods:
|
|
27
|
-
- Placed after the constructor.
|
|
28
|
-
- Grouped logically:
|
|
29
|
-
1. Getters, checkers, and status-check methods (e.g., `is*`, `get*`).
|
|
30
|
-
2. Setters and configuration methods (e.g., `set*`).
|
|
31
|
-
3. Core executors and action methods (e.g., `request()`, `fetch()`, `show()`).
|
|
32
|
-
|
|
33
|
-
D. Protected Methods:
|
|
34
|
-
- Placed after all public methods.
|
|
35
|
-
- Contain internal utility and helper logic accessible to subclasses.
|
|
36
|
-
|
|
37
|
-
E. Private Methods:
|
|
38
|
-
- Placed at the very end of the class.
|
|
39
|
-
- Strict encapsulation of internal logic.
|
|
40
|
-
|
|
41
|
-
2. CODING & STYLE CONVENTIONS
|
|
42
|
-
- Naming:
|
|
43
|
-
* Classes: PascalCase (e.g., `LoadingInstance`).
|
|
44
|
-
* Methods & Properties: camelCase (e.g., `registrationEvent`, `registrationList`).
|
|
45
|
-
* Constants inside files: UPPER_SNAKE_CASE (e.g., `LOADING_EVENT_NAME`).
|
|
46
|
-
- TypeScript Safety:
|
|
47
|
-
* Never use `any`. Use generic parameters or `unknown` if the type is dynamic/undefined.
|
|
48
|
-
* Explicitly declare return types for ALL public, protected, and private methods (including `void`).
|
|
49
|
-
* Use interfaces/types to define structural contracts for complex inputs and outputs.
|
|
50
|
-
- SSR Isolation (Server-Side Rendering):
|
|
51
|
-
* The library must be fully isomorphic and safe for SSR.
|
|
52
|
-
* Avoid storing request-specific state in global/static class properties directly.
|
|
53
|
-
* Use `ServerStorage.get('key', () => new Instance())` for request-isolated singletons.
|
|
54
|
-
* Use `isDomRuntime()` checks before accessing browser-only APIs like `window`, `document`, or `location`.
|
|
5
|
+
---
|
|
55
6
|
|
|
56
|
-
|
|
57
|
-
- Location: All types, interfaces, and enums must be located in the `src/types` directory if it exists in the project. If the `src/types` directory does not exist, they must be defined in the same file where they are used.
|
|
58
|
-
- Naming: All files containing types must have the suffix `Types` in their name (e.g., `*Types.ts` or `*Types.d.ts`).
|
|
59
|
-
- Export: All types, interfaces, and enums must be explicitly exported.
|
|
60
|
-
- API Types/Schemas: All types and interfaces for working with APIs must be defined/generated using the `@effect/schema` library if it is present in the project's dependencies (if the project is a monorepo, also check root dependencies).
|
|
7
|
+
## Coding Standards & Class Structure
|
|
61
8
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
9
|
+
### 1. Class Member Order
|
|
10
|
+
1. **Properties/Variables**: Top of class, ordered by visibility (`public` -> `protected` -> `private`). Initialize inline if possible.
|
|
11
|
+
2. **Constructor**: Follows properties. Parameter properties (e.g. `protected url: string`) allowed.
|
|
12
|
+
3. **Public Methods**:
|
|
13
|
+
1. Getters, checkers, status methods (`is*`, `get*`).
|
|
14
|
+
2. Setters & configuration (`set*`).
|
|
15
|
+
3. Core executors & actions (`request()`, `fetch()`, `show()`).
|
|
16
|
+
4. **Protected Methods**: Internal helpers for subclasses.
|
|
17
|
+
5. **Private Methods**: Internal helper logic at the very bottom.
|
|
65
18
|
|
|
66
|
-
|
|
19
|
+
### 2. Style & Type Conventions
|
|
20
|
+
- **Naming**: Classes = `PascalCase`, Methods/Properties = `camelCase`, Constants = `UPPER_SNAKE_CASE`.
|
|
21
|
+
- **TypeScript**: No `any` (use `unknown`/generics). Explicit return types on ALL methods (including `void`). Export all types/interfaces. Suffix type files with `Types` (e.g., `*Types.ts`). Use `@effect/schema` for API schemas if present.
|
|
22
|
+
- **SSR Safety**: Isomorphic code. Do not store request-specific state in static/global variables. Use `isDomRuntime()` before accessing `window`/`document`/`location`. Use `ServerStorage.get(key, () => new Instance())` for request-isolated singletons.
|
|
67
23
|
|
|
68
24
|
---
|
|
69
25
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
The library provides both a static global class `Api` and an instantiable `ApiInstance` wrapper around the native `fetch` API. They support cancellation, caching, interceptors, error handling, and loading states.
|
|
26
|
+
## API Reference & Examples
|
|
73
27
|
|
|
74
|
-
|
|
28
|
+
### 1. HTTP Client (`Api`, `ApiInstance`, `ApiCache`)
|
|
75
29
|
```typescript
|
|
76
|
-
import { Api } from '@dxtmisha/functional-basic';
|
|
30
|
+
import { Api, ApiCache } from '@dxtmisha/functional-basic';
|
|
77
31
|
|
|
78
|
-
//
|
|
32
|
+
// Config
|
|
79
33
|
Api.setOrigin('https://api.example.com');
|
|
80
34
|
Api.setUrl('/api/v1');
|
|
81
|
-
|
|
82
|
-
// Setup global request defaults (e.g., query params sent with every request)
|
|
83
35
|
Api.setRequestDefault({ client: 'web' });
|
|
36
|
+
Api.setHeaders(() => ({ Authorization: `Bearer ${localStorage.getItem('token') || ''}` }));
|
|
84
37
|
|
|
85
|
-
//
|
|
86
|
-
Api.
|
|
87
|
-
|
|
88
|
-
}));
|
|
89
|
-
```
|
|
38
|
+
// Interceptors
|
|
39
|
+
Api.setPreparation(async (fetchOpts) => { if (fetchOpts.auth) fetchOpts.headers['X-Auth'] = '1'; });
|
|
40
|
+
Api.setEnd(async (res, fetchOpts) => res.status === 401 ? { reset: true } : {});
|
|
90
41
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// Simple request: defaults to GET
|
|
94
|
-
const users = await Api.request<User[]>('users');
|
|
95
|
-
|
|
96
|
-
// Explicit methods
|
|
42
|
+
// Requests
|
|
43
|
+
const users = await Api.request<User[]>('users'); // default GET
|
|
97
44
|
const profile = await Api.get<User>({ path: 'profile' });
|
|
98
|
-
const updated = await Api.post<User>({
|
|
99
|
-
path: 'profile',
|
|
100
|
-
request: { name: 'New Name' }, // Request payload
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### Interceptors (Preparation and End Lifecycle Hooks)
|
|
105
|
-
```typescript
|
|
106
|
-
// Preparation hook: runs before fetch executes
|
|
107
|
-
Api.setPreparation(async (apiFetch) => {
|
|
108
|
-
// Can mutate apiFetch settings or inject headers
|
|
109
|
-
if (apiFetch.auth) {
|
|
110
|
-
apiFetch.headers = { ...apiFetch.headers, 'X-Auth-Required': 'true' };
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
// End hook: runs after response is received
|
|
115
|
-
Api.setEnd(async (response, apiFetch) => {
|
|
116
|
-
if (response.status === 401) {
|
|
117
|
-
// Perform token refresh or trigger sign-out
|
|
118
|
-
return { reset: true }; // Resets request/attempts or signals failure
|
|
119
|
-
}
|
|
120
|
-
return {};
|
|
121
|
-
});
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
#### Local caching with `ApiCache`
|
|
125
|
-
```typescript
|
|
126
|
-
import { ApiCache } from '@dxtmisha/functional-basic';
|
|
45
|
+
const updated = await Api.post<User>({ path: 'profile', request: { name: 'New' } });
|
|
127
46
|
|
|
128
|
-
// Cache
|
|
129
|
-
await ApiCache.set('
|
|
130
|
-
const cached = await ApiCache.get<
|
|
47
|
+
// Cache
|
|
48
|
+
await ApiCache.set('key', { data: 1 }, 60000); // ms age
|
|
49
|
+
const cached = await ApiCache.get<{ data: number }>('key');
|
|
131
50
|
```
|
|
132
51
|
|
|
133
|
-
---
|
|
134
|
-
|
|
135
52
|
### 2. State & Storage Management
|
|
136
|
-
|
|
137
|
-
The library features SSR-safe classes to manipulate `localStorage`/`sessionStorage`, cookies, and server-side contexts.
|
|
138
|
-
|
|
139
|
-
#### `DataStorage` (localStorage / sessionStorage)
|
|
140
|
-
Safely wraps storage with optional namespace prefixes, fallback defaults, and expiration cache.
|
|
141
53
|
```typescript
|
|
142
|
-
import { DataStorage } from '@dxtmisha/functional-basic';
|
|
54
|
+
import { DataStorage, CookieStorage, Cookie, ServerStorage } from '@dxtmisha/functional-basic';
|
|
143
55
|
|
|
144
|
-
//
|
|
56
|
+
// DataStorage (localStorage/sessionStorage)
|
|
145
57
|
DataStorage.setPrefix('my_app_');
|
|
146
|
-
|
|
147
|
-
// Instantiate a persistent storage item (sessionStorage if 2nd arg is true)
|
|
148
|
-
const userStorage = new DataStorage<{ id: string }>('user_session', false);
|
|
149
|
-
|
|
150
|
-
// Save value
|
|
58
|
+
const userStorage = new DataStorage<{ id: string }>('user_session', false); // true for sessionStorage
|
|
151
59
|
userStorage.set({ id: '123' });
|
|
152
|
-
|
|
153
|
-
// Get value (with default value fallback and optional cache limit in ms)
|
|
154
|
-
const user = userStorage.get({ id: 'guest' });
|
|
155
|
-
|
|
156
|
-
// Remove item
|
|
60
|
+
const user = userStorage.get({ id: 'guest' }); // fallback default
|
|
157
61
|
userStorage.remove();
|
|
158
|
-
```
|
|
159
62
|
|
|
160
|
-
|
|
161
|
-
Standard cookie manager.
|
|
162
|
-
```typescript
|
|
163
|
-
import { CookieStorage, Cookie } from '@dxtmisha/functional-basic';
|
|
164
|
-
|
|
165
|
-
// Global Cookie usage
|
|
63
|
+
// Cookies
|
|
166
64
|
CookieStorage.set('theme', 'dark', { age: 31536000, secure: true, sameSite: 'lax' });
|
|
167
65
|
const theme = CookieStorage.get<string>('theme', 'light');
|
|
168
66
|
CookieStorage.remove('theme');
|
|
169
67
|
|
|
170
|
-
// Instance-based Cookie manager
|
|
171
68
|
const tokenCookie = new Cookie<string>('auth_token');
|
|
172
69
|
tokenCookie.set('xyz123', { secure: true });
|
|
173
70
|
const token = tokenCookie.get();
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
#### `ServerStorage` (SSR Request-Isolated Storage)
|
|
177
|
-
Used to share and isolate singleton states safely across concurrent asynchronous server-side render requests.
|
|
178
|
-
```typescript
|
|
179
|
-
import { ServerStorage } from '@dxtmisha/functional-basic';
|
|
180
71
|
|
|
181
|
-
//
|
|
182
|
-
const
|
|
72
|
+
// SSR Request-Isolated Storage
|
|
73
|
+
const myService = ServerStorage.get('myService', () => new MyService());
|
|
183
74
|
```
|
|
184
75
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
### 3. Geolocation & Localization (`GeoIntl`, `Geo`, `GeoFlag`, `GeoPhone`)
|
|
188
|
-
|
|
189
|
-
Standardizes localization using the native browser/Node `Intl` API.
|
|
190
|
-
|
|
191
|
-
#### `Geo`
|
|
192
|
-
Used to track and modify country, language, standard, and timezone information.
|
|
76
|
+
### 3. Geolocation & Localization
|
|
193
77
|
```typescript
|
|
194
|
-
import { Geo } from '@dxtmisha/functional-basic';
|
|
195
|
-
|
|
196
|
-
// Get current geo details
|
|
197
|
-
const currentCountry = Geo.getCountry(); // e.g., 'VN'
|
|
198
|
-
const currentLang = Geo.getLanguage(); // e.g., 'vi'
|
|
78
|
+
import { Geo, GeoIntl, GeoFlag, GeoPhone } from '@dxtmisha/functional-basic';
|
|
199
79
|
|
|
200
|
-
//
|
|
80
|
+
// Geo state
|
|
81
|
+
const country = Geo.getCountry(); // e.g., 'VN'
|
|
82
|
+
const lang = Geo.getLanguage(); // e.g., 'vi'
|
|
201
83
|
Geo.set('en-US');
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
#### `GeoIntl`
|
|
205
|
-
Used for localized numbers, currencies, percentages, dates, relative times, and file sizes.
|
|
206
|
-
```typescript
|
|
207
|
-
import { GeoIntl } from '@dxtmisha/functional-basic';
|
|
208
84
|
|
|
85
|
+
// Formatters (Intl)
|
|
209
86
|
const intl = new GeoIntl('en-US');
|
|
210
|
-
|
|
211
|
-
//
|
|
212
|
-
intl.
|
|
213
|
-
|
|
214
|
-
//
|
|
215
|
-
intl.currency(99.99, 'USD'); // '$99.99'
|
|
216
|
-
|
|
217
|
-
// File Sizes
|
|
218
|
-
intl.sizeFile(1024 * 1024 * 5); // '5.00 MB'
|
|
219
|
-
|
|
220
|
-
// Dates & Time
|
|
221
|
-
intl.date(new Date(), 'date'); // 'Jun 18, 2026'
|
|
222
|
-
intl.date(new Date(), 'time'); // '10:48 PM'
|
|
223
|
-
|
|
224
|
-
// Relative time formatting
|
|
87
|
+
intl.number(123456.78); // '123,456.78'
|
|
88
|
+
intl.currency(99.99, 'USD'); // '$99.99'
|
|
89
|
+
intl.sizeFile(1024 * 1024 * 5); // '5.00 MB'
|
|
90
|
+
intl.date(new Date(), 'date'); // 'Jun 18, 2026'
|
|
91
|
+
intl.date(new Date(), 'time'); // '10:48 PM'
|
|
225
92
|
intl.relative(new Date(Date.now() - 3600000)); // '1 hour ago'
|
|
93
|
+
intl.plural(3, 'apple|apples'); // '3 apples' ('one|other' or 'one|few|many|other')
|
|
226
94
|
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
#### Country Flags (`GeoFlag`) and Phone Masks (`GeoPhone`)
|
|
233
|
-
```typescript
|
|
234
|
-
import { GeoFlag, GeoPhone } from '@dxtmisha/functional-basic';
|
|
235
|
-
|
|
236
|
-
// Flags
|
|
237
|
-
const flagHelper = new GeoFlag();
|
|
238
|
-
const flagIcon = flagHelper.getFlag('VN'); // Vietnam flag emoji/svg code
|
|
239
|
-
|
|
240
|
-
// Phones
|
|
241
|
-
const phoneInfo = GeoPhone.getByPhone('+84900000000');
|
|
242
|
-
console.log(phoneInfo.phone); // Cleaned phone string
|
|
243
|
-
const mask = GeoPhone.toMask('84900000000'); // Returns formatted phone mask
|
|
95
|
+
// Flags & Phones
|
|
96
|
+
const flag = new GeoFlag().getFlag('VN');
|
|
97
|
+
const phoneInfo = GeoPhone.getByPhone('+84900000000'); // .phone = cleaned string
|
|
98
|
+
const mask = GeoPhone.toMask('84900000000');
|
|
244
99
|
```
|
|
245
100
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
### 4. DOM and Safe Event Management (`EventItem`)
|
|
249
|
-
|
|
250
|
-
`EventItem` provides memory-leak proof DOM event management by automating listener binding and unbinding.
|
|
251
|
-
|
|
101
|
+
### 4. DOM, Safe Events & Helpers
|
|
252
102
|
```typescript
|
|
253
|
-
import { EventItem } from '@dxtmisha/functional-basic';
|
|
254
|
-
|
|
255
|
-
// Initialize the event listener (attached to element selector or Window)
|
|
256
|
-
const clickListener = new EventItem(
|
|
257
|
-
window,
|
|
258
|
-
'click',
|
|
259
|
-
(event) => {
|
|
260
|
-
console.log('Window clicked', event);
|
|
261
|
-
},
|
|
262
|
-
{ passive: true }
|
|
263
|
-
);
|
|
103
|
+
import { EventItem, goScrollSmooth, writeClipboardData, getClipboardData } from '@dxtmisha/functional-basic';
|
|
264
104
|
|
|
265
|
-
//
|
|
105
|
+
// Leak-proof Event management
|
|
106
|
+
const clickListener = new EventItem(window, 'click', (e) => console.log(e), { passive: true });
|
|
266
107
|
clickListener.start();
|
|
108
|
+
clickListener.stop(); // Call on destroy/cleanup!
|
|
267
109
|
|
|
268
|
-
//
|
|
269
|
-
clickListener.stop();
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
#### Scrolling & Clipboard Helpers
|
|
273
|
-
```typescript
|
|
274
|
-
import { goScrollSmooth, writeClipboardData, getClipboardData } from '@dxtmisha/functional-basic';
|
|
275
|
-
|
|
276
|
-
// Scroll element into view smoothly
|
|
110
|
+
// DOM / Clipboard
|
|
277
111
|
goScrollSmooth(document.getElementById('target'));
|
|
278
|
-
|
|
279
|
-
// Copy text to clipboard
|
|
280
|
-
await writeClipboardData('Text to copy');
|
|
281
|
-
|
|
282
|
-
// Read from clipboard
|
|
112
|
+
await writeClipboardData('text');
|
|
283
113
|
const text = await getClipboardData();
|
|
284
114
|
```
|
|
285
115
|
|
|
286
|
-
---
|
|
287
|
-
|
|
288
116
|
### 5. Search & Formatting Utilities
|
|
289
|
-
|
|
290
|
-
#### `SearchList`
|
|
291
|
-
A highly-optimized client-side text searching class featuring search highlights.
|
|
292
|
-
```typescript
|
|
293
|
-
import { SearchList } from '@dxtmisha/functional-basic';
|
|
294
|
-
|
|
295
|
-
const users = [
|
|
296
|
-
{ name: 'John Doe', email: 'john@example.com' },
|
|
297
|
-
{ name: 'Jane Smith', email: 'jane@example.com' },
|
|
298
|
-
];
|
|
299
|
-
|
|
300
|
-
// Instantiation: items, fields to search in, current search query, search options
|
|
301
|
-
const searcher = new SearchList(users, ['name', 'email'], 'john');
|
|
302
|
-
|
|
303
|
-
// Execute and retrieve filtered results with highlight match markup
|
|
304
|
-
const results = searcher.to();
|
|
305
|
-
// returns: Array of results with exact matching highlights in matching keys
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
#### `Formatters`
|
|
309
|
-
Automates schema-based transformations of structured lists or objects.
|
|
310
117
|
```typescript
|
|
311
|
-
import { Formatters, FormattersType } from '@dxtmisha/functional-basic';
|
|
118
|
+
import { SearchList, Formatters, FormattersType } from '@dxtmisha/functional-basic';
|
|
312
119
|
|
|
313
|
-
|
|
120
|
+
// Search List with highlights
|
|
121
|
+
const searcher = new SearchList([{ name: 'John Doe' }], ['name'], 'john');
|
|
122
|
+
const results = searcher.to(); // returns matching items with highlighted markup in matching keys
|
|
314
123
|
|
|
124
|
+
// Object Formatter
|
|
315
125
|
const formatter = new Formatters({
|
|
316
126
|
price: { type: FormattersType.currency, options: 'USD' },
|
|
317
127
|
date: { type: FormattersType.date, options: { month: 'long', year: 'numeric' } }
|
|
318
|
-
},
|
|
319
|
-
|
|
320
|
-
const formatted = formatter.to();
|
|
321
|
-
// { price: '$12,000.00', date: 'June 2026' }
|
|
128
|
+
}, { price: 12000, date: '2026-06-18' });
|
|
129
|
+
const formatted = formatter.to(); // { price: '$12,000.00', date: 'June 2026' }
|
|
322
130
|
```
|
|
323
131
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
### 6. General Utility Functions
|
|
327
|
-
|
|
328
|
-
Core lightweight utilities:
|
|
329
|
-
- `isFilled(value)`: Checks if string, array, object, boolean or number has filled content. Returns `false` for `[]`, `{}`, `''`, `null`, `undefined`.
|
|
330
|
-
- `isDomRuntime()`: Safe isomorphic environment check. Returns `true` if code is running in a browser runtime.
|
|
331
|
-
- `copyObject(value)`: Performs a quick, deep object clone.
|
|
332
|
-
- `anyToString(value)`: Converts any type to its clean string representation.
|
|
333
|
-
- `sleep(ms)`: Promisified setTimeout wrapper for async delay.
|
|
334
|
-
|
|
132
|
+
### 6. General Helpers
|
|
335
133
|
```typescript
|
|
336
|
-
import { isFilled, isDomRuntime, copyObject, sleep } from '@dxtmisha/functional-basic';
|
|
337
|
-
|
|
338
|
-
if (isDomRuntime()) {
|
|
339
|
-
console.log('Running in browser');
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if (isFilled(myArray)) {
|
|
343
|
-
const cloned = copyObject(myArray);
|
|
344
|
-
}
|
|
134
|
+
import { isFilled, isDomRuntime, copyObject, anyToString, sleep } from '@dxtmisha/functional-basic';
|
|
345
135
|
|
|
136
|
+
isFilled([]); // false (works for strings, arrays, objects, numbers, booleans)
|
|
137
|
+
isDomRuntime(); // true if in browser
|
|
138
|
+
const cloned = copyObject({ a: 1 });
|
|
139
|
+
const str = anyToString(123);
|
|
346
140
|
await sleep(500);
|
|
347
141
|
```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GeoInstance } from './GeoInstance';
|
|
1
2
|
import { LoadingInstance } from './LoadingInstance';
|
|
2
3
|
import { ErrorCenterInstance } from './ErrorCenterInstance';
|
|
3
4
|
import { ApiDefault } from './ApiDefault';
|
|
@@ -36,6 +37,8 @@ export type ApiInstanceOptions = {
|
|
|
36
37
|
*/
|
|
37
38
|
export declare class ApiInstance {
|
|
38
39
|
protected url: string;
|
|
40
|
+
/** Geo class instance / Экземпляр класса Geo */
|
|
41
|
+
protected geo: GeoInstance;
|
|
39
42
|
/** Headers / Заголовки */
|
|
40
43
|
protected headers: ApiHeaders;
|
|
41
44
|
/** Default request parameters / Параметры запроса по умолчанию */
|
|
@@ -54,9 +54,10 @@ export declare class ServerStorage {
|
|
|
54
54
|
* @param key unique storage key / уникальный ключ хранилища
|
|
55
55
|
* @param value function that returns the value to save / функция, возвращающая значение для сохранения
|
|
56
56
|
* @param hydration whether the value should be included in hydration / должно ли значение быть включено в гидратацию
|
|
57
|
+
* @param storageList optional storage list / необязательный список хранилища
|
|
57
58
|
* @returns saved value / сохраненное значение
|
|
58
59
|
*/
|
|
59
|
-
static set<T = any>(key: string, value: () => T, hydration?: boolean): T;
|
|
60
|
+
static set<T = any>(key: string, value: () => T, hydration?: boolean, storageList?: ServerStorageList): T;
|
|
60
61
|
/**
|
|
61
62
|
* Sets the visibility of error messages.
|
|
62
63
|
*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the last element of an array or object.
|
|
3
|
+
*
|
|
4
|
+
* Возвращает последний элемент массива или объекта.
|
|
5
|
+
* @param value input value / входное значение
|
|
6
|
+
* @returns last element of the array or object / последний элемент массива или объекта
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLast<T>(value: T | T[] | Record<string, T>): T | undefined;
|
package/dist/library.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ export * from './functions/getFirst';
|
|
|
97
97
|
export * from './functions/getHydrationData';
|
|
98
98
|
export * from './functions/getItemByPath';
|
|
99
99
|
export * from './functions/getKey';
|
|
100
|
+
export * from './functions/getLast';
|
|
100
101
|
export * from './functions/getLength';
|
|
101
102
|
export * from './functions/getLengthOfAllArray';
|
|
102
103
|
export * from './functions/getMaxLengthAllArray';
|
package/dist/library.js
CHANGED
|
@@ -539,14 +539,14 @@ var _e = "__ui:server-storage__", ve = "__ui:server:storage:id__", E = class {
|
|
|
539
539
|
static get(e, t, n = !1) {
|
|
540
540
|
let r = this.getStorage(void 0, `get:${e}`);
|
|
541
541
|
if (e in r) return r[e].value;
|
|
542
|
-
if (t) return this.set(e, t, n);
|
|
542
|
+
if (t) return this.set(e, t, n, r);
|
|
543
543
|
}
|
|
544
|
-
static set(e, t, n = !1) {
|
|
545
|
-
let
|
|
546
|
-
return
|
|
547
|
-
value:
|
|
544
|
+
static set(e, t, n = !1, r) {
|
|
545
|
+
let i = r || this.getStorage(void 0, `set:${e}`), a = t();
|
|
546
|
+
return i[e] = {
|
|
547
|
+
value: a,
|
|
548
548
|
hydration: n
|
|
549
|
-
},
|
|
549
|
+
}, a;
|
|
550
550
|
}
|
|
551
551
|
static setErrorStatus(e) {
|
|
552
552
|
this.hideError = e;
|
|
@@ -1613,9 +1613,9 @@ var Xe = "d-response-loading", Ze = class {
|
|
|
1613
1613
|
}
|
|
1614
1614
|
}, Qe = class {
|
|
1615
1615
|
constructor(e = "/api/", t = {}) {
|
|
1616
|
-
C(this, "url", void 0), C(this, "headers", void 0), C(this, "requestDefault", void 0), C(this, "status", void 0), C(this, "response", void 0), C(this, "preparation", void 0), C(this, "loading", void 0), C(this, "errorCenter", void 0), C(this, "hydration", void 0), C(this, "timeout", 16e3), C(this, "origin", void 0), C(this, "wrapper", void 0), this.url = e;
|
|
1616
|
+
C(this, "url", void 0), C(this, "geo", void 0), C(this, "headers", void 0), C(this, "requestDefault", void 0), C(this, "status", void 0), C(this, "response", void 0), C(this, "preparation", void 0), C(this, "loading", void 0), C(this, "errorCenter", void 0), C(this, "hydration", void 0), C(this, "timeout", 16e3), C(this, "origin", void 0), C(this, "wrapper", void 0), this.url = e;
|
|
1617
1617
|
let { headersClass: n = Ge, requestDefaultClass: r = Ve, statusClass: i = Re, responseClass: a = Ze, preparationClass: o = Je, loadingClass: s = M.getItem(), errorCenterClass: c = w.getItem(), hydrationClass: l = qe, wrapper: u } = t;
|
|
1618
|
-
this.headers = new n(), this.requestDefault = new r(), this.status = new i(), this.response = new a(this.requestDefault), this.preparation = new o(), this.loading = s, this.errorCenter = c, this.hydration = new l(), this.wrapper = u, this.hydration.initResponse(this.response);
|
|
1618
|
+
this.geo = k.getObject(), this.headers = new n(), this.requestDefault = new r(), this.status = new i(), this.response = new a(this.requestDefault), this.preparation = new o(), this.loading = s, this.errorCenter = c, this.hydration = new l(), this.wrapper = u, this.hydration.initResponse(this.response);
|
|
1619
1619
|
}
|
|
1620
1620
|
isLocalhost() {
|
|
1621
1621
|
return s() && typeof location < "u" && location.hostname === "localhost";
|
|
@@ -1633,7 +1633,7 @@ var Xe = "d-response-loading", Ze = class {
|
|
|
1633
1633
|
return this.origin && /^\//.test(this.url) ? `${this.origin}${this.url}` : this.url;
|
|
1634
1634
|
}
|
|
1635
1635
|
getUrl(e, t = !0) {
|
|
1636
|
-
return `${t ? this.getOrigin() : ""}${e}`.replace("{locale}",
|
|
1636
|
+
return `${t ? this.getOrigin() : ""}${e}`.replace("{locale}", this.geo.getLocation()).replace("{country}", this.geo.getCountry()).replace("{language}", this.geo.getLanguage());
|
|
1637
1637
|
}
|
|
1638
1638
|
getBody(e = {}, t = P.get) {
|
|
1639
1639
|
if (e instanceof FormData) return e;
|
|
@@ -4681,13 +4681,23 @@ function Pn(e) {
|
|
|
4681
4681
|
return (t = (n = e == null ? void 0 : e.key) == null ? e == null ? void 0 : e.code : n) == null ? e == null || (r = e.keyCode) == null ? void 0 : r.toString() : t;
|
|
4682
4682
|
}
|
|
4683
4683
|
//#endregion
|
|
4684
|
-
//#region src/functions/
|
|
4684
|
+
//#region src/functions/getLast.ts
|
|
4685
4685
|
function Fn(e) {
|
|
4686
|
+
if (i(e)) return e == null ? void 0 : e[e.length - 1];
|
|
4687
|
+
if (t(e)) {
|
|
4688
|
+
let t = Object.values(e);
|
|
4689
|
+
return t == null ? void 0 : t[t.length - 1];
|
|
4690
|
+
}
|
|
4691
|
+
return e;
|
|
4692
|
+
}
|
|
4693
|
+
//#endregion
|
|
4694
|
+
//#region src/functions/getLength.ts
|
|
4695
|
+
function In(e) {
|
|
4686
4696
|
return e == null ? 0 : typeof e == "string" || Array.isArray(e) ? e.length : e instanceof Map || e instanceof Set ? e.size : t(e) ? Object.keys(e).length : 0;
|
|
4687
4697
|
}
|
|
4688
4698
|
//#endregion
|
|
4689
4699
|
//#region src/functions/getLengthOfAllArray.ts
|
|
4690
|
-
function
|
|
4700
|
+
function Ln(e) {
|
|
4691
4701
|
return r(e, (e) => {
|
|
4692
4702
|
var t;
|
|
4693
4703
|
return (t = e == null ? void 0 : e.length) == null ? 0 : t;
|
|
@@ -4695,41 +4705,41 @@ function In(e) {
|
|
|
4695
4705
|
}
|
|
4696
4706
|
//#endregion
|
|
4697
4707
|
//#region src/functions/getMaxLengthAllArray.ts
|
|
4698
|
-
function
|
|
4708
|
+
function Rn(e) {
|
|
4699
4709
|
if (!l(e)) return 0;
|
|
4700
|
-
let t =
|
|
4710
|
+
let t = Ln(e);
|
|
4701
4711
|
return t.length > 1e4 ? t.reduce((e, t) => Math.max(e, t)) : Math.max(...t);
|
|
4702
4712
|
}
|
|
4703
4713
|
//#endregion
|
|
4704
4714
|
//#region src/functions/getMinLengthAllArray.ts
|
|
4705
|
-
function
|
|
4715
|
+
function zn(e) {
|
|
4706
4716
|
if (!l(e)) return 0;
|
|
4707
|
-
let t =
|
|
4717
|
+
let t = Ln(e);
|
|
4708
4718
|
return t.length > 1e4 ? t.reduce((e, t) => Math.min(e, t)) : Math.min(...t);
|
|
4709
4719
|
}
|
|
4710
4720
|
//#endregion
|
|
4711
4721
|
//#region src/functions/getMouseClientX.ts
|
|
4712
|
-
function
|
|
4722
|
+
function Bn(e) {
|
|
4713
4723
|
var t, n;
|
|
4714
4724
|
return (e == null ? void 0 : e.clientX) || (e == null || (t = e.targetTouches) == null || (t = t[0]) == null ? void 0 : t.clientX) || (e == null || (n = e.touches) == null || (n = n[0]) == null ? void 0 : n.clientX) || 0;
|
|
4715
4725
|
}
|
|
4716
4726
|
//#endregion
|
|
4717
4727
|
//#region src/functions/getMouseClientY.ts
|
|
4718
|
-
function
|
|
4728
|
+
function Vn(e) {
|
|
4719
4729
|
var t, n;
|
|
4720
4730
|
return (e == null ? void 0 : e.clientY) || (e == null || (t = e.targetTouches) == null || (t = t[0]) == null ? void 0 : t.clientY) || (e == null || (n = e.touches) == null || (n = n[0]) == null ? void 0 : n.clientY) || 0;
|
|
4721
4731
|
}
|
|
4722
4732
|
//#endregion
|
|
4723
4733
|
//#region src/functions/getMouseClient.ts
|
|
4724
|
-
function
|
|
4734
|
+
function Hn(e) {
|
|
4725
4735
|
return {
|
|
4726
|
-
x:
|
|
4727
|
-
y:
|
|
4736
|
+
x: Bn(e),
|
|
4737
|
+
y: Vn(e)
|
|
4728
4738
|
};
|
|
4729
4739
|
}
|
|
4730
4740
|
//#endregion
|
|
4731
4741
|
//#region src/functions/getObjectByKeys.ts
|
|
4732
|
-
function
|
|
4742
|
+
function Un(e, t) {
|
|
4733
4743
|
let r = {};
|
|
4734
4744
|
return n(e) && t.forEach((t) => {
|
|
4735
4745
|
t in e && e[t] !== void 0 && (r[t] = e[t]);
|
|
@@ -4737,7 +4747,7 @@ function Hn(e, t) {
|
|
|
4737
4747
|
}
|
|
4738
4748
|
//#endregion
|
|
4739
4749
|
//#region src/functions/getObjectNoUndefined.ts
|
|
4740
|
-
function
|
|
4750
|
+
function Wn(e, t = void 0) {
|
|
4741
4751
|
let n = {};
|
|
4742
4752
|
return r(e, (e, r) => {
|
|
4743
4753
|
e !== t && (n[r] = e);
|
|
@@ -4745,42 +4755,42 @@ function Un(e, t = void 0) {
|
|
|
4745
4755
|
}
|
|
4746
4756
|
//#endregion
|
|
4747
4757
|
//#region src/functions/getObjectOrNone.ts
|
|
4748
|
-
function
|
|
4758
|
+
function Gn(e) {
|
|
4749
4759
|
return n(e) ? e : {};
|
|
4750
4760
|
}
|
|
4751
4761
|
//#endregion
|
|
4752
4762
|
//#region src/functions/getOnlyText.ts
|
|
4753
|
-
function
|
|
4763
|
+
function Kn(e) {
|
|
4754
4764
|
return x(e).replace(/[^\p{L}\p{N}\s]+/gu, "").trim();
|
|
4755
4765
|
}
|
|
4756
4766
|
//#endregion
|
|
4757
4767
|
//#region src/functions/strFill.ts
|
|
4758
|
-
function
|
|
4768
|
+
function qn(e, t) {
|
|
4759
4769
|
return String(e).repeat(t);
|
|
4760
4770
|
}
|
|
4761
4771
|
//#endregion
|
|
4762
4772
|
//#region src/functions/getRandomText.ts
|
|
4763
|
-
function
|
|
4773
|
+
function Jn(e, t, n = "#", r = 2, i = 12) {
|
|
4764
4774
|
let a = f(e, t), o = [];
|
|
4765
|
-
for (let e = 0; e < a; e++) o.push(
|
|
4775
|
+
for (let e = 0; e < a; e++) o.push(qn(n, f(r, i)));
|
|
4766
4776
|
return o.join(" ");
|
|
4767
4777
|
}
|
|
4768
4778
|
//#endregion
|
|
4769
4779
|
//#region src/functions/getStepPercent.ts
|
|
4770
|
-
function
|
|
4780
|
+
function Yn(e, t) {
|
|
4771
4781
|
let n = e == null ? 0 : e;
|
|
4772
4782
|
return t > n ? 100 / (t - n) : 0;
|
|
4773
4783
|
}
|
|
4774
4784
|
//#endregion
|
|
4775
4785
|
//#region src/functions/getStepValue.ts
|
|
4776
|
-
function
|
|
4786
|
+
function Xn(e, t) {
|
|
4777
4787
|
let n = e == null ? 0 : e;
|
|
4778
4788
|
return t > n ? (t - n) / 100 : 0;
|
|
4779
4789
|
}
|
|
4780
4790
|
//#endregion
|
|
4781
4791
|
//#region src/functions/goScroll.ts
|
|
4782
|
-
var
|
|
4783
|
-
function
|
|
4792
|
+
var Zn = 0;
|
|
4793
|
+
function Qn(e, t, n) {
|
|
4784
4794
|
if (!s()) return;
|
|
4785
4795
|
let r = t == null ? void 0 : t.closest(e);
|
|
4786
4796
|
if (t && r && r.scrollHeight !== r.offsetHeight) {
|
|
@@ -4788,12 +4798,12 @@ function Zn(e, t, n) {
|
|
|
4788
4798
|
if (n) {
|
|
4789
4799
|
let a = n.getBoundingClientRect();
|
|
4790
4800
|
r.scrollTop = t.offsetTop - (a.top - e.top) - (a.height / 2 - i.height / 2), r.scrollTop + r.offsetHeight < t.offsetTop + t.offsetHeight && (r.scrollTop = t.offsetTop + t.offsetHeight - r.offsetHeight);
|
|
4791
|
-
} else r.scrollTop > t.offsetTop ? r.scrollTop = i.top - e.top -
|
|
4801
|
+
} else r.scrollTop > t.offsetTop ? r.scrollTop = i.top - e.top - Zn : r.scrollTop + r.offsetHeight < t.offsetTop + t.offsetHeight && (r.scrollTop = i.top - e.top + i.height - e.height + Zn);
|
|
4792
4802
|
}
|
|
4793
4803
|
}
|
|
4794
4804
|
//#endregion
|
|
4795
4805
|
//#region src/functions/goScrollSmooth.ts
|
|
4796
|
-
function
|
|
4806
|
+
function $n(e, t, n = 0) {
|
|
4797
4807
|
if (!s()) return;
|
|
4798
4808
|
let r = (t == null ? void 0 : t.behavior) || "smooth";
|
|
4799
4809
|
if ("scrollIntoView" in e && !n) {
|
|
@@ -4815,7 +4825,7 @@ function Qn(e, t, n = 0) {
|
|
|
4815
4825
|
}
|
|
4816
4826
|
//#endregion
|
|
4817
4827
|
//#region src/functions/goScrollTo.ts
|
|
4818
|
-
function
|
|
4828
|
+
function er(e, t, n = "smooth") {
|
|
4819
4829
|
if (!s() || !e || !t) return;
|
|
4820
4830
|
let r = e.getBoundingClientRect(), i = t.getBoundingClientRect();
|
|
4821
4831
|
e.scrollBy({
|
|
@@ -4826,13 +4836,13 @@ function $n(e, t, n = "smooth") {
|
|
|
4826
4836
|
}
|
|
4827
4837
|
//#endregion
|
|
4828
4838
|
//#region src/functions/isShare.ts
|
|
4829
|
-
function
|
|
4839
|
+
function tr() {
|
|
4830
4840
|
return s() && typeof navigator < "u" && !!navigator.share;
|
|
4831
4841
|
}
|
|
4832
4842
|
//#endregion
|
|
4833
4843
|
//#region src/functions/handleShare.ts
|
|
4834
|
-
async function
|
|
4835
|
-
if (
|
|
4844
|
+
async function nr(e) {
|
|
4845
|
+
if (tr() && navigator.canShare && navigator.canShare(e)) try {
|
|
4836
4846
|
return await navigator.share(e), !0;
|
|
4837
4847
|
} catch (e) {
|
|
4838
4848
|
w.on({
|
|
@@ -4845,12 +4855,12 @@ async function tr(e) {
|
|
|
4845
4855
|
}
|
|
4846
4856
|
//#endregion
|
|
4847
4857
|
//#region src/functions/inArray.ts
|
|
4848
|
-
function
|
|
4858
|
+
function rr(e, t) {
|
|
4849
4859
|
return e.includes(t);
|
|
4850
4860
|
}
|
|
4851
4861
|
//#endregion
|
|
4852
4862
|
//#region src/functions/initScrollbarOffset.ts
|
|
4853
|
-
async function
|
|
4863
|
+
async function ir() {
|
|
4854
4864
|
if (s()) {
|
|
4855
4865
|
let e = await Lt.get();
|
|
4856
4866
|
document.body.style.setProperty("--sys-scrollbar-offset", `${e}px`);
|
|
@@ -4858,7 +4868,7 @@ async function rr() {
|
|
|
4858
4868
|
}
|
|
4859
4869
|
//#endregion
|
|
4860
4870
|
//#region src/functions/intersectKey.ts
|
|
4861
|
-
function
|
|
4871
|
+
function ar(e, n) {
|
|
4862
4872
|
let i = {};
|
|
4863
4873
|
return t(e) && t(n) && r(e, (e, t) => {
|
|
4864
4874
|
t in n && (i[t] = e);
|
|
@@ -4866,7 +4876,7 @@ function ir(e, n) {
|
|
|
4866
4876
|
}
|
|
4867
4877
|
//#endregion
|
|
4868
4878
|
//#region src/functions/isDifferent.ts
|
|
4869
|
-
function
|
|
4879
|
+
function or(e, t) {
|
|
4870
4880
|
let n = Object.keys(e).length !== Object.keys(t).length;
|
|
4871
4881
|
return n || r(e, (e, r) => {
|
|
4872
4882
|
e !== (t == null ? void 0 : t[r]) && (n = !0);
|
|
@@ -4874,7 +4884,7 @@ function ar(e, t) {
|
|
|
4874
4884
|
}
|
|
4875
4885
|
//#endregion
|
|
4876
4886
|
//#region src/functions/isElementVisible.ts
|
|
4877
|
-
function
|
|
4887
|
+
function sr(e) {
|
|
4878
4888
|
if (!s()) return !1;
|
|
4879
4889
|
let t = A(e);
|
|
4880
4890
|
if (!t || "isConnected" in t && t.isConnected === !1) return !1;
|
|
@@ -4883,16 +4893,16 @@ function or(e) {
|
|
|
4883
4893
|
}
|
|
4884
4894
|
//#endregion
|
|
4885
4895
|
//#region src/functions/isInput.ts
|
|
4886
|
-
var
|
|
4896
|
+
var cr = (e) => {
|
|
4887
4897
|
if (e instanceof HTMLElement) {
|
|
4888
4898
|
let t = e.tagName.toLowerCase();
|
|
4889
4899
|
return !!(t === "input" || t === "textarea" || t === "select" || e.isContentEditable || e.getAttribute("contenteditable") === "true") && !(e != null && e.readOnly) && !(e != null && e.disabled);
|
|
4890
4900
|
}
|
|
4891
4901
|
return !1;
|
|
4892
|
-
},
|
|
4902
|
+
}, lr = (e, t) => e.code === "Space" || e.code === "Enter" || e.key === " " || e.key === "Spacebar" || e.key === "Enter" || e.keyCode === 13 || e.keyCode === 32 ? t === void 0 ? !cr(e.target) : !t : !1;
|
|
4893
4903
|
//#endregion
|
|
4894
4904
|
//#region src/functions/isFloat.ts
|
|
4895
|
-
function
|
|
4905
|
+
function ur(e) {
|
|
4896
4906
|
switch (typeof e) {
|
|
4897
4907
|
case "number": return !0;
|
|
4898
4908
|
case "string": return /^-?\d+(\.\d+)?$/.test(e);
|
|
@@ -4901,24 +4911,24 @@ function lr(e) {
|
|
|
4901
4911
|
}
|
|
4902
4912
|
//#endregion
|
|
4903
4913
|
//#region src/functions/isIntegerBetween.ts
|
|
4904
|
-
function
|
|
4914
|
+
function dr(e, t) {
|
|
4905
4915
|
let n = Math.floor(t);
|
|
4906
4916
|
return e >= n && e < n + 1;
|
|
4907
4917
|
}
|
|
4908
4918
|
//#endregion
|
|
4909
4919
|
//#region src/functions/isMetaKey.ts
|
|
4910
|
-
var
|
|
4920
|
+
var fr = (e) => !!(e.metaKey || e.altKey || e.ctrlKey);
|
|
4911
4921
|
//#endregion
|
|
4912
4922
|
//#region src/functions/isSelectedByList.ts
|
|
4913
|
-
function
|
|
4923
|
+
function pr(e, t) {
|
|
4914
4924
|
return Array.isArray(e) ? e.every((e) => b(e, t)) : b(e, t);
|
|
4915
4925
|
}
|
|
4916
4926
|
//#endregion
|
|
4917
4927
|
//#region src/functions/isTab.ts
|
|
4918
|
-
var
|
|
4928
|
+
var mr = (e) => e.key === "Tab" || e.code === "Tab" || e.keyCode === 9;
|
|
4919
4929
|
//#endregion
|
|
4920
4930
|
//#region src/functions/removeCommonPrefix.ts
|
|
4921
|
-
function
|
|
4931
|
+
function hr(e, t) {
|
|
4922
4932
|
if (e.startsWith(t)) return e.slice(t.length).trim();
|
|
4923
4933
|
let n = 0;
|
|
4924
4934
|
for (; e[n] === t[n] && n < e.length && n < t.length;) n++;
|
|
@@ -4926,13 +4936,13 @@ function mr(e, t) {
|
|
|
4926
4936
|
}
|
|
4927
4937
|
//#endregion
|
|
4928
4938
|
//#region src/functions/replaceComponentName.ts
|
|
4929
|
-
var
|
|
4939
|
+
var gr = (e, t, n) => {
|
|
4930
4940
|
var r;
|
|
4931
4941
|
return e == null || (r = e.replace(RegExp(`<${t}`, "ig"), `<${n}`)) == null || (r = r.replace(RegExp(`</${t}`, "ig"), `</${n}`)) == null ? void 0 : r.trim();
|
|
4932
4942
|
};
|
|
4933
4943
|
//#endregion
|
|
4934
4944
|
//#region src/functions/uniqueArray.ts
|
|
4935
|
-
function
|
|
4945
|
+
function _r(e) {
|
|
4936
4946
|
return [...new Set(e)];
|
|
4937
4947
|
}
|
|
4938
4948
|
//#endregion
|
|
@@ -4941,12 +4951,12 @@ function $(e, n, i = !0) {
|
|
|
4941
4951
|
let a = Z(e);
|
|
4942
4952
|
return t(e) && t(n) && r(n, (n, r) => {
|
|
4943
4953
|
let o = e == null ? void 0 : e[r];
|
|
4944
|
-
t(o) && t(n) ? i && Array.isArray(o) && Array.isArray(n) ? a[r] = Z(
|
|
4954
|
+
t(o) && t(n) ? i && Array.isArray(o) && Array.isArray(n) ? a[r] = Z(_r([...o, ...n])) : a[r] = $(Array.isArray(o) ? { ...o } : o, n, i) : a[r] = t(n) ? Z(n) : n;
|
|
4945
4955
|
}), a;
|
|
4946
4956
|
}
|
|
4947
4957
|
//#endregion
|
|
4948
4958
|
//#region src/functions/replaceTemplate.ts
|
|
4949
|
-
function
|
|
4959
|
+
function vr(e, t) {
|
|
4950
4960
|
let n = e;
|
|
4951
4961
|
return r(t, (e, t) => {
|
|
4952
4962
|
n = n.replace(Gt(`[${t}]`), m(e));
|
|
@@ -4954,7 +4964,7 @@ function _r(e, t) {
|
|
|
4954
4964
|
}
|
|
4955
4965
|
//#endregion
|
|
4956
4966
|
//#region src/functions/secondToTime.ts
|
|
4957
|
-
function
|
|
4967
|
+
function yr(e, t) {
|
|
4958
4968
|
let n = y(e);
|
|
4959
4969
|
if (n > 0) {
|
|
4960
4970
|
let e = String(Math.floor(n / 60)).padStart(2, "0"), r = String(n % 60).padStart(2, "0");
|
|
@@ -4964,7 +4974,7 @@ function vr(e, t) {
|
|
|
4964
4974
|
}
|
|
4965
4975
|
//#endregion
|
|
4966
4976
|
//#region src/functions/setValues.ts
|
|
4967
|
-
function
|
|
4977
|
+
function br(e, t, { multiple: n = !1, maxlength: r = 0, alwaysChange: a = !0, notEmpty: o = !1 }) {
|
|
4968
4978
|
if (n) {
|
|
4969
4979
|
if (i(e)) {
|
|
4970
4980
|
let n = e.indexOf(t), i = [...e];
|
|
@@ -4976,7 +4986,7 @@ function yr(e, t, { multiple: n = !1, maxlength: r = 0, alwaysChange: a = !0, no
|
|
|
4976
4986
|
}
|
|
4977
4987
|
//#endregion
|
|
4978
4988
|
//#region src/functions/splice.ts
|
|
4979
|
-
function
|
|
4989
|
+
function xr(e, n, i) {
|
|
4980
4990
|
if (t(e) && t(n)) {
|
|
4981
4991
|
if (i) {
|
|
4982
4992
|
let a = {}, o = !1;
|
|
@@ -4990,34 +5000,34 @@ function br(e, n, i) {
|
|
|
4990
5000
|
}
|
|
4991
5001
|
//#endregion
|
|
4992
5002
|
//#region src/functions/toCamelCaseFirst.ts
|
|
4993
|
-
function
|
|
5003
|
+
function Sr(e) {
|
|
4994
5004
|
return ot(e).replace(/^([a-z])/, (e) => `${e.toUpperCase()}`);
|
|
4995
5005
|
}
|
|
4996
5006
|
//#endregion
|
|
4997
5007
|
//#region src/functions/toKebabCase.ts
|
|
4998
|
-
function
|
|
5008
|
+
function Cr(e) {
|
|
4999
5009
|
return e.toString().trim().replace(/[^\w-. ]+/g, "").replace(/[ .]+/g, "-").replace(/(?<=[A-Z])([A-Z])/g, (e) => `${e.toLowerCase()}`).replace(/^[A-Z]/, (e) => e.toLowerCase()).replace(/(?<=[\w ])[A-Z]/g, (e) => `-${e.toLowerCase()}`).replace(/[A-Z]/g, (e) => e.toLowerCase());
|
|
5000
5010
|
}
|
|
5001
5011
|
//#endregion
|
|
5002
5012
|
//#region src/functions/toNumberByMax.ts
|
|
5003
|
-
function
|
|
5013
|
+
function wr(e, t, n, r) {
|
|
5004
5014
|
let i = y(e), a = y(t);
|
|
5005
|
-
return t && a < i ? `${
|
|
5015
|
+
return t && a < i ? `${Tr(a, n, r)}+` : Tr(i, n, r);
|
|
5006
5016
|
}
|
|
5007
|
-
var
|
|
5017
|
+
var Tr = (e, t, n) => t ? new L(n).number(e) : e;
|
|
5008
5018
|
//#endregion
|
|
5009
5019
|
//#region src/functions/toPercent.ts
|
|
5010
|
-
function
|
|
5020
|
+
function Er(e, t) {
|
|
5011
5021
|
return e === 0 ? t : 1 / e * t;
|
|
5012
5022
|
}
|
|
5013
5023
|
//#endregion
|
|
5014
5024
|
//#region src/functions/toPercentBy100.ts
|
|
5015
|
-
function
|
|
5016
|
-
return
|
|
5025
|
+
function Dr(e, t) {
|
|
5026
|
+
return Er(e, t) * 100;
|
|
5017
5027
|
}
|
|
5018
5028
|
//#endregion
|
|
5019
5029
|
//#region src/functions/uint8ArrayToBase64.ts
|
|
5020
|
-
function
|
|
5030
|
+
function Or(e) {
|
|
5021
5031
|
let t = "";
|
|
5022
5032
|
for (let n of e) t += String.fromCharCode(n);
|
|
5023
5033
|
if (s()) return window.btoa(t);
|
|
@@ -5029,7 +5039,7 @@ function Dr(e) {
|
|
|
5029
5039
|
}
|
|
5030
5040
|
//#endregion
|
|
5031
5041
|
//#region src/functions/writeClipboardData.ts
|
|
5032
|
-
async function
|
|
5042
|
+
async function kr(e) {
|
|
5033
5043
|
if (s()) try {
|
|
5034
5044
|
await navigator.clipboard.writeText(e);
|
|
5035
5045
|
} catch (n) {
|
|
@@ -5038,4 +5048,4 @@ async function Or(e) {
|
|
|
5038
5048
|
}
|
|
5039
5049
|
}
|
|
5040
5050
|
//#endregion
|
|
5041
|
-
export { F as Api, N as ApiCache, Be as ApiDataReturn, Ve as ApiDefault, We as ApiError, He as ApiErrorItem, Ue as ApiErrorStorage, Ge as ApiHeaders, qe as ApiHydration, Qe as ApiInstance, P as ApiMethodItem, Je as ApiPreparation, Ze as ApiResponse, Re as ApiStatus, $e as BroadcastMessage, nt as Cache, tt as CacheItem, rt as CacheStatic, Ee as Cookie, Ce as CookieBlock, Se as CookieBlockInstance, O as CookieStorage, D as DataStorage, at as Datetime, w as ErrorCenter, ue as ErrorCenterHandler, de as ErrorCenterInstance, Ne as EventItem, st as Formatters, V as FormattersType, ct as GEO_FLAG_ICON_NAME, k as Geo, lt as GeoFlag, ke as GeoInstance, L as GeoIntl, ut as GeoPhone, ft as GeoUnit, pt as Global, gt as Hash, ht as HashInstance, yt as Icons, M as Loading, Fe as LoadingInstance, Mt as Meta, G as MetaManager, At as MetaOg, Dt as MetaOpenGraphAge, Tt as MetaOpenGraphAvailability, Et as MetaOpenGraphCondition, Ot as MetaOpenGraphGender, q as MetaOpenGraphTag, wt as MetaOpenGraphType, Ct as MetaRobots, Nt as MetaStatic, K as MetaTag, jt as MetaTwitter, kt as MetaTwitterCard, J as MetaTwitterTag, Ft as Query, Pt as QueryInstance, It as ResumableTimer, Lt as ScrollbarWidth, Xt as SearchList, Ut as SearchListData, Wt as SearchListItem, Jt as SearchListMatcher, Yt as SearchListOptions, E as ServerStorage, Qt as StorageCallback, rn as TRANSLATE_GLOBAL_PREFIX, an as TRANSLATE_TIME_OUT, cn as Translate, on as TranslateFile, sn as TranslateInstance, De as UI_GEO_COOKIE_KEY, mt as UrlInstanceAbstract, Y as UrlItem, Ht as addTagHighlightMatch, x as anyToString, tn as applyTemplate, ln as arrFill, mn as blobToBase64, hn as capitalize, Z as copyObject, gn as copyObjectLite, U as createElement, _n as domQuerySelector, vn as domQuerySelectorAll, W as encodeAttribute, me as encodeLiteAttribute, Sn as ensureMaxSize, X as escapeExp, Cn as eventStopPropagation, m as executeFunction, Ye as executePromise, r as forEach, wn as frame, Tn as getArrayHighlightMatch, En as getAttributes, Dn as getClipboardData, it as getColumn, On as getCurrentDate, kn as getCurrentTime, A as getElement, jn as getElementId, yn as getElementImage, bt as getElementItem, je as getElementOrWindow, he as getElementSafeScript, Kt as getExactSearchExp, Gt as getExp, Nn as getFirst, ge as getHydrationData, B as getItemByPath, Pn as getKey, Fn as
|
|
5051
|
+
export { F as Api, N as ApiCache, Be as ApiDataReturn, Ve as ApiDefault, We as ApiError, He as ApiErrorItem, Ue as ApiErrorStorage, Ge as ApiHeaders, qe as ApiHydration, Qe as ApiInstance, P as ApiMethodItem, Je as ApiPreparation, Ze as ApiResponse, Re as ApiStatus, $e as BroadcastMessage, nt as Cache, tt as CacheItem, rt as CacheStatic, Ee as Cookie, Ce as CookieBlock, Se as CookieBlockInstance, O as CookieStorage, D as DataStorage, at as Datetime, w as ErrorCenter, ue as ErrorCenterHandler, de as ErrorCenterInstance, Ne as EventItem, st as Formatters, V as FormattersType, ct as GEO_FLAG_ICON_NAME, k as Geo, lt as GeoFlag, ke as GeoInstance, L as GeoIntl, ut as GeoPhone, ft as GeoUnit, pt as Global, gt as Hash, ht as HashInstance, yt as Icons, M as Loading, Fe as LoadingInstance, Mt as Meta, G as MetaManager, At as MetaOg, Dt as MetaOpenGraphAge, Tt as MetaOpenGraphAvailability, Et as MetaOpenGraphCondition, Ot as MetaOpenGraphGender, q as MetaOpenGraphTag, wt as MetaOpenGraphType, Ct as MetaRobots, Nt as MetaStatic, K as MetaTag, jt as MetaTwitter, kt as MetaTwitterCard, J as MetaTwitterTag, Ft as Query, Pt as QueryInstance, It as ResumableTimer, Lt as ScrollbarWidth, Xt as SearchList, Ut as SearchListData, Wt as SearchListItem, Jt as SearchListMatcher, Yt as SearchListOptions, E as ServerStorage, Qt as StorageCallback, rn as TRANSLATE_GLOBAL_PREFIX, an as TRANSLATE_TIME_OUT, cn as Translate, on as TranslateFile, sn as TranslateInstance, De as UI_GEO_COOKIE_KEY, mt as UrlInstanceAbstract, Y as UrlItem, Ht as addTagHighlightMatch, x as anyToString, tn as applyTemplate, ln as arrFill, mn as blobToBase64, hn as capitalize, Z as copyObject, gn as copyObjectLite, U as createElement, _n as domQuerySelector, vn as domQuerySelectorAll, W as encodeAttribute, me as encodeLiteAttribute, Sn as ensureMaxSize, X as escapeExp, Cn as eventStopPropagation, m as executeFunction, Ye as executePromise, r as forEach, wn as frame, Tn as getArrayHighlightMatch, En as getAttributes, Dn as getClipboardData, it as getColumn, On as getCurrentDate, kn as getCurrentTime, A as getElement, jn as getElementId, yn as getElementImage, bt as getElementItem, je as getElementOrWindow, he as getElementSafeScript, Kt as getExactSearchExp, Gt as getExp, Nn as getFirst, ge as getHydrationData, B as getItemByPath, Pn as getKey, Fn as getLast, In as getLength, Ln as getLengthOfAllArray, Rn as getMaxLengthAllArray, zn as getMinLengthAllArray, Hn as getMouseClient, Bn as getMouseClientX, Vn as getMouseClientY, Un as getObjectByKeys, Wn as getObjectNoUndefined, Gn as getObjectOrNone, Kn as getOnlyText, Jn as getRandomText, o as getRequestString, qt as getSearchExp, Rt as getSeparatingSearchExp, Yn as getStepPercent, Xn as getStepValue, Qn as goScroll, $n as goScrollSmooth, er as goScrollTo, nr as handleShare, rr as inArray, Mn as initGetElementId, ir as initScrollbarOffset, ar as intersectKey, nn as isApiSuccess, i as isArray, or as isDifferent, oe as isDomData, s as isDomRuntime, sr as isElementVisible, lr as isEnter, l as isFilled, ur as isFloat, p as isFunction, Me as isInDom, cr as isInput, dr as isIntegerBetween, fr as isMetaKey, c as isNull, h as isNumber, t as isObject, n as isObjectNotArray, u as isOnLine, b as isSelected, pr as isSelectedByList, tr as isShare, d as isString, mr as isTab, Ae as isWindow, f as random, hr as removeCommonPrefix, gr as replaceComponentName, $ as replaceRecursive, vr as replaceTemplate, xn as resizeImageByMax, yr as secondToTime, xt as setElementItem, br as setValues, ee as sleep, xr as splice, qn as strFill, se as strSplit, j as toArray, ot as toCamelCase, Sr as toCamelCaseFirst, I as toDate, Cr as toKebabCase, y as toNumber, wr as toNumberByMax, Er as toPercent, Dr as toPercentBy100, a as toString, T as transformation, Or as uint8ArrayToBase64, _r as uniqueArray, kr as writeClipboardData };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxtmisha/functional-basic",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Foundational utility library for modern web development — HTTP client, geolocation, i18n, SEO meta tags, caching, storage, DOM utilities, and more. Framework-agnostic, zero dependencies, TypeScript-first.",
|
|
7
7
|
"keywords": [
|