@hypernym/utils 3.4.5 → 3.4.6

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/README.md CHANGED
@@ -48,7 +48,7 @@ Also, it is possible to download files manually and serve them accordingly.
48
48
 
49
49
  ```html
50
50
  <script type="module">
51
- import { isNull, isString, ... } from 'https://unpkg.com/@hypernym/utils/dist/index.min.mjs'
51
+ import { isNull, isString, ... } from 'https://unpkg.com/@hypernym/utils/dist/index.min.js'
52
52
  </script>
53
53
  ```
54
54
 
@@ -1,5 +1,7 @@
1
- import { Dirent } from 'node:fs';
2
- import { writeFile as writeFile$1 } from 'node:fs/promises';
1
+ import { Dirent } from "node:fs";
2
+ import { writeFile as writeFile$1 } from "node:fs/promises";
3
+
4
+ //#region src/fs/exists.d.ts
3
5
 
4
6
  /**
5
7
  * Checks if the `file` or `directory` exists.
@@ -13,29 +15,30 @@ import { writeFile as writeFile$1 } from 'node:fs/promises';
13
15
  * ```
14
16
  */
15
17
  declare function exists(path: string): Promise<boolean>;
16
-
18
+ //#endregion
19
+ //#region src/fs/read.d.ts
17
20
  type ReadPath = string | URL;
18
21
  type ReadEncodingType = BufferEncoding | null | undefined;
19
22
  type ReadType<T> = T extends BufferEncoding | undefined ? string : T extends null ? Buffer : never;
20
23
  interface ReadOptions<T extends ReadEncodingType> {
21
- /**
22
- * If no encoding is specified, the data is returned as a `Buffer` object. Otherwise, the data will be a string.
23
- *
24
- * @default 'utf-8'
25
- */
26
- encoding?: T;
27
- /**
28
- * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
29
- *
30
- * @default undefined
31
- */
32
- signal?: AbortSignal;
33
- /**
34
- * If a flag is not provided, it defaults to `'r'`.
35
- *
36
- * @default 'r'
37
- */
38
- flag?: number | string;
24
+ /**
25
+ * If no encoding is specified, the data is returned as a `Buffer` object. Otherwise, the data will be a string.
26
+ *
27
+ * @default 'utf-8'
28
+ */
29
+ encoding?: T;
30
+ /**
31
+ * When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
32
+ *
33
+ * @default undefined
34
+ */
35
+ signal?: AbortSignal;
36
+ /**
37
+ * If a flag is not provided, it defaults to `'r'`.
38
+ *
39
+ * @default 'r'
40
+ */
41
+ flag?: number | string;
39
42
  }
40
43
  /**
41
44
  * Reads the entire contents of a `file`.
@@ -49,30 +52,31 @@ interface ReadOptions<T extends ReadEncodingType> {
49
52
  * ```
50
53
  */
51
54
  declare function read<T extends ReadEncodingType = BufferEncoding>(path: ReadPath, options?: ReadOptions<T>): Promise<ReadType<T>>;
52
-
55
+ //#endregion
56
+ //#region src/fs/readdir.d.ts
53
57
  type ReaddirPath = string | URL;
54
58
  type ReaddirEncodingType = BufferEncoding | null | 'buffer' | undefined;
55
59
  type ReaddirWithFileType = true | undefined;
56
60
  type ReaddirType<E, F> = F extends true ? Dirent : E extends BufferEncoding | undefined ? string : E extends null | 'buffer' ? Buffer : never;
57
61
  interface ReaddirOptions<E extends ReaddirEncodingType, F extends ReaddirWithFileType> {
58
- /**
59
- * If the encoding is set to `'buffer'` or `null`, the filenames returned will be passed as `Buffer` objects.
60
- *
61
- * @default 'utf-8'
62
- */
63
- encoding?: E;
64
- /**
65
- * If `withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
66
- *
67
- * @default undefined
68
- */
69
- withFileTypes?: F;
70
- /**
71
- * Reads the directory recursively.
72
- *
73
- * @default true
74
- */
75
- recursive?: boolean;
62
+ /**
63
+ * If the encoding is set to `'buffer'` or `null`, the filenames returned will be passed as `Buffer` objects.
64
+ *
65
+ * @default 'utf-8'
66
+ */
67
+ encoding?: E;
68
+ /**
69
+ * If `withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
70
+ *
71
+ * @default undefined
72
+ */
73
+ withFileTypes?: F;
74
+ /**
75
+ * Reads the directory recursively.
76
+ *
77
+ * @default true
78
+ */
79
+ recursive?: boolean;
76
80
  }
77
81
  /**
78
82
  * Reads the contents of a `directory` recursively.
@@ -86,7 +90,8 @@ interface ReaddirOptions<E extends ReaddirEncodingType, F extends ReaddirWithFil
86
90
  * ```
87
91
  */
88
92
  declare function readdir<E extends ReaddirEncodingType = BufferEncoding, F extends ReaddirWithFileType = undefined>(path: ReaddirPath, options?: ReaddirOptions<E, F>): Promise<ReaddirType<E, F>[]>;
89
-
93
+ //#endregion
94
+ //#region src/fs/write.d.ts
90
95
  type WritePath = string | URL;
91
96
  /**
92
97
  * Writes data to a `file` recursively.
@@ -104,24 +109,25 @@ declare function write(path: WritePath, data: Parameters<typeof writeFile$1>[1],
104
109
  * @deprecated Use `write` instead.
105
110
  */
106
111
  declare const writeFile: typeof write;
107
-
112
+ //#endregion
113
+ //#region src/fs/copy.d.ts
108
114
  type CopySource = string | URL;
109
115
  type CopyDestination = string | URL;
110
116
  interface CopyOptions {
111
- /**
112
- * Copies files or directories recursively.
113
- *
114
- * @default true
115
- */
116
- recursive?: boolean;
117
- /**
118
- * Filters copied `files` or `directories`.
119
- *
120
- * Returns `true` to copy the item, `false` to ignore it.
121
- *
122
- * @default undefined
123
- */
124
- filter?(source: string, destination: string): boolean | Promise<boolean>;
117
+ /**
118
+ * Copies files or directories recursively.
119
+ *
120
+ * @default true
121
+ */
122
+ recursive?: boolean;
123
+ /**
124
+ * Filters copied `files` or `directories`.
125
+ *
126
+ * Returns `true` to copy the item, `false` to ignore it.
127
+ *
128
+ * @default undefined
129
+ */
130
+ filter?(source: string, destination: string): boolean | Promise<boolean>;
125
131
  }
126
132
  /**
127
133
  * Copies `files` or `directories` recursively.
@@ -137,23 +143,24 @@ interface CopyOptions {
137
143
  * ```
138
144
  */
