@hypernym/utils 3.4.4 → 3.4.5
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/LICENSE.txt +2 -1
- package/README.md +370 -12
- package/dist/fs/index.d.mts +1 -1
- package/dist/index.d.mts +106 -34
- package/dist/index.iife.js +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +20 -21
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025 Ivo Dolenc
|
|
3
|
+
Copyright (c) 2025, Ivo Dolenc <https://github.com/ivodolenc>
|
|
4
|
+
Copyright (c) 2025, Hypernym Studio <https://github.com/hypernym-studio>
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center"
|
|
1
|
+
<h1 align="center">@hypernym/utils</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">A collection of reusable utilities.</p>
|
|
4
4
|
|
|
@@ -72,7 +72,7 @@ Also, it is possible to download files manually and serve them accordingly.
|
|
|
72
72
|
|
|
73
73
|
## Usage
|
|
74
74
|
|
|
75
|
-
After installation, import `
|
|
75
|
+
After installation, import `utils` into your project:
|
|
76
76
|
|
|
77
77
|
```ts
|
|
78
78
|
// ESM & TS
|
|
@@ -104,7 +104,7 @@ Returns a boolean if the given value is a `null`.
|
|
|
104
104
|
```ts
|
|
105
105
|
import { isNull } from '@hypernym/utils'
|
|
106
106
|
|
|
107
|
-
isNull(null) //
|
|
107
|
+
isNull(null) // true
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
### isUndefined
|
|
@@ -114,7 +114,7 @@ Returns a boolean if the given value is a `undefined`.
|
|
|
114
114
|
```ts
|
|
115
115
|
import { isUndefined } from '@hypernym/utils'
|
|
116
116
|
|
|
117
|
-
isUndefined(undefined) //
|
|
117
|
+
isUndefined(undefined) // true
|
|
118
118
|
```
|
|
119
119
|
|
|
120
120
|
### isString
|
|
@@ -124,7 +124,307 @@ Returns a boolean if the given value is a `string`.
|
|
|
124
124
|
```ts
|
|
125
125
|
import { isString } from '@hypernym/utils'
|
|
126
126
|
|
|
127
|
-
isString('@hypernym/utils') //
|
|
127
|
+
isString('@hypernym/utils') // true
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### isStringEmpty
|
|
131
|
+
|
|
132
|
+
Returns a boolean if the given value is an empty `string`.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import { isStringEmpty } from '@hypernym/utils'
|
|
136
|
+
|
|
137
|
+
isStringEmpty('') // true
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### isBoolean
|
|
141
|
+
|
|
142
|
+
Returns a boolean if the given value is a `boolean`.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { isBoolean } from '@hypernym/utils'
|
|
146
|
+
|
|
147
|
+
isBoolean(true) // true
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### isTrue
|
|
151
|
+
|
|
152
|
+
Returns a boolean if the given value is a `true`.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { isTrue } from '@hypernym/utils'
|
|
156
|
+
|
|
157
|
+
isTrue(true) // true
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### isFalse
|
|
161
|
+
|
|
162
|
+
Returns a boolean if the given value is a `false`.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { isFalse } from '@hypernym/utils'
|
|
166
|
+
|
|
167
|
+
isFalse(false) // true
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### isNumber
|
|
171
|
+
|
|
172
|
+
Returns a boolean if the given value is a `number`.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { isNumber } from '@hypernym/utils'
|
|
176
|
+
|
|
177
|
+
isNumber(33) // true
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### isArray
|
|
181
|
+
|
|
182
|
+
Returns a boolean if the given value is a `array`.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { isArray } from '@hypernym/utils'
|
|
186
|
+
|
|
187
|
+
isArray([]) // true
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### isArrayEmpty
|
|
191
|
+
|
|
192
|
+
Returns a boolean if the given value is an empty `array`.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
import { isArrayEmpty } from '@hypernym/utils'
|
|
196
|
+
|
|
197
|
+
isArrayEmpty([]) // true
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### isObject
|
|
201
|
+
|
|
202
|
+
Returns a boolean if the given value is a `object`.
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { isObject } from '@hypernym/utils'
|
|
206
|
+
|
|
207
|
+
isObject({}) // true
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### isObjectEmpty
|
|
211
|
+
|
|
212
|
+
Returns a boolean if the given value is an empty `object`.
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
import { isObjectEmpty } from '@hypernym/utils'
|
|
216
|
+
|
|
217
|
+
isObjectEmpty({}) // true
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### isFunction
|
|
221
|
+
|
|
222
|
+
Returns a boolean if the given value is a `Function`.
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import { isFunction } from '@hypernym/utils'
|
|
226
|
+
|
|
227
|
+
isFunction(() => {}) // true
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### isNanValue
|
|
231
|
+
|
|
232
|
+
Returns a boolean if the given value is a `NaN`.
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { isNaNValue } from '@hypernym/utils'
|
|
236
|
+
|
|
237
|
+
isNaNValue(NaN) // true
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### isRegExp
|
|
241
|
+
|
|
242
|
+
Returns a boolean if the given value is a `RegExp`.
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import { isRegExp } from '@hypernym/utils'
|
|
246
|
+
|
|
247
|
+
isRegExp(/^hypernym/) // true
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### isMap
|
|
251
|
+
|
|
252
|
+
Returns a boolean if the given value is a `Map`.
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import { isMap } from '@hypernym/utils'
|
|
256
|
+
|
|
257
|
+
isMap(new Map()) // true
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### isWeakMap
|
|
261
|
+
|
|
262
|
+
Returns a boolean if the given value is a `WeakMap`.
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { isWeakMap } from '@hypernym/utils'
|
|
266
|
+
|
|
267
|
+
isWeakMap(new WeakMap()) // true
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### isSet
|
|
271
|
+
|
|
272
|
+
Returns a boolean if the given value is a `Set`.
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
import { isSet } from '@hypernym/utils'
|
|
276
|
+
|
|
277
|
+
isSet(new Set()) // true
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### isWeakSet
|
|
281
|
+
|
|
282
|
+
Returns a boolean if the given value is a `WeakSet`.
|
|
283
|
+
|
|
284
|
+
```ts
|
|
285
|
+
import { isWeakSet } from '@hypernym/utils'
|
|
286
|
+
|
|
287
|
+
isWeakSet(new WeakSet()) // true
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### isSymbol
|
|
291
|
+
|
|
292
|
+
Returns a boolean if the given value is a `symbol`.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import { isSymbol } from '@hypernym/utils'
|
|
296
|
+
|
|
297
|
+
isSymbol(Symboly('hypernym')) // true
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### isDate
|
|
301
|
+
|
|
302
|
+
Returns a boolean if the given value is a `Date`.
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
import { isDate } from '@hypernym/utils'
|
|
306
|
+
|
|
307
|
+
isDate(new Date()) // true
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### isBigInt
|
|
311
|
+
|
|
312
|
+
Returns a boolean if the given value is a `bigint`.
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
import { isBigInt } from '@hypernym/utils'
|
|
316
|
+
|
|
317
|
+
isBigInt(1n) // true
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### isInfinity
|
|
321
|
+
|
|
322
|
+
Returns a boolean if the given value is a `Infinity`.
|
|
323
|
+
|
|
324
|
+
```ts
|
|
325
|
+
import { isInfinity } from '@hypernym/utils'
|
|
326
|
+
|
|
327
|
+
isInfinity(Infinity) // true
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### isURL
|
|
331
|
+
|
|
332
|
+
Returns a boolean if the given value is a `URL`.
|
|
333
|
+
|
|
334
|
+
```ts
|
|
335
|
+
import { isURL } from '@hypernym/utils'
|
|
336
|
+
|
|
337
|
+
isURL(new URL('https://localhost:3000')) // true
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### isError
|
|
341
|
+
|
|
342
|
+
Returns a boolean if the given value is a `Error`.
|
|
343
|
+
|
|
344
|
+
```ts
|
|
345
|
+
import { isError } from '@hypernym/utils'
|
|
346
|
+
|
|
347
|
+
isError(new Error()) // true
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### isPrimitive
|
|
351
|
+
|
|
352
|
+
Returns a boolean if the given value is a `Primitive`.
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import { isPrimitive } from '@hypernym/utils'
|
|
356
|
+
|
|
357
|
+
isPrimitive(true) // true
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### isElement
|
|
361
|
+
|
|
362
|
+
Returns a boolean if the given value is a `Element`.
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
import { isElement } from '@hypernym/utils'
|
|
366
|
+
|
|
367
|
+
isElement(el) // true
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### isHtmlElement
|
|
371
|
+
|
|
372
|
+
Returns a boolean if the given value is a `HTMLElement`.
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { isHtmlElement } from '@hypernym/utils'
|
|
376
|
+
|
|
377
|
+
isHtmlElement(htmlEl) // true
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### isSvgElement
|
|
381
|
+
|
|
382
|
+
Returns a boolean if the given value is a `SVGElement`.
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
import { isSvgElement } from '@hypernym/utils'
|
|
386
|
+
|
|
387
|
+
isSvgElement(svgEl) // true
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### isNodeList
|
|
391
|
+
|
|
392
|
+
Returns a boolean if the given value is a `NodeList`.
|
|
393
|
+
|
|
394
|
+
```ts
|
|
395
|
+
import { isNodeList } from '@hypernym/utils'
|
|
396
|
+
|
|
397
|
+
isNodeList(document.querySelectorAll('div')) // true
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
### isNodeListEmpty
|
|
401
|
+
|
|
402
|
+
Returns a boolean if the given value is an empty `NodeList`.
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
import { isNodeListEmpty } from '@hypernym/utils'
|
|
406
|
+
|
|
407
|
+
isNodeListEmpty(document.querySelectorAll('divs')) // true
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### isHtmlCollection
|
|
411
|
+
|
|
412
|
+
Returns a boolean if the given value is a `HTMLCollection`.
|
|
413
|
+
|
|
414
|
+
```ts
|
|
415
|
+
import { isHtmlCollection } from '@hypernym/utils'
|
|
416
|
+
|
|
417
|
+
isHtmlCollection(document.getElementsByClassName('el')) // true
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### isHtmlCollectionEmpty
|
|
421
|
+
|
|
422
|
+
Returns a boolean if the given value is an empty `HTMLCollection`.
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
import { isHtmlCollectionEmpty } from '@hypernym/utils'
|
|
426
|
+
|
|
427
|
+
isHtmlCollectionEmpty(document.getElementsByClassName('els')) // true
|
|
128
428
|
```
|
|
129
429
|
|
|
130
430
|
## fs
|
|
@@ -136,7 +436,7 @@ Checks if the `file` or `directory` exists.
|
|
|
136
436
|
```ts
|
|
137
437
|
import { exists } from '@hypernym/utils/fs'
|
|
138
438
|
|
|
139
|
-
await exists('dir/file.ts') //
|
|
439
|
+
await exists('dir/file.ts') // true
|
|
140
440
|
```
|
|
141
441
|
|
|
142
442
|
### read
|
|
@@ -207,6 +507,66 @@ await remove('src/subdir/file.ts')
|
|
|
207
507
|
|
|
208
508
|
## Types
|
|
209
509
|
|
|
510
|
+
### Primitive
|
|
511
|
+
|
|
512
|
+
Matches any primitive value.
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
import type { Primitive } from '@hypernym/utils'
|
|
516
|
+
|
|
517
|
+
type OnlyPrimitives<T> = T extends Primitive ? T : never
|
|
518
|
+
|
|
519
|
+
type Filtered = OnlyPrimitives<string | number | {} | Date> // string | number
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### BuiltIn
|
|
523
|
+
|
|
524
|
+
Matches any `Primitive`, `Date` or `RegExp` value.
|
|
525
|
+
|
|
526
|
+
```ts
|
|
527
|
+
import type { BuiltIn } from '@hypernym/utils'
|
|
528
|
+
|
|
529
|
+
type OnlyBuiltIns<T> = T extends BuiltIn ? T : never
|
|
530
|
+
|
|
531
|
+
type Filtered = OnlyBuiltIns<string | Date | {} | RegExp> // string | Date | RegExp
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### IsNull
|
|
535
|
+
|
|
536
|
+
Returns a boolean if the given type is a `null`.
|
|
537
|
+
|
|
538
|
+
```ts
|
|
539
|
+
import type { IsNull } from '@hypernym/utils'
|
|
540
|
+
|
|
541
|
+
type A = IsNull<null> // true
|
|
542
|
+
type B = IsNull<string> // false
|
|
543
|
+
type C = IsNull<undefined> // false
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### IsAny
|
|
547
|
+
|
|
548
|
+
Returns a boolean if the given type is a `any`.
|
|
549
|
+
|
|
550
|
+
```ts
|
|
551
|
+
import type { IsAny } from '@hypernym/utils'
|
|
552
|
+
|
|
553
|
+
type A = IsAny<any> // true
|
|
554
|
+
type B = IsAny<string> // false
|
|
555
|
+
type C = IsAny<unknown> // false
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
### IsNever
|
|
559
|
+
|
|
560
|
+
Returns a boolean if the given type is a `never`.
|
|
561
|
+
|
|
562
|
+
```ts
|
|
563
|
+
import type { IsNever } from '@hypernym/utils'
|
|
564
|
+
|
|
565
|
+
type A = IsNever<never> // true
|
|
566
|
+
type B = IsNever<number> // false
|
|
567
|
+
type C = IsNever<undefined> // false
|
|
568
|
+
```
|
|
569
|
+
|
|
210
570
|
### PartialDeep
|
|
211
571
|
|
|
212
572
|
Constructs a type by recursively setting all properties as optional.
|
|
@@ -214,6 +574,8 @@ Constructs a type by recursively setting all properties as optional.
|
|
|
214
574
|
Use `Partial<T>` for one level.
|
|
215
575
|
|
|
216
576
|
```ts
|
|
577
|
+
import type { PartialDeep } from '@hypernym/utils'
|
|
578
|
+
|
|
217
579
|
type PartialObject = PartialDeep<Object>
|
|
218
580
|
|
|
219
581
|
// Disables recursive mode for arrays and tuples.
|
|
@@ -227,18 +589,14 @@ Constructs a type by recursively setting all properties as required.
|
|
|
227
589
|
Use `Required<T>` for one level.
|
|
228
590
|
|
|
229
591
|
```ts
|
|
592
|
+
import type { RequiredDeep } from '@hypernym/utils'
|
|
593
|
+
|
|
230
594
|
type RequiredObject = RequiredDeep<Object>
|
|
231
595
|
|
|
232
596
|
// Disables recursive mode for arrays and tuples.
|
|
233
597
|
type RequiredObject = RequiredDeep<Object, { arrays: false }>
|
|
234
598
|
```
|
|
235
599
|
|
|
236
|
-
## Community
|
|
237
|
-
|
|
238
|
-
Feel free to ask questions or share new ideas.
|
|
239
|
-
|
|
240
|
-
Use the official [discussions](https://github.com/hypernym-studio/utils/discussions) to get involved.
|
|
241
|
-
|
|
242
600
|
## License
|
|
243
601
|
|
|
244
602
|
Developed in 🇭🇷 Croatia, © Hypernym Studio.
|
package/dist/fs/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { writeFile as writeFile$1 } from 'node:fs/promises';
|
|
|
9
9
|
* ```ts
|
|
10
10
|
* import { exists } from '@hypernym/utils/fs'
|
|
11
11
|
*
|
|
12
|
-
* await exists('dir/file.ts') //
|
|
12
|
+
* await exists('dir/file.ts') // true
|
|
13
13
|
* ```
|
|
14
14
|
*/
|
|
15
15
|
declare function exists(path: string): Promise<boolean>;
|
package/dist/index.d.mts
CHANGED
|
@@ -18,17 +18,37 @@ declare const noop: () => void;
|
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { toString } from '@hypernym/utils'
|
|
20
20
|
*
|
|
21
|
-
* toString({}) //
|
|
21
|
+
* toString({}) // 'Object'
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
declare const toString: (v: any) => string;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Matches any primitive value.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* import type { Primitive } from '@hypernym/utils'
|
|
33
|
+
*
|
|
34
|
+
* type OnlyPrimitives<T> = T extends Primitive ? T : never
|
|
35
|
+
*
|
|
36
|
+
* type Filtered = OnlyPrimitives<string | number | {} | Date> // string | number
|
|
37
|
+
* ```
|
|
28
38
|
*/
|
|
29
39
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
30
40
|
/**
|
|
31
41
|
* Matches any `Primitive`, `Date` or `RegExp` value.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* import type { BuiltIn } from '@hypernym/utils'
|
|
47
|
+
*
|
|
48
|
+
* type OnlyBuiltIns<T> = T extends BuiltIn ? T : never
|
|
49
|
+
*
|
|
50
|
+
* type Filtered = OnlyBuiltIns<string | Date | {} | RegExp> // string | Date | RegExp
|
|
51
|
+
* ```
|
|
32
52
|
*/
|
|
33
53
|
type BuiltIn = Primitive | Date | RegExp;
|
|
34
54
|
|
|
@@ -52,7 +72,7 @@ declare const isBrowser: boolean;
|
|
|
52
72
|
* ```ts
|
|
53
73
|
* import { isNull } from '@hypernym/utils'
|
|
54
74
|
*
|
|
55
|
-
* isNull(null) //
|
|
75
|
+
* isNull(null) // true
|
|
56
76
|
* ```
|
|
57
77
|
*/
|
|
58
78
|
declare const isNull: (v: any) => v is null;
|
|
@@ -64,7 +84,7 @@ declare const isNull: (v: any) => v is null;
|
|
|
64
84
|
* ```ts
|
|
65
85
|
* import { isUndefined } from '@hypernym/utils'
|
|
66
86
|
*
|
|
67
|
-
* isUndefined(undefined) //
|
|
87
|
+
* isUndefined(undefined) // true
|
|
68
88
|
* ```
|
|
69
89
|
*/
|
|
70
90
|
declare const isUndefined: (v: any) => v is undefined;
|
|
@@ -76,7 +96,7 @@ declare const isUndefined: (v: any) => v is undefined;
|
|
|
76
96
|
* ```ts
|
|
77
97
|
* import { isString } from '@hypernym/utils'
|
|
78
98
|
*
|
|
79
|
-
* isString('@hypernym/utils') //
|
|
99
|
+
* isString('@hypernym/utils') // true
|
|
80
100
|
* ```
|
|
81
101
|
*/
|
|
82
102
|
declare const isString: (v: any) => v is string;
|
|
@@ -88,7 +108,7 @@ declare const isString: (v: any) => v is string;
|
|
|
88
108
|
* ```ts
|
|
89
109
|
* import { isStringEmpty } from '@hypernym/utils'
|
|
90
110
|
*
|
|
91
|
-
* isStringEmpty('') //
|
|
111
|
+
* isStringEmpty('') // true
|
|
92
112
|
* ```
|
|
93
113
|
*/
|
|
94
114
|
declare const isStringEmpty: (v: any) => v is string;
|
|
@@ -100,7 +120,7 @@ declare const isStringEmpty: (v: any) => v is string;
|
|
|
100
120
|
* ```ts
|
|
101
121
|
* import { isBoolean } from '@hypernym/utils'
|
|
102
122
|
*
|
|
103
|
-
* isBoolean(true) //
|
|
123
|
+
* isBoolean(true) // true
|
|
104
124
|
* ```
|
|
105
125
|
*/
|
|
106
126
|
declare const isBoolean: (v: any) => v is boolean;
|
|
@@ -112,7 +132,7 @@ declare const isBoolean: (v: any) => v is boolean;
|
|
|
112
132
|
* ```ts
|
|
113
133
|
* import { isTrue } from '@hypernym/utils'
|
|
114
134
|
*
|
|
115
|
-
* isTrue(true) //
|
|
135
|
+
* isTrue(true) // true
|
|
116
136
|
* ```
|
|
117
137
|
*/
|
|
118
138
|
declare const isTrue: (v: any) => v is true;
|
|
@@ -124,7 +144,7 @@ declare const isTrue: (v: any) => v is true;
|
|
|
124
144
|
* ```ts
|
|
125
145
|
* import { isFalse } from '@hypernym/utils'
|
|
126
146
|
*
|
|
127
|
-
* isFalse(false) //
|
|
147
|
+
* isFalse(false) // true
|
|
128
148
|
* ```
|
|
129
149
|
*/
|
|
130
150
|
declare const isFalse: (v: any) => v is false;
|
|
@@ -136,7 +156,7 @@ declare const isFalse: (v: any) => v is false;
|
|
|
136
156
|
* ```ts
|
|
137
157
|
* import { isNumber } from '@hypernym/utils'
|
|
138
158
|
*
|
|
139
|
-
* isNumber(33) //
|
|
159
|
+
* isNumber(33) // true
|
|
140
160
|
* ```
|
|
141
161
|
*/
|
|
142
162
|
declare const isNumber: (v: any) => v is number;
|
|
@@ -148,7 +168,7 @@ declare const isNumber: (v: any) => v is number;
|
|
|
148
168
|
* ```ts
|
|
149
169
|
* import { isArray } from '@hypernym/utils'
|
|
150
170
|
*
|
|
151
|
-
* isArray([]) //
|
|
171
|
+
* isArray([]) // true
|
|
152
172
|
* ```
|
|
153
173
|
*/
|
|
154
174
|
declare const isArray: (v: any) => v is any[];
|
|
@@ -160,7 +180,7 @@ declare const isArray: (v: any) => v is any[];
|
|
|
160
180
|
* ```ts
|
|
161
181
|
* import { isArrayEmpty } from '@hypernym/utils'
|
|
162
182
|
*
|
|
163
|
-
* isArrayEmpty([]) //
|
|
183
|
+
* isArrayEmpty([]) // true
|
|
164
184
|
* ```
|
|
165
185
|
*/
|
|
166
186
|
declare const isArrayEmpty: (v: any) => v is any[];
|
|
@@ -172,7 +192,7 @@ declare const isArrayEmpty: (v: any) => v is any[];
|
|
|
172
192
|
* ```ts
|
|
173
193
|
* import { isObject } from '@hypernym/utils'
|
|
174
194
|
*
|
|
175
|
-
* isObject({}) //
|
|
195
|
+
* isObject({}) // true
|
|
176
196
|
* ```
|
|
177
197
|
*/
|
|
178
198
|
declare const isObject: (v: any) => v is object;
|
|
@@ -184,7 +204,7 @@ declare const isObject: (v: any) => v is object;
|
|
|
184
204
|
* ```ts
|
|
185
205
|
* import { isObjectEmpty } from '@hypernym/utils'
|
|
186
206
|
*
|
|
187
|
-
* isObjectEmpty({}) //
|
|
207
|
+
* isObjectEmpty({}) // true
|
|
188
208
|
* ```
|
|
189
209
|
*/
|
|
190
210
|
declare const isObjectEmpty: (v: any) => v is object;
|
|
@@ -196,7 +216,7 @@ declare const isObjectEmpty: (v: any) => v is object;
|
|
|
196
216
|
* ```ts
|
|
197
217
|
* import { isFunction } from '@hypernym/utils'
|
|
198
218
|
*
|
|
199
|
-
* isFunction(() => {}) //
|
|
219
|
+
* isFunction(() => {}) // true
|
|
200
220
|
* ```
|
|
201
221
|
*/
|
|
202
222
|
declare const isFunction: (v: any) => v is (...args: any[]) => unknown;
|
|
@@ -208,7 +228,7 @@ declare const isFunction: (v: any) => v is (...args: any[]) => unknown;
|
|
|
208
228
|
* ```ts
|
|
209
229
|
* import { isNaNValue } from '@hypernym/utils'
|
|
210
230
|
*
|
|
211
|
-
* isNaNValue(NaN) //
|
|
231
|
+
* isNaNValue(NaN) // true
|
|
212
232
|
* ```
|
|
213
233
|
*/
|
|
214
234
|
declare const isNaNValue: (v: any) => v is typeof NaN;
|
|
@@ -220,7 +240,7 @@ declare const isNaNValue: (v: any) => v is typeof NaN;
|
|
|
220
240
|
* ```ts
|
|
221
241
|
* import { isRegExp } from '@hypernym/utils'
|
|
222
242
|
*
|
|
223
|
-
* isRegExp(/^hypernym/) //
|
|
243
|
+
* isRegExp(/^hypernym/) // true
|
|
224
244
|
* ```
|
|
225
245
|
*/
|
|
226
246
|
declare const isRegExp: (v: any) => v is RegExp;
|
|
@@ -232,7 +252,7 @@ declare const isRegExp: (v: any) => v is RegExp;
|
|
|
232
252
|
* ```ts
|
|
233
253
|
* import { isMap } from '@hypernym/utils'
|
|
234
254
|
*
|
|
235
|
-
* isMap(new Map()) //
|
|
255
|
+
* isMap(new Map()) // true
|
|
236
256
|
* ```
|
|
237
257
|
*/
|
|
238
258
|
declare const isMap: (v: any) => v is Map<any, any>;
|
|
@@ -244,7 +264,7 @@ declare const isMap: (v: any) => v is Map<any, any>;
|
|
|
244
264
|
* ```ts
|
|
245
265
|
* import { isWeakMap } from '@hypernym/utils'
|
|
246
266
|
*
|
|
247
|
-
* isWeakMap(new WeakMap()) //
|
|
267
|
+
* isWeakMap(new WeakMap()) // true
|
|
248
268
|
* ```
|
|
249
269
|
*/
|
|
250
270
|
declare const isWeakMap: (v: any) => v is WeakMap<any, any>;
|
|
@@ -256,7 +276,7 @@ declare const isWeakMap: (v: any) => v is WeakMap<any, any>;
|
|
|
256
276
|
* ```ts
|
|
257
277
|
* import { isSet } from '@hypernym/utils'
|
|
258
278
|
*
|
|
259
|
-
* isSet(new Set()) //
|
|
279
|
+
* isSet(new Set()) // true
|
|
260
280
|
* ```
|
|
261
281
|
*/
|
|
262
282
|
declare const isSet: (v: any) => v is Set<any>;
|
|
@@ -268,7 +288,7 @@ declare const isSet: (v: any) => v is Set<any>;
|
|
|
268
288
|
* ```ts
|
|
269
289
|
* import { isWeakSet } from '@hypernym/utils'
|
|
270
290
|
*
|
|
271
|
-
* isWeakSet(new WeakSet()) //
|
|
291
|
+
* isWeakSet(new WeakSet()) // true
|
|
272
292
|
* ```
|
|
273
293
|
*/
|
|
274
294
|
declare const isWeakSet: (v: any) => v is WeakSet<any>;
|
|
@@ -280,7 +300,7 @@ declare const isWeakSet: (v: any) => v is WeakSet<any>;
|
|
|
280
300
|
* ```ts
|
|
281
301
|
* import { isSymbol } from '@hypernym/utils'
|
|
282
302
|
*
|
|
283
|
-
* isSymbol(Symboly('hypernym')) //
|
|
303
|
+
* isSymbol(Symboly('hypernym')) // true
|
|
284
304
|
* ```
|
|
285
305
|
*/
|
|
286
306
|
declare const isSymbol: (v: any) => v is symbol;
|
|
@@ -292,7 +312,7 @@ declare const isSymbol: (v: any) => v is symbol;
|
|
|
292
312
|
* ```ts
|
|
293
313
|
* import { isDate } from '@hypernym/utils'
|
|
294
314
|
*
|
|
295
|
-
* isDate(new Date()) //
|
|
315
|
+
* isDate(new Date()) // true
|
|
296
316
|
* ```
|
|
297
317
|
*/
|
|
298
318
|
declare const isDate: (v: any) => v is Date;
|
|
@@ -304,7 +324,7 @@ declare const isDate: (v: any) => v is Date;
|
|
|
304
324
|
* ```ts
|
|
305
325
|
* import { isBigInt } from '@hypernym/utils'
|
|
306
326
|
*
|
|
307
|
-
* isBigInt(1n) //
|
|
327
|
+
* isBigInt(1n) // true
|
|
308
328
|
* ```
|
|
309
329
|
*/
|
|
310
330
|
declare const isBigInt: (v: any) => v is bigint;
|
|
@@ -316,7 +336,7 @@ declare const isBigInt: (v: any) => v is bigint;
|
|
|
316
336
|
* ```ts
|
|
317
337
|
* import { isInfinity } from '@hypernym/utils'
|
|
318
338
|
*
|
|
319
|
-
* isInfinity(Infinity) //
|
|
339
|
+
* isInfinity(Infinity) // true
|
|
320
340
|
* ```
|
|
321
341
|
*/
|
|
322
342
|
declare const isInfinity: (v: any) => v is number;
|
|
@@ -328,7 +348,7 @@ declare const isInfinity: (v: any) => v is number;
|
|
|
328
348
|
* ```ts
|
|
329
349
|
* import { isURL } from '@hypernym/utils'
|
|
330
350
|
*
|
|
331
|
-
* isURL(new URL('https://localhost:3000')) //
|
|
351
|
+
* isURL(new URL('https://localhost:3000')) // true
|
|
332
352
|
* ```
|
|
333
353
|
*/
|
|
334
354
|
declare const isURL: (v: any) => v is URL;
|
|
@@ -340,7 +360,7 @@ declare const isURL: (v: any) => v is URL;
|
|
|
340
360
|
* ```ts
|
|
341
361
|
* import { isError } from '@hypernym/utils'
|
|
342
362
|
*
|
|
343
|
-
* isError(new Error()) //
|
|
363
|
+
* isError(new Error()) // true
|
|
344
364
|
* ```
|
|
345
365
|
*/
|
|
346
366
|
declare const isError: (v: any) => v is Error;
|
|
@@ -352,7 +372,7 @@ declare const isError: (v: any) => v is Error;
|
|
|
352
372
|
* ```ts
|
|
353
373
|
* import { isPrimitive } from '@hypernym/utils'
|
|
354
374
|
*
|
|
355
|
-
* isPrimitive(true) //
|
|
375
|
+
* isPrimitive(true) // true
|
|
356
376
|
* ```
|
|
357
377
|
*/
|
|
358
378
|
declare const isPrimitive: (v: any) => v is Primitive;
|
|
@@ -364,7 +384,7 @@ declare const isPrimitive: (v: any) => v is Primitive;
|
|
|
364
384
|
* ```ts
|
|
365
385
|
* import { isElement } from '@hypernym/utils'
|
|
366
386
|
*
|
|
367
|
-
* isElement(el) //
|
|
387
|
+
* isElement(el) // true
|
|
368
388
|
* ```
|
|
369
389
|
*/
|
|
370
390
|
declare const isElement: (v: any) => v is Element;
|
|
@@ -376,7 +396,7 @@ declare const isElement: (v: any) => v is Element;
|
|
|
376
396
|
* ```ts
|
|
377
397
|
* import { isHtmlElement } from '@hypernym/utils'
|
|
378
398
|
*
|
|
379
|
-
* isHtmlElement(htmlEl) //
|
|
399
|
+
* isHtmlElement(htmlEl) // true
|
|
380
400
|
* ```
|
|
381
401
|
*/
|
|
382
402
|
declare const isHtmlElement: (v: any) => v is HTMLElement;
|
|
@@ -388,7 +408,7 @@ declare const isHtmlElement: (v: any) => v is HTMLElement;
|
|
|
388
408
|
* ```ts
|
|
389
409
|
* import { isSvgElement } from '@hypernym/utils'
|
|
390
410
|
*
|
|
391
|
-
* isSvgElement(svgEl) //
|
|
411
|
+
* isSvgElement(svgEl) // true
|
|
392
412
|
* ```
|
|
393
413
|
*/
|
|
394
414
|
declare const isSvgElement: (v: any) => v is SVGElement;
|
|
@@ -400,7 +420,7 @@ declare const isSvgElement: (v: any) => v is SVGElement;
|
|
|
400
420
|
* ```ts
|
|
401
421
|
* import { isNodeList } from '@hypernym/utils'
|
|
402
422
|
*
|
|
403
|
-
* isNodeList(document.querySelectorAll('div')) //
|
|
423
|
+
* isNodeList(document.querySelectorAll('div')) // true
|
|
404
424
|
* ```
|
|
405
425
|
*/
|
|
406
426
|
declare const isNodeList: (v: any) => v is NodeList;
|
|
@@ -412,7 +432,7 @@ declare const isNodeList: (v: any) => v is NodeList;
|
|
|
412
432
|
* ```ts
|
|
413
433
|
* import { isNodeListEmpty } from '@hypernym/utils'
|
|
414
434
|
*
|
|
415
|
-
* isNodeListEmpty(document.querySelectorAll('divs')) //
|
|
435
|
+
* isNodeListEmpty(document.querySelectorAll('divs')) // true
|
|
416
436
|
* ```
|
|
417
437
|
*/
|
|
418
438
|
declare const isNodeListEmpty: (v: any) => v is NodeList;
|
|
@@ -424,7 +444,7 @@ declare const isNodeListEmpty: (v: any) => v is NodeList;
|
|
|
424
444
|
* ```ts
|
|
425
445
|
* import { isHtmlCollection } from '@hypernym/utils'
|
|
426
446
|
*
|
|
427
|
-
* isHtmlCollection(document.getElementsByClassName('el')) //
|
|
447
|
+
* isHtmlCollection(document.getElementsByClassName('el')) // true
|
|
428
448
|
* ```
|
|
429
449
|
*/
|
|
430
450
|
declare const isHtmlCollection: (v: any) => v is HTMLCollection;
|
|
@@ -434,21 +454,51 @@ declare const isHtmlCollection: (v: any) => v is HTMLCollection;
|
|
|
434
454
|
* ```ts
|
|
435
455
|
* import { isHtmlCollectionEmpty } from '@hypernym/utils'
|
|
436
456
|
*
|
|
437
|
-
* isHtmlCollectionEmpty(document.getElementsByClassName('els')) //
|
|
457
|
+
* isHtmlCollectionEmpty(document.getElementsByClassName('els')) // true
|
|
438
458
|
* ```
|
|
439
459
|
*/
|
|
440
460
|
declare const isHtmlCollectionEmpty: (v: any) => v is HTMLCollection;
|
|
441
461
|
|
|
442
462
|
/**
|
|
443
463
|
* Returns a boolean if the given type is a `null`.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
*
|
|
467
|
+
* ```ts
|
|
468
|
+
* import type { IsNull } from '@hypernym/utils'
|
|
469
|
+
*
|
|
470
|
+
* type A = IsNull<null> // true
|
|
471
|
+
* type B = IsNull<string> // false
|
|
472
|
+
* type C = IsNull<undefined> // false
|
|
473
|
+
* ```
|
|
444
474
|
*/
|
|
445
475
|
type IsNull<T> = [T] extends [null] ? true : false;
|
|
446
476
|
/**
|
|
447
477
|
* Returns a boolean if the given type is a `any`.
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
*
|
|
481
|
+
* ```ts
|
|
482
|
+
* import type { IsAny } from '@hypernym/utils'
|
|
483
|
+
*
|
|
484
|
+
* type A = IsAny<any> // true
|
|
485
|
+
* type B = IsAny<string> // false
|
|
486
|
+
* type C = IsAny<unknown> // false
|
|
487
|
+
* ```
|
|
448
488
|
*/
|
|
449
489
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
450
490
|
/**
|
|
451
491
|
* Returns a boolean if the given type is a `never`.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
*
|
|
495
|
+
* ```ts
|
|
496
|
+
* import type { IsNever } from '@hypernym/utils'
|
|
497
|
+
*
|
|
498
|
+
* type A = IsNever<never> // true
|
|
499
|
+
* type B = IsNever<number> // false
|
|
500
|
+
* type C = IsNever<undefined> // false
|
|
501
|
+
* ```
|
|
452
502
|
*/
|
|
453
503
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
454
504
|
|
|
@@ -464,6 +514,17 @@ type PartialOptions = {
|
|
|
464
514
|
* Constructs a type by recursively setting all properties as optional.
|
|
465
515
|
*
|
|
466
516
|
* Use `Partial<T>` for one level.
|
|
517
|
+
*
|
|
518
|
+
* @example
|
|
519
|
+
*
|
|
520
|
+
* ```ts
|
|
521
|
+
* import type { PartialDeep } from '@hypernym/utils'
|
|
522
|
+
*
|
|
523
|
+
* type PartialObject = PartialDeep<Object>
|
|
524
|
+
*
|
|
525
|
+
* // Disables recursive mode for arrays and tuples.
|
|
526
|
+
* type PartialObject = PartialDeep<Object, { arrays: false }>
|
|
527
|
+
* ```
|
|
467
528
|
*/
|
|
468
529
|
type PartialDeep<T, Options extends PartialOptions = {
|
|
469
530
|
arrays: true;
|
|
@@ -486,6 +547,17 @@ type RequiredOptions = {
|
|
|
486
547
|
* Constructs a type by recursively setting all properties as required.
|
|
487
548
|
*
|
|
488
549
|
* Use `Required<T>` for one level.
|
|
550
|
+
*
|
|
551
|
+
* @example
|
|
552
|
+
*
|
|
553
|
+
* ```ts
|
|
554
|
+
* import type { RequiredDeep } from '@hypernym/utils'
|
|
555
|
+
*
|
|
556
|
+
* type RequiredObject = RequiredDeep<Object>
|
|
557
|
+
*
|
|
558
|
+
* // Disables recursive mode for arrays and tuples.
|
|
559
|
+
* type RequiredObject = RequiredDeep<Object, { arrays: false }>
|
|
560
|
+
* ```
|
|
489
561
|
*/
|
|
490
562
|
type RequiredDeep<T, Options extends RequiredOptions = {
|
|
491
563
|
arrays: true;
|
package/dist/index.iife.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Hyperutils=function(e){"use strict";const g=()=>{},t=i=>Object.prototype.toString.call(i).slice(8,-1),N=typeof window<"u",s=i=>i===null,l=i=>typeof i>"u",n=i=>typeof i=="string",S=i=>n(i)&&i.trim().length===0,a=i=>typeof i=="boolean",b=i=>i===!0,r=i=>i===!1,c=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),d=i=>m(i)&&i.length===0,y=i=>t(i)==="Object",L=i=>y(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,M=i=>typeof i=="number"&&isNaN(i),O=i=>i instanceof RegExp,j=i=>i instanceof Map,k=i=>i instanceof WeakMap,v=i=>i instanceof Set,A=i=>i instanceof WeakSet,o=i=>t(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),f=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,W=i=>i instanceof URL,h=i=>i instanceof Error,C=i=>n(i)||c(i)||f(i)||a(i)||o(i)||s(i)||l(i),F=i=>i instanceof Element,U=i=>i instanceof HTMLElement,w=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,I=i=>E(i)&&i.length===0,u=i=>i instanceof HTMLCollection,T=i=>u(i)&&i.length===0;return e.isArray=m,e.isArrayEmpty=d,e.isBigInt=f,e.isBoolean=a,e.isBrowser=N,e.isDate=B,e.isElement=F,e.isError=h,e.isFalse=r,e.isFunction=H,e.isHtmlCollection=u,e.isHtmlCollectionEmpty=T,e.isHtmlElement=U,e.isInfinity=R,e.isMap=j,e.isNaNValue=M,e.isNodeList=E,e.isNodeListEmpty=I,e.isNull=s,e.isNumber=c,e.isObject=y,e.isObjectEmpty=L,e.isPrimitive=C,e.isRegExp=O,e.isSet=v,e.isString=n,e.isStringEmpty=S,e.isSvgElement=w,e.isSymbol=o,e.isTrue=b,e.isURL=W,e.isUndefined=l,e.isWeakMap=k,e.isWeakSet=A,e.noop=g,e.toString=t,e}({});
|
|
1
|
+
var Hyperutils=(function(e){"use strict";const g=()=>{},t=i=>Object.prototype.toString.call(i).slice(8,-1),N=typeof window<"u",s=i=>i===null,l=i=>typeof i>"u",n=i=>typeof i=="string",S=i=>n(i)&&i.trim().length===0,a=i=>typeof i=="boolean",b=i=>i===!0,r=i=>i===!1,c=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),d=i=>m(i)&&i.length===0,y=i=>t(i)==="Object",L=i=>y(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,M=i=>typeof i=="number"&&isNaN(i),O=i=>i instanceof RegExp,j=i=>i instanceof Map,k=i=>i instanceof WeakMap,v=i=>i instanceof Set,A=i=>i instanceof WeakSet,o=i=>t(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),f=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,W=i=>i instanceof URL,h=i=>i instanceof Error,C=i=>n(i)||c(i)||f(i)||a(i)||o(i)||s(i)||l(i),F=i=>i instanceof Element,U=i=>i instanceof HTMLElement,w=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,I=i=>E(i)&&i.length===0,u=i=>i instanceof HTMLCollection,T=i=>u(i)&&i.length===0;return e.isArray=m,e.isArrayEmpty=d,e.isBigInt=f,e.isBoolean=a,e.isBrowser=N,e.isDate=B,e.isElement=F,e.isError=h,e.isFalse=r,e.isFunction=H,e.isHtmlCollection=u,e.isHtmlCollectionEmpty=T,e.isHtmlElement=U,e.isInfinity=R,e.isMap=j,e.isNaNValue=M,e.isNodeList=E,e.isNodeListEmpty=I,e.isNull=s,e.isNumber=c,e.isObject=y,e.isObjectEmpty=L,e.isPrimitive=C,e.isRegExp=O,e.isSet=v,e.isString=n,e.isStringEmpty=S,e.isSvgElement=w,e.isSymbol=o,e.isTrue=b,e.isURL=W,e.isUndefined=l,e.isWeakMap=k,e.isWeakSet=A,e.noop=g,e.toString=t,e})({});
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.Hyperutils={}))})(this,function(e){"use strict";const t=()=>{},n=i=>Object.prototype.toString.call(i).slice(8,-1),d=typeof window<"u",l=i=>i===null,a=i=>typeof i>"u",s=i=>typeof i=="string",N=i=>s(i)&&i.trim().length===0,o=i=>typeof i=="boolean",S=i=>i===!0,b=i=>i===!1,f=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),r=i=>m(i)&&i.length===0,c=i=>n(i)==="Object",L=i=>c(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,h=i=>typeof i=="number"&&isNaN(i),j=i=>i instanceof RegExp,M=i=>i instanceof Map,O=i=>i instanceof WeakMap,k=i=>i instanceof Set,A=i=>i instanceof WeakSet,y=i=>n(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),u=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,T=i=>i instanceof URL,W=i=>i instanceof Error,v=i=>s(i)||f(i)||u(i)||o(i)||y(i)||l(i)||a(i),C=i=>i instanceof Element,F=i=>i instanceof HTMLElement,U=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,w=i=>E(i)&&i.length===0,g=i=>i instanceof HTMLCollection,I=i=>g(i)&&i.length===0;e.isArray=m,e.isArrayEmpty=r,e.isBigInt=u,e.isBoolean=o,e.isBrowser=d,e.isDate=B,e.isElement=C,e.isError=W,e.isFalse=b,e.isFunction=H,e.isHtmlCollection=g,e.isHtmlCollectionEmpty=I,e.isHtmlElement=F,e.isInfinity=R,e.isMap=M,e.isNaNValue=h,e.isNodeList=E,e.isNodeListEmpty=w,e.isNull=l,e.isNumber=f,e.isObject=c,e.isObjectEmpty=L,e.isPrimitive=v,e.isRegExp=j,e.isSet=k,e.isString=s,e.isStringEmpty=N,e.isSvgElement=U,e.isSymbol=y,e.isTrue=S,e.isURL=T,e.isUndefined=a,e.isWeakMap=O,e.isWeakSet=A,e.noop=t,e.toString=n});
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.Hyperutils={}))})(this,(function(e){"use strict";const t=()=>{},n=i=>Object.prototype.toString.call(i).slice(8,-1),d=typeof window<"u",l=i=>i===null,a=i=>typeof i>"u",s=i=>typeof i=="string",N=i=>s(i)&&i.trim().length===0,o=i=>typeof i=="boolean",S=i=>i===!0,b=i=>i===!1,f=i=>typeof i=="number"&&!isNaN(i),m=i=>Array.isArray(i),r=i=>m(i)&&i.length===0,c=i=>n(i)==="Object",L=i=>c(i)&&Object.keys(i).length===0,H=i=>i instanceof Function,h=i=>typeof i=="number"&&isNaN(i),j=i=>i instanceof RegExp,M=i=>i instanceof Map,O=i=>i instanceof WeakMap,k=i=>i instanceof Set,A=i=>i instanceof WeakSet,y=i=>n(i)==="Symbol",B=i=>i instanceof Date&&!isNaN(i.valueOf()),u=i=>typeof i=="bigint",R=i=>i===1/0||i===-1/0,T=i=>i instanceof URL,W=i=>i instanceof Error,v=i=>s(i)||f(i)||u(i)||o(i)||y(i)||l(i)||a(i),C=i=>i instanceof Element,F=i=>i instanceof HTMLElement,U=i=>i instanceof SVGElement,E=i=>i instanceof NodeList,w=i=>E(i)&&i.length===0,g=i=>i instanceof HTMLCollection,I=i=>g(i)&&i.length===0;e.isArray=m,e.isArrayEmpty=r,e.isBigInt=u,e.isBoolean=o,e.isBrowser=d,e.isDate=B,e.isElement=C,e.isError=W,e.isFalse=b,e.isFunction=H,e.isHtmlCollection=g,e.isHtmlCollectionEmpty=I,e.isHtmlElement=F,e.isInfinity=R,e.isMap=M,e.isNaNValue=h,e.isNodeList=E,e.isNodeListEmpty=w,e.isNull=l,e.isNumber=f,e.isObject=c,e.isObjectEmpty=L,e.isPrimitive=v,e.isRegExp=j,e.isSet=k,e.isString=s,e.isStringEmpty=N,e.isSvgElement=U,e.isSymbol=y,e.isTrue=S,e.isURL=T,e.isUndefined=a,e.isWeakMap=O,e.isWeakSet=A,e.noop=t,e.toString=n}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.5",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,16 +37,6 @@
|
|
|
37
37
|
"js",
|
|
38
38
|
"ts"
|
|
39
39
|
],
|
|
40
|
-
"scripts": {
|
|
41
|
-
"dev:browser": "vite playgrounds/browser",
|
|
42
|
-
"dev:server": "bun --watch playgrounds/server/main.ts",
|
|
43
|
-
"build": "hyperbundler",
|
|
44
|
-
"test": "vitest -c test/vitest.config.ts",
|
|
45
|
-
"lint": "eslint .",
|
|
46
|
-
"lint:fix": "eslint --fix .",
|
|
47
|
-
"format": "prettier --write .",
|
|
48
|
-
"prepublishOnly": "npm run build"
|
|
49
|
-
},
|
|
50
40
|
"peerDependencies": {
|
|
51
41
|
"@types/node": ">=20.0.0",
|
|
52
42
|
"typescript": ">=5.0.0"
|
|
@@ -60,14 +50,23 @@
|
|
|
60
50
|
}
|
|
61
51
|
},
|
|
62
52
|
"devDependencies": {
|
|
63
|
-
"@hypernym/bundler": "^0.14.
|
|
64
|
-
"@hypernym/eslint-config": "^3.6.
|
|
65
|
-
"@hypernym/prettier-config": "^3.2.
|
|
66
|
-
"@hypernym/tsconfig": "^2.6.
|
|
67
|
-
"@types/node": "^
|
|
68
|
-
"eslint": "^9.
|
|
69
|
-
"prettier": "^3.
|
|
70
|
-
"typescript": "^5.
|
|
71
|
-
"vitest": "^3.
|
|
53
|
+
"@hypernym/bundler": "^0.14.4",
|
|
54
|
+
"@hypernym/eslint-config": "^3.6.3",
|
|
55
|
+
"@hypernym/prettier-config": "^3.2.6",
|
|
56
|
+
"@hypernym/tsconfig": "^2.6.2",
|
|
57
|
+
"@types/node": "^24.3.0",
|
|
58
|
+
"eslint": "^9.33.0",
|
|
59
|
+
"prettier": "^3.6.2",
|
|
60
|
+
"typescript": "^5.9.2",
|
|
61
|
+
"vitest": "^3.2.4"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"dev:browser": "vite playgrounds/browser",
|
|
65
|
+
"dev:server": "bun --watch playgrounds/server/main.ts",
|
|
66
|
+
"build": "hyperbundler",
|
|
67
|
+
"test": "vitest -c test/vitest.config.ts",
|
|
68
|
+
"lint": "eslint .",
|
|
69
|
+
"lint:fix": "eslint --fix .",
|
|
70
|
+
"format": "prettier --write ."
|
|
72
71
|
}
|
|
73
|
-
}
|
|
72
|
+
}
|