139
145
  declare function copy(source: CopySource | CopySource[], destination: CopyDestination, options?: CopyOptions): Promise<void>;
140
-
146
+ //#endregion
147
+ //#region src/fs/mkdir.d.ts
141
148
  type MakeDirPath = string | URL;
142
149
  interface MakeDirOptions {
143
- /**
144
- * Indicates whether parent folders should be created.
145
- *
146
- * If a folder was created, the path to the first created folder will be returned.
147
- *
148
- * @default true
149
- */
150
- recursive?: boolean;
151
- /**
152
- * A file mode. If a string is passed, it is parsed as an octal integer.
153
- *
154
- * @default 0o777
155
- */
156
- mode?: string | number;
150
+ /**
151
+ * Indicates whether parent folders should be created.
152
+ *
153
+ * If a folder was created, the path to the first created folder will be returned.
154
+ *
155
+ * @default true
156
+ */
157
+ recursive?: boolean;
158
+ /**
159
+ * A file mode. If a string is passed, it is parsed as an octal integer.
160
+ *
161
+ * @default 0o777
162
+ */
163
+ mode?: string | number;
157
164
  }
158
165
  /**
159
166
  * Creates a `directory` recursively.
@@ -169,41 +176,42 @@ interface MakeDirOptions {
169
176
  * ```
170
177
  */
171
178
  declare function mkdir(path: MakeDirPath | MakeDirPath[], options?: MakeDirOptions): Promise<void>;
172
-
179
+ //#endregion
180
+ //#region src/fs/remove.d.ts
173
181
  type RemovePath = string | URL;
174
182
  interface RemoveOptions {
175
- /**
176
- * If `true`, perform a recursive directory removal.
177
- *
178
- * In recursive mode, operations are retried on failure.
179
- *
180
- * @default true
181
- */
182
- recursive?: boolean;
183
- /**
184
- * When `true`, exceptions will be ignored if `path` does not exist.
185
- *
186
- * @default true
187
- */
188
- force?: boolean;
189
- /**
190
- * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
191
- * `EPERM` error is encountered, Node.js will retry the operation with a linear
192
- * backoff wait of `retryDelay` ms longer on each try. This option represents the
193
- * number of retries. This option is ignored if the `recursive` option is not
194
- * `true`.
195
- *
196
- * @default 0
197
- */
198
- maxRetries?: number;
199
- /**
200
- * The amount of time in milliseconds to wait between retries.
201
- *
202
- * This option is ignored if the `recursive` option is not `true`.
203
- *
204
- * @default 100
205
- */
206
- retryDelay?: number;
183
+ /**
184
+ * If `true`, perform a recursive directory removal.
185
+ *
186
+ * In recursive mode, operations are retried on failure.
187
+ *
188
+ * @default true
189
+ */
190
+ recursive?: boolean;
191
+ /**
192
+ * When `true`, exceptions will be ignored if `path` does not exist.
193
+ *
194
+ * @default true
195
+ */
196
+ force?: boolean;
197
+ /**
198
+ * If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or
199
+ * `EPERM` error is encountered, Node.js will retry the operation with a linear
200
+ * backoff wait of `retryDelay` ms longer on each try. This option represents the
201
+ * number of retries. This option is ignored if the `recursive` option is not
202
+ * `true`.
203
+ *
204
+ * @default 0
205
+ */
206
+ maxRetries?: number;
207
+ /**
208
+ * The amount of time in milliseconds to wait between retries.
209
+ *
210
+ * This option is ignored if the `recursive` option is not `true`.
211
+ *
212
+ * @default 100
213
+ */
214
+ retryDelay?: number;
207
215
  }
208
216
  /**
209
217
  * Removes `files` and `directories` recursively.
@@ -219,6 +227,5 @@ interface RemoveOptions {
219
227
  * ```
220
228
  */
221
229
  declare function remove(path: RemovePath | RemovePath[], options?: RemoveOptions): Promise<void>;
222
-
223
- export { copy, exists, mkdir, read, readdir, remove, write, writeFile };
224
- export type { CopyDestination, CopyOptions, CopySource, MakeDirOptions, MakeDirPath, ReadEncodingType, ReadOptions, ReadPath, ReadType, ReaddirEncodingType, ReaddirOptions, ReaddirPath, ReaddirType, ReaddirWithFileType, RemoveOptions, RemovePath, WritePath };
230
+ //#endregion
231
+ export { CopyDestination, CopyOptions, CopySource, MakeDirOptions, MakeDirPath, ReadEncodingType, ReadOptions, ReadPath, ReadType, ReaddirEncodingType, ReaddirOptions, ReaddirPath, ReaddirType, ReaddirWithFileType, RemoveOptions, RemovePath, WritePath, copy, exists, mkdir, read, readdir, remove, write, writeFile };
@@ -0,0 +1,161 @@
1
+ import { access, constants, cp, mkdir as mkdir$1, readFile, readdir as readdir$1, rm, writeFile as writeFile$1 } from "node:fs/promises";
2
+ import { dirname } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { isString, isURL } from "../index.js";
5
+
6
+ //#region src/fs/exists.ts
7
+ /**
8
+ * Checks if the `file` or `directory` exists.
9
+ *
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import { exists } from '../index.js'
14
+ *
15
+ * await exists('dir/file.ts') // true
16
+ * ```
17
+ */
18
+ async function exists(path) {
19
+ return await access(path, constants.F_OK).then(() => true).catch(() => false);
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/fs/read.ts
24
+ /**
25
+ * Reads the entire contents of a `file`.
26
+ *
27
+ * @example
28
+ *
29
+ * ```ts
30
+ * import { read } from '../index.js'
31
+ *
32
+ * await read('dir/subdir/file.ts')
33
+ * ```
34
+ */
35
+ async function read(path, options = {}) {
36
+ const { encoding = "utf-8" } = options;
37
+ return await readFile(path, {
38
+ encoding,
39
+ ...options
40
+ });
41
+ }
42
+
43
+ //#endregion
44
+ //#region src/fs/readdir.ts
45
+ /**
46
+ * Reads the contents of a `directory` recursively.
47
+ *
48
+ * @example
49
+ *
50
+ * ```ts
51
+ * import { readdir } from '../index.js'
52
+ *
53
+ * await readdir('dir/subdir')
54
+ * ```
55
+ */
56
+ async function readdir(path, options = {}) {
57
+ const { encoding = "utf-8", recursive = true } = options;
58
+ return await readdir$1(path, {
59
+ encoding,
60
+ recursive,
61
+ ...options
62
+ });
63
+ }
64
+
65
+ //#endregion
66
+ //#region src/fs/write.ts
67
+ /**
68
+ * Writes data to a `file` recursively.
69
+ *
70
+ * @example
71
+ *
72
+ * ```ts
73
+ * import { write } from '../index.js'
74
+ *
75
+ * await write('dir/subdir/file.ts', `console.log('Hello World!')`)
76
+ * ```
77
+ */
78
+ async function write(path, data, options) {
79
+ await mkdir$1(dirname(isURL(path) ? fileURLToPath(path) : path), { recursive: true });
80
+ await writeFile$1(path, data, options);
81
+ }
82
+ /**
83
+ * @deprecated Use `write` instead.
84
+ */
85
+ const writeFile = write;
86
+
87
+ //#endregion
88
+ //#region src/fs/copy.ts
89
+ /**
90
+ * Copies `files` or `directories` recursively.
91
+ *
92
+ * Accepts a single source or a range of sources.
93
+ *
94
+ * @example
95
+ *
96
+ * ```ts
97
+ * import { copy } from '../index.js'
98
+ *
99
+ * await copy('src/subdir/file.ts', './dist/subdir')
100
+ * ```
101
+ */
102
+ async function copy(source, destination, options = {}) {
103
+ const { recursive = true, filter } = options;
104
+ const sources = isString(source) || isURL(source) ? [source] : source;
105
+ for (const src of sources) await cp(src, destination, {
106
+ recursive,
107
+ filter
108
+ });
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/fs/mkdir.ts
113
+ /**
114
+ * Creates a `directory` recursively.
115
+ *
116
+ * Accepts a single path or a range of paths.
117
+ *
118
+ * @example
119
+ *
120
+ * ```ts
121
+ * import { mkdir } from '../index.js'
122
+ *
123
+ * await mkdir('src/subdir')
124
+ * ```
125
+ */
126
+ async function mkdir(path, options = {}) {
127
+ const { recursive = true, mode } = options;
128
+ const paths = isString(path) || isURL(path) ? [path] : path;
129
+ for (const p of paths) await mkdir$1(p, {
130
+ recursive,
131
+ mode
132
+ });
133
+ }
134
+
135
+ //#endregion
136
+ //#region src/fs/remove.ts
137
+ /**
138
+ * Removes `files` and `directories` recursively.
139
+ *
140
+ * Accepts a single path or a range of paths.
141
+ *
142
+ * @example
143
+ *
144
+ * ```ts
145
+ * import { remove } from '../index.js'
146
+ *
147
+ * await remove('src/subdir/file.ts')
148
+ * ```
149
+ */
150
+ async function remove(path, options = {}) {
151
+ const { recursive = true, force = true } = options;
152
+ const paths = isString(path) || isURL(path) ? [path] : path;
153
+ for (const p of paths) await rm(p, {
154
+ recursive,
155
+ force,
156
+ ...options
157
+ });
158
+ }
159
+
160
+ //#endregion
161
+ export { copy, exists, mkdir, read, readdir, remove, write, writeFile };
@@ -1,3 +1,4 @@
1
+ //#region src/base/index.d.ts
1
2
  /**
2
3
  * An empty arrow function that performs no operation.
3
4
  *
@@ -22,7 +23,8 @@ declare const noop: () => void;
22
23
  * ```
23
24
  */
24
25
  declare const toString: (v: any) => string;
25
-
26
+ //#endregion
27
+ //#region src/types/base/index.d.ts
26
28
  /**
27
29
  * Matches any primitive value.
28
30
  *
@@ -51,7 +53,8 @@ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
51
53
  * ```
52
54
  */
53
55
  type BuiltIn = Primitive | Date | RegExp;
54
-
56
+ //#endregion
57
+ //#region src/is/index.d.ts
55
58
  /**
56
59
  * Checks if the code is running in the browser.
57
60
  *
@@ -458,7 +461,8 @@ declare const isHtmlCollection: (v: any) => v is HTMLCollection;
458
461
  * ```
459
462
  */
460
463
  declare const isHtmlCollectionEmpty: (v: any) => v is HTMLCollection;
461
-
464
+ //#endregion
465
+ //#region src/types/is/index.d.ts
462
466
  /**
463
467
  * Returns a boolean if the given type is a `null`.
464
468
  *
@@ -501,14 +505,15 @@ type IsAny<T> = 0 extends 1 & T ? true : false;
501
505
  * ```
502
506
  */
503
507
  type IsNever<T> = [T] extends [never] ? true : false;
504
-
508
+ //#endregion
509
+ //#region src/types/partial-deep/index.d.ts
505
510
  type PartialOptions = {
506
- /**
507
- * Enables recursive mode for arrays and tuples.
508
- *
509
- * @default true
510
- */
511
- readonly arrays?: boolean;
511
+ /**
512
+ * Enables recursive mode for arrays and tuples.
513
+ *
514
+ * @default true
515
+ */
516
+ readonly arrays?: boolean;
512
517
  };
513
518
  /**
514
519
  * Constructs a type by recursively setting all properties as optional.
@@ -527,21 +532,20 @@ type PartialOptions = {
527
532
  * ```
528
533
  */
529
534
  type PartialDeep<T, Options extends PartialOptions = {
530
- arrays: true;
531
- }> = T extends BuiltIn ? T | undefined : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<Partial<K>, PartialDeep<V, Options>> : T extends Set<infer V> ? Set<PartialDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<PartialDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<Partial<V>> : T extends Promise<infer V> ? Promise<PartialDeep<V, Options>> : T extends (...args: any[]) => unknown ? T | undefined : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<PartialDeep<V, Options>> : Array<PartialDeep<V, Options>> : PartialObjectDeep<T, Options> : T | undefined : PartialObjectDeep<T, Options> : unknown;
535
+ arrays: true;
536
+ }> = T extends BuiltIn ? T | undefined : T extends Map<infer K, infer V> ? Map<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<PartialDeep<K, Options>, PartialDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<Partial<K>, PartialDeep<V, Options>> : T extends Set<infer V> ? Set<PartialDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<PartialDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<Partial<V>> : T extends Promise<infer V> ? Promise<PartialDeep<V, Options>> : T extends ((...args: any[]) => unknown) ? T | undefined : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<PartialDeep<V, Options>> : Array<PartialDeep<V, Options>> : PartialObjectDeep<T, Options> : T | undefined : PartialObjectDeep<T, Options> : unknown;
532
537
  type PartialObjectDeep<T extends object, Options extends PartialOptions = {
533
- arrays: true;
534
- }> = {
535
- [K in keyof T]?: PartialDeep<T[K], Options>;
536
- };
537
-
538
+ arrays: true;
539
+ }> = { [K in keyof T]?: PartialDeep<T[K], Options> };
540
+ //#endregion
541
+ //#region src/types/required-deep/index.d.ts
538
542
  type RequiredOptions = {
539
- /**
540
- * Enables recursive mode for arrays and tuples.
541
- *
542
- * @default true
543
- */
544
- readonly arrays?: boolean;
543
+ /**
544
+ * Enables recursive mode for arrays and tuples.
545
+ *
546
+ * @default true
547
+ */
548
+ readonly arrays?: boolean;
545
549
  };
546
550
  /**
547
551
  * Constructs a type by recursively setting all properties as required.
@@ -560,13 +564,10 @@ type RequiredOptions = {
560
564
  * ```
561
565
  */
562
566
  type RequiredDeep<T, Options extends RequiredOptions = {
563
- arrays: true;
564
- }> = T extends BuiltIn ? Exclude<T, undefined> : T extends Map<infer K, infer V> ? Map<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends Set<infer V> ? Set<RequiredDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<RequiredDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<RequiredDeep<V, Options>> : T extends Promise<infer V> ? Promise<RequiredDeep<V, Options>> : T extends (...args: any[]) => unknown ? Exclude<T, undefined> : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<RequiredDeep<Exclude<V, undefined>, Options>> : Array<RequiredDeep<Exclude<V, undefined>, Options>> : RequiredObjectDeep<T, Options> : Exclude<T, undefined> : RequiredObjectDeep<T, Options> : unknown;
567
+ arrays: true;
568
+ }> = T extends BuiltIn ? Exclude<T, undefined> : T extends Map<infer K, infer V> ? Map<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends ReadonlyMap<infer K, infer V> ? ReadonlyMap<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends WeakMap<infer K, infer V> ? WeakMap<RequiredDeep<K, Options>, RequiredDeep<V, Options>> : T extends Set<infer V> ? Set<RequiredDeep<V, Options>> : T extends ReadonlySet<infer V> ? ReadonlySet<RequiredDeep<V, Options>> : T extends WeakSet<infer V> ? WeakSet<RequiredDeep<V, Options>> : T extends Promise<infer V> ? Promise<RequiredDeep<V, Options>> : T extends ((...args: any[]) => unknown) ? Exclude<T, undefined> : T extends object ? T extends ReadonlyArray<infer V> ? Options['arrays'] extends true ? V[] extends T ? readonly V[] extends T ? ReadonlyArray<RequiredDeep<Exclude<V, undefined>, Options>> : Array<RequiredDeep<Exclude<V, undefined>, Options>> : RequiredObjectDeep<T, Options> : Exclude<T, undefined> : RequiredObjectDeep<T, Options> : unknown;
565
569
  type RequiredObjectDeep<T extends object, Options extends RequiredOptions = {
566
- arrays: true;
567
- }> = {
568
- [K in keyof T]-?: RequiredDeep<T[K], Options>;
569
- };
570
-
571
- export { isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
572
- export type { BuiltIn, IsAny, IsNever, IsNull, PartialDeep, Primitive, RequiredDeep };
570
+ arrays: true;
571
+ }> = { [K in keyof T]-?: RequiredDeep<T[K], Options> };
572
+ //#endregion
573
+ export { BuiltIn, IsAny, IsNever, IsNull, PartialDeep, Primitive, RequiredDeep, isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
@@ -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){let t=()=>{},n=e=>Object.prototype.toString.call(e).slice(8,-1),r=typeof window<`u`,i=e=>e===null,a=e=>e===void 0,o=e=>typeof e==`string`,s=e=>o(e)&&e.trim().length===0,c=e=>typeof e==`boolean`,l=e=>e===!0,u=e=>e===!1,d=e=>typeof e==`number`&&!isNaN(e),f=e=>Array.isArray(e),p=e=>f(e)&&e.length===0,m=e=>n(e)===`Object`,h=e=>m(e)&&Object.keys(e).length===0,g=e=>e instanceof Function,_=e=>typeof e==`number`&&isNaN(e),v=e=>e instanceof RegExp,y=e=>e instanceof Map,b=e=>e instanceof WeakMap,x=e=>e instanceof Set,S=e=>e instanceof WeakSet,C=e=>n(e)===`Symbol`,w=e=>e instanceof Date&&!isNaN(e.valueOf()),T=e=>typeof e==`bigint`,E=e=>e===1/0||e===-1/0,D=e=>e instanceof URL,O=e=>e instanceof Error,k=e=>o(e)||d(e)||T(e)||c(e)||C(e)||i(e)||a(e),A=e=>e instanceof Element,j=e=>e instanceof HTMLElement,M=e=>e instanceof SVGElement,N=e=>e instanceof NodeList,P=e=>N(e)&&e.length===0,F=e=>e instanceof HTMLCollection;return e.isArray=f,e.isArrayEmpty=p,e.isBigInt=T,e.isBoolean=c,e.isBrowser=r,e.isDate=w,e.isElement=A,e.isError=O,e.isFalse=u,e.isFunction=g,e.isHtmlCollection=F,e.isHtmlCollectionEmpty=e=>F(e)&&e.length===0,e.isHtmlElement=j,e.isInfinity=E,e.isMap=y,e.isNaNValue=_,e.isNodeList=N,e.isNodeListEmpty=P,e.isNull=i,e.isNumber=d,e.isObject=m,e.isObjectEmpty=h,e.isPrimitive=k,e.isRegExp=v,e.isSet=x,e.isString=o,e.isStringEmpty=s,e.isSvgElement=M,e.isSymbol=C,e.isTrue=l,e.isURL=D,e.isUndefined=a,e.isWeakMap=b,e.isWeakSet=S,e.noop=t,e.toString=n,e})({});
package/dist/index.js ADDED
@@ -0,0 +1,437 @@
1
+ //#region src/base/index.ts
2
+ /**
3
+ * An empty arrow function that performs no operation.
4
+ *
5
+ * @example
6
+ *
7
+ * ```ts
8
+ * import { noop } from '@hypernym/utils'
9
+ *
10
+ * noop()
11
+ * ```
12
+ */
13
+ const noop = () => {};
14
+ /**
15
+ * Returns a string representing the object.
16
+ *
17
+ * @example
18
+ *
19
+ * ```ts
20
+ * import { toString } from '@hypernym/utils'
21
+ *
22
+ * toString({}) // 'Object'
23
+ * ```
24
+ */
25
+ const toString = (v) => Object.prototype.toString.call(v).slice(8, -1);
26
+
27
+ //#endregion
28
+ //#region src/is/index.ts
29
+ /**
30
+ * Checks if the code is running in the browser.
31
+ *
32
+ * @example
33
+ *
34
+ * ```ts
35
+ * import { isBrowser } from '@hypernym/utils'
36
+ *
37
+ * isBrowser // true
38
+ * ```
39
+ */
40
+ const isBrowser = typeof window !== "undefined";
41
+ /**
42
+ * Returns a boolean if the given value is a `null`.
43
+ *
44
+ * @example
45
+ *
46
+ * ```ts
47
+ * import { isNull } from '@hypernym/utils'
48
+ *
49
+ * isNull(null) // true
50
+ * ```
51
+ */
52
+ const isNull = (v) => v === null;
53
+ /**
54
+ * Returns a boolean if the given value is a `undefined`.
55
+ *
56
+ * @example
57
+ *
58
+ * ```ts
59
+ * import { isUndefined } from '@hypernym/utils'
60
+ *
61
+ * isUndefined(undefined) // true
62
+ * ```
63
+ */
64
+ const isUndefined = (v) => typeof v === "undefined";
65
+ /**
66
+ * Returns a boolean if the given value is a `string`.
67
+ *
68
+ * @example
69
+ *
70
+ * ```ts
71
+ * import { isString } from '@hypernym/utils'
72
+ *
73
+ * isString('@hypernym/utils') // true
74
+ * ```
75
+ */
76
+ const isString = (v) => typeof v === "string";
77
+ /**
78
+ * Returns a boolean if the given value is an empty `string`.
79
+ *
80
+ * @example
81
+ *
82
+ * ```ts
83
+ * import { isStringEmpty } from '@hypernym/utils'
84
+ *
85
+ * isStringEmpty('') // true
86
+ * ```
87
+ */
88
+ const isStringEmpty = (v) => isString(v) && v.trim().length === 0;
89
+ /**
90
+ * Returns a boolean if the given value is a `boolean`.
91
+ *
92
+ * @example
93
+ *
94
+ * ```ts
95
+ * import { isBoolean } from '@hypernym/utils'
96
+ *
97
+ * isBoolean(true) // true
98
+ * ```
99
+ */
100
+ const isBoolean = (v) => typeof v === "boolean";
101
+ /**
102
+ * Returns a boolean if the given value is a `true`.
103
+ *
104
+ * @example
105
+ *
106
+ * ```ts
107
+ * import { isTrue } from '@hypernym/utils'
108
+ *
109
+ * isTrue(true) // true
110
+ * ```
111
+ */
112
+ const isTrue = (v) => v === true;
113
+ /**
114
+ * Returns a boolean if the given value is a `false`.
115
+ *
116
+ * @example
117
+ *
118
+ * ```ts
119
+ * import { isFalse } from '@hypernym/utils'
120
+ *
121
+ * isFalse(false) // true
122
+ * ```
123
+ */
124
+ const isFalse = (v) => v === false;
125
+ /**
126
+ * Returns a boolean if the given value is a `number`.
127
+ *
128
+ * @example
129
+ *
130
+ * ```ts
131
+ * import { isNumber } from '@hypernym/utils'
132
+ *
133
+ * isNumber(33) // true
134
+ * ```
135
+ */
136
+ const isNumber = (v) => typeof v === "number" && !isNaN(v);
137
+ /**
138
+ * Returns a boolean if the given value is a `array`.
139
+ *
140
+ * @example
141
+ *
142
+ * ```ts
143
+ * import { isArray } from '@hypernym/utils'
144
+ *
145
+ * isArray([]) // true
146
+ * ```
147
+ */
148
+ const isArray = (v) => Array.isArray(v);
149
+ /**
150
+ * Returns a boolean if the given value is an empty `array`.
151
+ *
152
+ * @example
153
+ *
154
+ * ```ts
155
+ * import { isArrayEmpty } from '@hypernym/utils'
156
+ *
157
+ * isArrayEmpty([]) // true
158
+ * ```
159
+ */
160
+ const isArrayEmpty = (v) => isArray(v) && v.length === 0;
161
+ /**
162
+ * Returns a boolean if the given value is a `object`.
163
+ *
164
+ * @example
165
+ *
166
+ * ```ts
167
+ * import { isObject } from '@hypernym/utils'
168
+ *
169
+ * isObject({}) // true
170
+ * ```
171
+ */
172
+ const isObject = (v) => toString(v) === "Object";
173
+ /**
174
+ * Returns a boolean if the given value is an empty `object`.
175
+ *
176
+ * @example
177
+ *
178
+ * ```ts
179
+ * import { isObjectEmpty } from '@hypernym/utils'
180
+ *
181
+ * isObjectEmpty({}) // true
182
+ * ```
183
+ */
184
+ const isObjectEmpty = (v) => isObject(v) && Object.keys(v).length === 0;
185
+ /**
186
+ * Returns a boolean if the given value is a `Function`.
187
+ *
188
+ * @example
189
+ *
190
+ * ```ts
191
+ * import { isFunction } from '@hypernym/utils'
192
+ *
193
+ * isFunction(() => {}) // true
194
+ * ```
195
+ */
196
+ const isFunction = (v) => v instanceof Function;
197
+ /**
198
+ * Returns a boolean if the given value is a `NaN`.
199
+ *
200
+ * @example
201
+ *
202
+ * ```ts
203
+ * import { isNaNValue } from '@hypernym/utils'
204
+ *
205
+ * isNaNValue(NaN) // true
206
+ * ```
207
+ */
208
+ const isNaNValue = (v) => typeof v === "number" && isNaN(v);
209
+ /**
210
+ * Returns a boolean if the given value is a `RegExp`.
211
+ *
212
+ * @example
213
+ *
214
+ * ```ts
215
+ * import { isRegExp } from '@hypernym/utils'
216
+ *
217
+ * isRegExp(/^hypernym/) // true
218
+ * ```
219
+ */
220
+ const isRegExp = (v) => v instanceof RegExp;
221
+ /**
222
+ * Returns a boolean if the given value is a `Map`.
223
+ *
224
+ * @example
225
+ *
226
+ * ```ts
227
+ * import { isMap } from '@hypernym/utils'
228
+ *
229
+ * isMap(new Map()) // true
230
+ * ```
231
+ */
232
+ const isMap = (v) => v instanceof Map;
233
+ /**
234
+ * Returns a boolean if the given value is a `WeakMap`.
235
+ *
236
+ * @example
237
+ *
238
+ * ```ts
239
+ * import { isWeakMap } from '@hypernym/utils'
240
+ *
241
+ * isWeakMap(new WeakMap()) // true
242
+ * ```
243
+ */
244
+ const isWeakMap = (v) => v instanceof WeakMap;
245
+ /**
246
+ * Returns a boolean if the given value is a `Set`.
247
+ *
248
+ * @example
249
+ *
250
+ * ```ts
251
+ * import { isSet } from '@hypernym/utils'
252
+ *
253
+ * isSet(new Set()) // true
254
+ * ```
255
+ */
256
+ const isSet = (v) => v instanceof Set;
257
+ /**
258
+ * Returns a boolean if the given value is a `WeakSet`.
259
+ *
260
+ * @example
261
+ *
262
+ * ```ts
263
+ * import { isWeakSet } from '@hypernym/utils'
264
+ *
265
+ * isWeakSet(new WeakSet()) // true
266
+ * ```
267
+ */
268
+ const isWeakSet = (v) => v instanceof WeakSet;
269
+ /**
270
+ * Returns a boolean if the given value is a `symbol`.
271
+ *
272
+ * @example
273
+ *
274
+ * ```ts
275
+ * import { isSymbol } from '@hypernym/utils'
276
+ *
277
+ * isSymbol(Symboly('hypernym')) // true
278
+ * ```
279
+ */
280
+ const isSymbol = (v) => toString(v) === "Symbol";
281
+ /**
282
+ * Returns a boolean if the given value is a `Date`.
283
+ *
284
+ * @example
285
+ *
286
+ * ```ts
287
+ * import { isDate } from '@hypernym/utils'
288
+ *
289
+ * isDate(new Date()) // true
290
+ * ```
291
+ */
292
+ const isDate = (v) => v instanceof Date && !isNaN(v.valueOf());
293
+ /**
294
+ * Returns a boolean if the given value is a `bigint`.
295
+ *
296
+ * @example
297
+ *
298
+ * ```ts
299
+ * import { isBigInt } from '@hypernym/utils'
300
+ *
301
+ * isBigInt(1n) // true
302
+ * ```
303
+ */
304
+ const isBigInt = (v) => typeof v === "bigint";
305
+ /**
306
+ * Returns a boolean if the given value is a `Infinity`.
307
+ *
308
+ * @example
309
+ *
310
+ * ```ts
311
+ * import { isInfinity } from '@hypernym/utils'
312
+ *
313
+ * isInfinity(Infinity) // true
314
+ * ```
315
+ */
316
+ const isInfinity = (v) => v === Infinity || v === -Infinity;
317
+ /**
318
+ * Returns a boolean if the given value is a `URL`.
319
+ *
320
+ * @example
321
+ *
322
+ * ```ts
323
+ * import { isURL } from '@hypernym/utils'
324
+ *
325
+ * isURL(new URL('https://localhost:3000')) // true
326
+ * ```
327
+ */
328
+ const isURL = (v) => v instanceof URL;
329
+ /**
330
+ * Returns a boolean if the given value is a `Error`.
331
+ *
332
+ * @example
333
+ *
334
+ * ```ts
335
+ * import { isError } from '@hypernym/utils'
336
+ *
337
+ * isError(new Error()) // true
338
+ * ```
339
+ */
340
+ const isError = (v) => v instanceof Error;
341
+ /**
342
+ * Returns a boolean if the given value is a `Primitive`.
343
+ *
344
+ * @example
345
+ *
346
+ * ```ts
347
+ * import { isPrimitive } from '@hypernym/utils'
348
+ *
349
+ * isPrimitive(true) // true
350
+ * ```
351
+ */
352
+ const isPrimitive = (v) => isString(v) || isNumber(v) || isBigInt(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
353
+ /**
354
+ * Returns a boolean if the given value is a `Element`.
355
+ *
356
+ * @example
357
+ *
358
+ * ```ts
359
+ * import { isElement } from '@hypernym/utils'
360
+ *
361
+ * isElement(el) // true
362
+ * ```
363
+ */
364
+ const isElement = (v) => v instanceof Element;
365
+ /**
366
+ * Returns a boolean if the given value is a `HTMLElement`.
367
+ *
368
+ * @example
369
+ *
370
+ * ```ts
371
+ * import { isHtmlElement } from '@hypernym/utils'
372
+ *
373
+ * isHtmlElement(htmlEl) // true
374
+ * ```
375
+ */
376
+ const isHtmlElement = (v) => v instanceof HTMLElement;
377
+ /**
378
+ * Returns a boolean if the given value is a `SVGElement`.
379
+ *
380
+ * @example
381
+ *
382
+ * ```ts
383
+ * import { isSvgElement } from '@hypernym/utils'
384
+ *
385
+ * isSvgElement(svgEl) // true
386
+ * ```
387
+ */
388
+ const isSvgElement = (v) => v instanceof SVGElement;
389
+ /**
390
+ * Returns a boolean if the given value is a `NodeList`.
391
+ *
392
+ * @example
393
+ *
394
+ * ```ts
395
+ * import { isNodeList } from '@hypernym/utils'
396
+ *
397
+ * isNodeList(document.querySelectorAll('div')) // true
398
+ * ```
399
+ */
400
+ const isNodeList = (v) => v instanceof NodeList;
401
+ /**
402
+ * Returns a boolean if the given value is an empty `NodeList`.
403
+ *
404
+ * @example
405
+ *
406
+ * ```ts
407
+ * import { isNodeListEmpty } from '@hypernym/utils'
408
+ *
409
+ * isNodeListEmpty(document.querySelectorAll('divs')) // true
410
+ * ```
411
+ */
412
+ const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
413
+ /**
414
+ * Returns a boolean if the given value is a `HTMLCollection`.
415
+ *
416
+ * @example
417
+ *
418
+ * ```ts
419
+ * import { isHtmlCollection } from '@hypernym/utils'
420
+ *
421
+ * isHtmlCollection(document.getElementsByClassName('el')) // true
422
+ * ```
423
+ */
424
+ const isHtmlCollection = (v) => v instanceof HTMLCollection;
425
+ /**
426
+ * Returns a boolean if the given value is an empty `HTMLCollection`.
427
+ *
428
+ * ```ts
429
+ * import { isHtmlCollectionEmpty } from '@hypernym/utils'
430
+ *
431
+ * isHtmlCollectionEmpty(document.getElementsByClassName('els')) // true
432
+ * ```
433
+ */
434
+ const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
435
+
436
+ //#endregion
437
+ export { isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };
@@ -0,0 +1 @@
1
+ const e=()=>{},t=e=>Object.prototype.toString.call(e).slice(8,-1),n=typeof window<`u`,r=e=>e===null,i=e=>e===void 0,a=e=>typeof e==`string`,o=e=>a(e)&&e.trim().length===0,s=e=>typeof e==`boolean`,c=e=>e===!0,l=e=>e===!1,u=e=>typeof e==`number`&&!isNaN(e),d=e=>Array.isArray(e),f=e=>d(e)&&e.length===0,p=e=>t(e)===`Object`,m=e=>p(e)&&Object.keys(e).length===0,h=e=>e instanceof Function,g=e=>typeof e==`number`&&isNaN(e),_=e=>e instanceof RegExp,v=e=>e instanceof Map,y=e=>e instanceof WeakMap,b=e=>e instanceof Set,x=e=>e instanceof WeakSet,S=e=>t(e)===`Symbol`,C=e=>e instanceof Date&&!isNaN(e.valueOf()),w=e=>typeof e==`bigint`,T=e=>e===1/0||e===-1/0,E=e=>e instanceof URL,D=e=>e instanceof Error,O=e=>a(e)||u(e)||w(e)||s(e)||S(e)||r(e)||i(e),k=e=>e instanceof Element,A=e=>e instanceof HTMLElement,j=e=>e instanceof SVGElement,M=e=>e instanceof NodeList,N=e=>M(e)&&e.length===0,P=e=>e instanceof HTMLCollection,F=e=>P(e)&&e.length===0;export{d as isArray,f as isArrayEmpty,w as isBigInt,s as isBoolean,n as isBrowser,C as isDate,k as isElement,D as isError,l as isFalse,h as isFunction,P as isHtmlCollection,F as isHtmlCollectionEmpty,A as isHtmlElement,T as isInfinity,v as isMap,g as isNaNValue,M as isNodeList,N as isNodeListEmpty,r as isNull,u as isNumber,p as isObject,m as isObjectEmpty,O as isPrimitive,_ as isRegExp,b as isSet,a as isString,o as isStringEmpty,j as isSvgElement,S as isSymbol,c as isTrue,E as isURL,i as isUndefined,y as isWeakMap,x as isWeakSet,e as noop,t as toString};
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){let t=()=>{},n=e=>Object.prototype.toString.call(e).slice(8,-1),r=typeof window<`u`,i=e=>e===null,a=e=>e===void 0,o=e=>typeof e==`string`,s=e=>o(e)&&e.trim().length===0,c=e=>typeof e==`boolean`,l=e=>e===!0,u=e=>e===!1,d=e=>typeof e==`number`&&!isNaN(e),f=e=>Array.isArray(e),p=e=>f(e)&&e.length===0,m=e=>n(e)===`Object`,h=e=>m(e)&&Object.keys(e).length===0,g=e=>e instanceof Function,_=e=>typeof e==`number`&&isNaN(e),v=e=>e instanceof RegExp,y=e=>e instanceof Map,b=e=>e instanceof WeakMap,x=e=>e instanceof Set,S=e=>e instanceof WeakSet,C=e=>n(e)===`Symbol`,w=e=>e instanceof Date&&!isNaN(e.valueOf()),T=e=>typeof e==`bigint`,E=e=>e===1/0||e===-1/0,D=e=>e instanceof URL,O=e=>e instanceof Error,k=e=>o(e)||d(e)||T(e)||c(e)||C(e)||i(e)||a(e),A=e=>e instanceof Element,j=e=>e instanceof HTMLElement,M=e=>e instanceof SVGElement,N=e=>e instanceof NodeList,P=e=>N(e)&&e.length===0,F=e=>e instanceof HTMLCollection;e.isArray=f,e.isArrayEmpty=p,e.isBigInt=T,e.isBoolean=c,e.isBrowser=r,e.isDate=w,e.isElement=A,e.isError=O,e.isFalse=u,e.isFunction=g,e.isHtmlCollection=F,e.isHtmlCollectionEmpty=e=>F(e)&&e.length===0,e.isHtmlElement=j,e.isInfinity=E,e.isMap=y,e.isNaNValue=_,e.isNodeList=N,e.isNodeListEmpty=P,e.isNull=i,e.isNumber=d,e.isObject=m,e.isObjectEmpty=h,e.isPrimitive=k,e.isRegExp=v,e.isSet=x,e.isString=o,e.isStringEmpty=s,e.isSvgElement=M,e.isSymbol=C,e.isTrue=l,e.isURL=D,e.isUndefined=a,e.isWeakMap=b,e.isWeakSet=S,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.5",
3
+ "version": "3.4.6",
4
4
  "author": "Hypernym Studio",
5
5
  "description": "A collection of reusable utilities.",
6
6
  "license": "MIT",
@@ -13,12 +13,12 @@
13
13
  "type": "module",
14
14
  "exports": {
15
15
  ".": {
16
- "types": "./dist/index.d.mts",
17
- "import": "./dist/index.mjs"
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
18
  },
19
19
  "./fs": {
20
- "types": "./dist/fs/index.d.mts",
21
- "import": "./dist/fs/index.mjs"
20
+ "types": "./dist/fs/index.d.ts",
21
+ "import": "./dist/fs/index.js"
22
22
  }
23
23
  },
24
24
  "files": [
@@ -50,14 +50,14 @@
50
50
  }
51
51
  },
52
52
  "devDependencies": {
53
- "@hypernym/bundler": "^0.14.4",
54
- "@hypernym/eslint-config": "^3.6.3",
55
- "@hypernym/prettier-config": "^3.2.6",
53
+ "@hypernym/bundler": "^0.30.4",
54
+ "@hypernym/eslint-config": "^3.6.4",
55
+ "@hypernym/prettier-config": "^3.2.7",
56
56
  "@hypernym/tsconfig": "^2.6.2",
57
- "@types/node": "^24.3.0",
58
- "eslint": "^9.33.0",
57
+ "@types/node": "^24.7.2",
58
+ "eslint": "^9.37.0",
59
59
  "prettier": "^3.6.2",
60
- "typescript": "^5.9.2",
60
+ "typescript": "^5.9.3",
61
61
  "vitest": "^3.2.4"
62
62
  },
63
63
  "scripts": {
package/dist/fs/index.mjs DELETED
@@ -1,59 +0,0 @@
1
- import { access, constants, readFile, readdir as readdir$1, mkdir as mkdir$1, writeFile as writeFile$1, cp, rm } from 'node:fs/promises';
2
- import { dirname } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { isURL, isString } from '../index.mjs';
5
-
6
- async function exists(path) {
7
- return await access(path, constants.F_OK).then(() => true).catch(() => false);
8
- }
9
-
10
- async function read(path, options = {}) {
11
- const { encoding = "utf-8" } = options;
12
- return await readFile(path, { encoding, ...options });
13
- }
14
-
15
- async function readdir(path, options = {}) {
16
- const { encoding = "utf-8", recursive = true } = options;
17
- return await readdir$1(path, {
18
- encoding,
19
- recursive,
20
- ...options
21
- });
22
- }
23
-
24
- async function write(path, data, options) {
25
- await mkdir$1(dirname(isURL(path) ? fileURLToPath(path) : path), {
26
- recursive: true
27
- });
28
- await writeFile$1(path, data, options);
29
- }
30
- const writeFile = write;
31
-
32
- async function copy(source, destination, options = {}) {
33
- const { recursive = true, filter } = options;
34
- const sources = isString(source) || isURL(source) ? [source] : source;
35
- for (const src of sources) {
36
- await cp(src, destination, {
37
- recursive,
38
- filter
39
- });
40
- }
41
- }
42
-
43
- async function mkdir(path, options = {}) {
44
- const { recursive = true, mode } = options;
45
- const paths = isString(path) || isURL(path) ? [path] : path;
46
- for (const p of paths) {
47
- await mkdir$1(p, { recursive, mode });
48
- }
49
- }
50
-
51
- async function remove(path, options = {}) {
52
- const { recursive = true, force = true } = options;
53
- const paths = isString(path) || isURL(path) ? [path] : path;
54
- for (const p of paths) {
55
- await rm(p, { recursive, force, ...options });
56
- }
57
- }
58
-
59
- export { copy, exists, mkdir, read, readdir, remove, write, writeFile };
@@ -1 +0,0 @@
1
- const y=()=>{},i=e=>Object.prototype.toString.call(e).slice(8,-1),g=typeof window<"u",s=e=>e===null,n=e=>typeof e>"u",t=e=>typeof e=="string",E=e=>t(e)&&e.trim().length===0,o=e=>typeof e=="boolean",u=e=>e===!0,N=e=>e===!1,a=e=>typeof e=="number"&&!isNaN(e),l=e=>Array.isArray(e),b=e=>l(e)&&e.length===0,r=e=>i(e)==="Object",S=e=>r(e)&&Object.keys(e).length===0,L=e=>e instanceof Function,d=e=>typeof e=="number"&&isNaN(e),M=e=>e instanceof RegExp,O=e=>e instanceof Map,h=e=>e instanceof WeakMap,j=e=>e instanceof Set,k=e=>e instanceof WeakSet,c=e=>i(e)==="Symbol",H=e=>e instanceof Date&&!isNaN(e.valueOf()),f=e=>typeof e=="bigint",A=e=>e===1/0||e===-1/0,R=e=>e instanceof URL,W=e=>e instanceof Error,v=e=>t(e)||a(e)||f(e)||o(e)||c(e)||s(e)||n(e),w=e=>e instanceof Element,x=e=>e instanceof HTMLElement,B=e=>e instanceof SVGElement,p=e=>e instanceof NodeList,C=e=>p(e)&&e.length===0,m=e=>e instanceof HTMLCollection,F=e=>m(e)&&e.length===0;export{l as isArray,b as isArrayEmpty,f as isBigInt,o as isBoolean,g as isBrowser,H as isDate,w as isElement,W as isError,N as isFalse,L as isFunction,m as isHtmlCollection,F as isHtmlCollectionEmpty,x as isHtmlElement,A as isInfinity,O as isMap,d as isNaNValue,p as isNodeList,C as isNodeListEmpty,s as isNull,a as isNumber,r as isObject,S as isObjectEmpty,v as isPrimitive,M as isRegExp,j as isSet,t as isString,E as isStringEmpty,B as isSvgElement,c as isSymbol,u as isTrue,R as isURL,n as isUndefined,h as isWeakMap,k as isWeakSet,y as noop,i as toString};
package/dist/index.mjs DELETED
@@ -1,40 +0,0 @@
1
- const noop = () => {
2
- };
3
- const toString = (v) => Object.prototype.toString.call(v).slice(8, -1);
4
-
5
- const isBrowser = typeof window !== "undefined";
6
- const isNull = (v) => v === null;
7
- const isUndefined = (v) => typeof v === "undefined";
8
- const isString = (v) => typeof v === "string";
9
- const isStringEmpty = (v) => isString(v) && v.trim().length === 0;
10
- const isBoolean = (v) => typeof v === "boolean";
11
- const isTrue = (v) => v === true;
12
- const isFalse = (v) => v === false;
13
- const isNumber = (v) => typeof v === "number" && !isNaN(v);
14
- const isArray = (v) => Array.isArray(v);
15
- const isArrayEmpty = (v) => isArray(v) && v.length === 0;
16
- const isObject = (v) => toString(v) === "Object";
17
- const isObjectEmpty = (v) => isObject(v) && Object.keys(v).length === 0;
18
- const isFunction = (v) => v instanceof Function;
19
- const isNaNValue = (v) => typeof v === "number" && isNaN(v);
20
- const isRegExp = (v) => v instanceof RegExp;
21
- const isMap = (v) => v instanceof Map;
22
- const isWeakMap = (v) => v instanceof WeakMap;
23
- const isSet = (v) => v instanceof Set;
24
- const isWeakSet = (v) => v instanceof WeakSet;
25
- const isSymbol = (v) => toString(v) === "Symbol";
26
- const isDate = (v) => v instanceof Date && !isNaN(v.valueOf());
27
- const isBigInt = (v) => typeof v === "bigint";
28
- const isInfinity = (v) => v === Infinity || v === -Infinity;
29
- const isURL = (v) => v instanceof URL;
30
- const isError = (v) => v instanceof Error;
31
- const isPrimitive = (v) => isString(v) || isNumber(v) || isBigInt(v) || isBoolean(v) || isSymbol(v) || isNull(v) || isUndefined(v);
32
- const isElement = (v) => v instanceof Element;
33
- const isHtmlElement = (v) => v instanceof HTMLElement;
34
- const isSvgElement = (v) => v instanceof SVGElement;
35
- const isNodeList = (v) => v instanceof NodeList;
36
- const isNodeListEmpty = (v) => isNodeList(v) && v.length === 0;
37
- const isHtmlCollection = (v) => v instanceof HTMLCollection;
38
- const isHtmlCollectionEmpty = (v) => isHtmlCollection(v) && v.length === 0;
39
-
40
- export { isArray, isArrayEmpty, isBigInt, isBoolean, isBrowser, isDate, isElement, isError, isFalse, isFunction, isHtmlCollection, isHtmlCollectionEmpty, isHtmlElement, isInfinity, isMap, isNaNValue, isNodeList, isNodeListEmpty, isNull, isNumber, isObject, isObjectEmpty, isPrimitive, isRegExp, isSet, isString, isStringEmpty, isSvgElement, isSymbol, isTrue, isURL, isUndefined, isWeakMap, isWeakSet, noop, toString };