tiny-essentials 1.28.2 β†’ 1.28.4

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.
@@ -31,7 +31,9 @@ exports.readJsonBlob = html.readJsonBlob;
31
31
  exports.saveJsonFile = html.saveJsonFile;
32
32
  exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
33
33
  exports.extendObjType = objFilter.extendObjType;
34
+ exports.isObjType = objFilter.isObjType;
34
35
  exports.objType = objFilter.objType;
36
+ exports.objTypeName = objFilter.objTypeName;
35
37
  exports.reorderObjTypeOrder = objFilter.reorderObjTypeOrder;
36
38
  exports.countObj = objChecker.countObj;
37
39
  exports.isJsonObject = objChecker.isJsonObject;
@@ -1,12 +1,12 @@
1
1
  import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks } from './array.mjs';
2
2
  import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './clock.mjs';
3
3
  import { readJsonBlob, saveJsonFile, fetchJson, installWindowHiddenScript, readFileBlob, readBase64Blob, fetchText } from './html.mjs';
4
- import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType } from './objFilter.mjs';
4
+ import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, isObjType, objTypeName } from './objFilter.mjs';
5
5
  import { countObj, isJsonObject } from './objChecker.mjs';
6
6
  import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange } from './fullScreen.mjs';
7
7
  import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree } from './simpleMath.mjs';
8
8
  import { addAiMarkerShortcut, diffStrings, diffObjList, safeTextTrim, toTitleCase, toTitleCaseLowerFirst, asyncReplace } from './text.mjs';
9
9
  import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails } from './collision.mjs';
10
10
  import { extractMediaId3Tags, parseMediaMetadata, valMediaContentMetadata, valMediaContentMetadataPartial } from './mediaContent.mjs';
11
- export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
11
+ export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, isObjType, objTypeName, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
12
12
  //# sourceMappingURL=index.d.mts.map
@@ -1,11 +1,11 @@
1
1
  import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks } from './array.mjs';
2
2
  import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, } from './clock.mjs';
3
3
  import { readJsonBlob, saveJsonFile, fetchJson, installWindowHiddenScript, readFileBlob, readBase64Blob, fetchText, } from './html.mjs';
4
- import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType } from './objFilter.mjs';
4
+ import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, isObjType, objTypeName, } from './objFilter.mjs';
5
5
  import { countObj, isJsonObject } from './objChecker.mjs';
6
6
  import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './fullScreen.mjs';
7
7
  import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree, } from './simpleMath.mjs';
8
8
  import { addAiMarkerShortcut, diffStrings, diffObjList, safeTextTrim, toTitleCase, toTitleCaseLowerFirst, asyncReplace, } from './text.mjs';
9
9
  import { areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, } from './collision.mjs';
10
10
  import { extractMediaId3Tags, parseMediaMetadata, valMediaContentMetadata, valMediaContentMetadataPartial, } from './mediaContent.mjs';
11
- export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
11
+ export { multiplyArrayBlocks, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, diffStrings, diffObjList, diffArrayList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, isObjType, objTypeName, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
@@ -2,6 +2,8 @@
2
2
 
3
3
  var objChecker = require('./objChecker.cjs');
4
4
 
5
+ // @ts-nocheck
6
+
5
7
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
6
8
 
7
9
  /**
@@ -144,9 +146,6 @@ function cloneObjTypeOrder() {
144
146
  /**
145
147
  * Returns the detected type name of a given value based on predefined type validators.
146
148
  *
147
- * This function uses `getType` with a predefined `typeValidator` to determine or compare types safely.
148
- * in the specified `typeValidator.order`. The first matching type is returned.
149
- *
150
149
  * If `val` is `null`, it immediately returns `'null'`.
151
150
  * If no match is found, it returns `'unknown'`.
152
151
  *
@@ -154,12 +153,11 @@ function cloneObjTypeOrder() {
154
153
  * @returns {string} - The type name of the value (e.g., "array", "date", "map"), or "unknown" if no match is found.
155
154
  *
156
155
  * @example
157
- * getType([]); // "array"
158
- * getType(null); // "null"
159
- * getType(new Set()); // "set"
160
- * getType(() => {}); // "unknown"
156
+ * objTypeName([]); // "array"
157
+ * objTypeName(null); // "null"
158
+ * objTypeName(new Set()); // "set"
161
159
  */
162
- const getType = (val) => {
160
+ const objTypeName = (val) => {
163
161
  if (val === null) return 'null';
164
162
  // @ts-ignore
165
163
  for (const name of typeValidator.order) {
@@ -170,9 +168,22 @@ const getType = (val) => {
170
168
  return 'unknown';
171
169
  };
172
170
 
171
+ /**
172
+ * Checks the type of a given object.
173
+ *
174
+ * @param {*} obj - The object to check.
175
+ * @param {string} [type] - Checks whether the object matches this type (e.g., "object", "array", "string").
176
+ * @returns {boolean} - Returns `true` if the type matches.
177
+ */
178
+ function isObjType(obj, type) {
179
+ if (typeof type !== 'string') throw new TypeError("Argument 'type' must be a string.");
180
+ return objTypeName(obj) === type.toLowerCase();
181
+ }
182
+
173
183
  /**
174
184
  * Checks the type of a given object or returns its type as a string.
175
185
  *
186
+ * @deprecated Use {@link isObjType} or {@link objTypeName} instead.
176
187
  * @param {*} obj - The object to check or identify.
177
188
  * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
178
189
  * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
@@ -190,7 +201,7 @@ function objType(obj, type) {
190
201
  throw new TypeError("Argument 'type' must be a string.");
191
202
  }
192
203
 
193
- const result = getType(obj);
204
+ const result = objTypeName(obj);
194
205
  if (typeof type === 'string') return result === type.toLowerCase();
195
206
  return result;
196
207
  }
@@ -232,49 +243,48 @@ function getCheckObj() {
232
243
  extendObjType([
233
244
  [
234
245
  'undefined',
235
- /** @param {*} val @returns {val is undefined} */
246
+ /** @param {unknown} val @returns {val is undefined} */
236
247
  (val) => typeof val === 'undefined',
237
248
  ],
238
249
  [
239
250
  'null',
240
- /** @param {*} val @returns {val is null} */
251
+ /** @param {unknown} val @returns {val is null} */
241
252
  (val) => val === null,
242
253
  ],
243
254
  [
244
255
  'boolean',
245
- /** @param {*} val @returns {val is boolean} */
256
+ /** @param {unknown} val @returns {val is boolean} */
246
257
  (val) => typeof val === 'boolean',
247
258
  ],
248
259
  [
249
260
  'number',
250
- /** @param {*} val @returns {val is number} */
261
+ /** @param {unknown} val @returns {val is number} */
251
262
  (val) => typeof val === 'number' && !Number.isNaN(val),
252
263
  ],
253
264
  [
254
265
  'bigint',
255
- /** @param {*} val @returns {val is bigint} */
266
+ /** @param {unknown} val @returns {val is bigint} */
256
267
  (val) => typeof val === 'bigint',
257
268
  ],
258
269
  [
259
270
  'string',
260
- /** @param {*} val @returns {val is string} */
271
+ /** @param {unknown} val @returns {val is string} */
261
272
  (val) => typeof val === 'string',
262
273
  ],
263
274
  [
264
275
  'symbol',
265
- /** @param {*} val @returns {val is symbol} */
276
+ /** @param {unknown} val @returns {val is symbol} */
266
277
  (val) => typeof val === 'symbol',
267
278
  ],
268
279
  [
269
280
  'function',
270
- /** @param {*} val @returns {val is Function} */
281
+ /** @param {unknown} val @returns {val is Function} */
271
282
  (val) => typeof val === 'function',
272
283
  ],
273
284
  [
274
285
  'array',
275
286
  /**
276
- * @template {any} Value
277
- * @param {*} val @returns {val is Value[]}
287
+ * @param {unknown} val @returns {val is unknown[]}
278
288
  */
279
289
  (val) => Array.isArray(val),
280
290
  ],
@@ -284,7 +294,7 @@ if (isBrowser) {
284
294
  extendObjType([
285
295
  [
286
296
  'file',
287
- /** @param {*} val @returns {val is File} */
297
+ /** @param {unknown} val @returns {val is File} */
288
298
  (val) => typeof File !== 'undefined' && val instanceof File,
289
299
  ],
290
300
  ]);
@@ -293,53 +303,46 @@ if (isBrowser) {
293
303
  extendObjType([
294
304
  [
295
305
  'date',
296
- /** @param {*} val @returns {val is Date} */
306
+ /** @param {unknown} val @returns {val is Date} */
297
307
  (val) => val instanceof Date,
298
308
  ],
299
309
  [
300
310
  'regexp',
301
- /** @param {*} val @returns {val is RegExp} */
311
+ /** @param {unknown} val @returns {val is RegExp} */
302
312
  (val) => val instanceof RegExp,
303
313
  ],
304
314
  [
305
315
  'map',
306
316
  /**
307
- * @template {any} Key
308
- * @template {any} Value
309
- * @param {*} val @returns {val is Map<Key, Value>}
317
+ * @param {unknown} val @returns {val is Map<unknown, unknown>}
310
318
  */
311
319
  (val) => val instanceof Map,
312
320
  ],
313
321
  [
314
322
  'set',
315
323
  /**
316
- * @template {any} Value
317
- * @param {*} val @returns {val is Set<Value>}
324
+ * @param {unknown} val @returns {val is Set<unknown>}
318
325
  */
319
326
  (val) => val instanceof Set,
320
327
  ],
321
328
  [
322
329
  'weakmap',
323
330
  /**
324
- * @template {WeakKey} Key
325
- * @template {any} Value
326
- * @param {*} val @returns {val is WeakMap<Key, Value>}
331
+ * @param {unknown} val @returns {val is WeakMap<unknown, unknown>}
327
332
  */
328
333
  (val) => val instanceof WeakMap,
329
334
  ],
330
335
  [
331
336
  'weakset',
332
337
  /**
333
- * @template {WeakKey} Value
334
- * @param {*} val @returns {val is WeakSet<Value>}
338
+ * @param {unknown} val @returns {val is WeakSet<unknown>}
335
339
  */
336
340
  (val) => val instanceof WeakSet,
337
341
  ],
338
342
  [
339
343
  'promise',
340
344
  /**
341
- * @template {any} Value
342
- * @param {*} val @returns {val is Promise<Value>}
345
+ * @param {unknown} val @returns {val is Promise<unknown>}
343
346
  */
344
347
  (val) => val instanceof Promise,
345
348
  ],
@@ -349,7 +352,7 @@ if (isBrowser) {
349
352
  extendObjType([
350
353
  [
351
354
  'htmlelement',
352
- /** @param {*} val @returns {val is HTMLElement} */
355
+ /** @param {unknown} val @returns {val is HTMLElement} */
353
356
  (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
354
357
  ],
355
358
  ]);
@@ -359,9 +362,7 @@ extendObjType([
359
362
  [
360
363
  'object',
361
364
  /**
362
- * @template {string | number | symbol} Key
363
- * @template {any} Value
364
- * @param {*} val @returns {val is Record<Key, Value>}
365
+ * @param {unknown} val @returns {val is Record<string | number | symbol, unknown>}
365
366
  */
366
367
  (val) => objChecker.isJsonObject(val),
367
368
  ],
@@ -373,5 +374,7 @@ exports.checkObj = checkObj;
373
374
  exports.cloneObjTypeOrder = cloneObjTypeOrder;
374
375
  exports.extendObjType = extendObjType;
375
376
  exports.getCheckObj = getCheckObj;
377
+ exports.isObjType = isObjType;
376
378
  exports.objType = objType;
379
+ exports.objTypeName = objTypeName;
377
380
  exports.reorderObjTypeOrder = reorderObjTypeOrder;
@@ -48,9 +48,33 @@ export declare function reorderObjTypeOrder(newOrder: string[]): boolean;
48
48
  * @returns {string[]} - A new array with the same values as `typeValidator.order`.
49
49
  */
50
50
  export declare function cloneObjTypeOrder(): string[];
51
+ /**
52
+ * Returns the detected type name of a given value based on predefined type validators.
53
+ *
54
+ * If `val` is `null`, it immediately returns `'null'`.
55
+ * If no match is found, it returns `'unknown'`.
56
+ *
57
+ * @param {any} val - The value whose type should be determined.
58
+ * @returns {string} - The type name of the value (e.g., "array", "date", "map"), or "unknown" if no match is found.
59
+ *
60
+ * @example
61
+ * objTypeName([]); // "array"
62
+ * objTypeName(null); // "null"
63
+ * objTypeName(new Set()); // "set"
64
+ */
65
+ export declare const objTypeName: (val: any) => string;
66
+ /**
67
+ * Checks the type of a given object.
68
+ *
69
+ * @param {*} obj - The object to check.
70
+ * @param {string} [type] - Checks whether the object matches this type (e.g., "object", "array", "string").
71
+ * @returns {boolean} - Returns `true` if the type matches.
72
+ */
73
+ export declare function isObjType(obj: any, type?: string): boolean;
51
74
  /**
52
75
  * Checks the type of a given object or returns its type as a string.
53
76
  *
77
+ * @deprecated Use {@link isObjType} or {@link objTypeName} instead.
54
78
  * @param {*} obj - The object to check or identify.
55
79
  * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
56
80
  * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import { countObj, isJsonObject } from './objChecker.mjs';
2
3
  export { countObj, isJsonObject };
3
4
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
@@ -121,9 +122,6 @@ export function cloneObjTypeOrder() {
121
122
  /**
122
123
  * Returns the detected type name of a given value based on predefined type validators.
123
124
  *
124
- * This function uses `getType` with a predefined `typeValidator` to determine or compare types safely.
125
- * in the specified `typeValidator.order`. The first matching type is returned.
126
- *
127
125
  * If `val` is `null`, it immediately returns `'null'`.
128
126
  * If no match is found, it returns `'unknown'`.
129
127
  *
@@ -131,12 +129,11 @@ export function cloneObjTypeOrder() {
131
129
  * @returns {string} - The type name of the value (e.g., "array", "date", "map"), or "unknown" if no match is found.
132
130
  *
133
131
  * @example
134
- * getType([]); // "array"
135
- * getType(null); // "null"
136
- * getType(new Set()); // "set"
137
- * getType(() => {}); // "unknown"
132
+ * objTypeName([]); // "array"
133
+ * objTypeName(null); // "null"
134
+ * objTypeName(new Set()); // "set"
138
135
  */
139
- const getType = (val) => {
136
+ export const objTypeName = (val) => {
140
137
  if (val === null)
141
138
  return 'null';
142
139
  // @ts-ignore
@@ -147,9 +144,22 @@ const getType = (val) => {
147
144
  }
148
145
  return 'unknown';
149
146
  };
147
+ /**
148
+ * Checks the type of a given object.
149
+ *
150
+ * @param {*} obj - The object to check.
151
+ * @param {string} [type] - Checks whether the object matches this type (e.g., "object", "array", "string").
152
+ * @returns {boolean} - Returns `true` if the type matches.
153
+ */
154
+ export function isObjType(obj, type) {
155
+ if (typeof type !== 'string')
156
+ throw new TypeError("Argument 'type' must be a string.");
157
+ return objTypeName(obj) === type.toLowerCase();
158
+ }
150
159
  /**
151
160
  * Checks the type of a given object or returns its type as a string.
152
161
  *
162
+ * @deprecated Use {@link isObjType} or {@link objTypeName} instead.
153
163
  * @param {*} obj - The object to check or identify.
154
164
  * @param {string} [type] - Optional. If provided, checks whether the object matches this type (e.g., "object", "array", "string").
155
165
  * @returns {boolean|string|null} - Returns `true` if the type matches, `false` if not,
@@ -167,7 +177,7 @@ export function objType(obj, type) {
167
177
  if (typeof type !== 'undefined' && typeof type !== 'string') {
168
178
  throw new TypeError("Argument 'type' must be a string.");
169
179
  }
170
- const result = getType(obj);
180
+ const result = objTypeName(obj);
171
181
  if (typeof type === 'string')
172
182
  return result === type.toLowerCase();
173
183
  return result;
@@ -206,49 +216,48 @@ export function getCheckObj() {
206
216
  extendObjType([
207
217
  [
208
218
  'undefined',
209
- /** @param {*} val @returns {val is undefined} */
219
+ /** @param {unknown} val @returns {val is undefined} */
210
220
  (val) => typeof val === 'undefined',
211
221
  ],
212
222
  [
213
223
  'null',
214
- /** @param {*} val @returns {val is null} */
224
+ /** @param {unknown} val @returns {val is null} */
215
225
  (val) => val === null,
216
226
  ],
217
227
  [
218
228
  'boolean',
219
- /** @param {*} val @returns {val is boolean} */
229
+ /** @param {unknown} val @returns {val is boolean} */
220
230
  (val) => typeof val === 'boolean',
221
231
  ],
222
232
  [
223
233
  'number',
224
- /** @param {*} val @returns {val is number} */
234
+ /** @param {unknown} val @returns {val is number} */
225
235
  (val) => typeof val === 'number' && !Number.isNaN(val),
226
236
  ],
227
237
  [
228
238
  'bigint',
229
- /** @param {*} val @returns {val is bigint} */
239
+ /** @param {unknown} val @returns {val is bigint} */
230
240
  (val) => typeof val === 'bigint',
231
241
  ],
232
242
  [
233
243
  'string',
234
- /** @param {*} val @returns {val is string} */
244
+ /** @param {unknown} val @returns {val is string} */
235
245
  (val) => typeof val === 'string',
236
246
  ],
237
247
  [
238
248
  'symbol',
239
- /** @param {*} val @returns {val is symbol} */
249
+ /** @param {unknown} val @returns {val is symbol} */
240
250
  (val) => typeof val === 'symbol',
241
251
  ],
242
252
  [
243
253
  'function',
244
- /** @param {*} val @returns {val is Function} */
254
+ /** @param {unknown} val @returns {val is Function} */
245
255
  (val) => typeof val === 'function',
246
256
  ],
247
257
  [
248
258
  'array',
249
259
  /**
250
- * @template {any} Value
251
- * @param {*} val @returns {val is Value[]}
260
+ * @param {unknown} val @returns {val is unknown[]}
252
261
  */
253
262
  (val) => Array.isArray(val),
254
263
  ],
@@ -257,7 +266,7 @@ if (isBrowser) {
257
266
  extendObjType([
258
267
  [
259
268
  'file',
260
- /** @param {*} val @returns {val is File} */
269
+ /** @param {unknown} val @returns {val is File} */
261
270
  (val) => typeof File !== 'undefined' && val instanceof File,
262
271
  ],
263
272
  ]);
@@ -265,53 +274,46 @@ if (isBrowser) {
265
274
  extendObjType([
266
275
  [
267
276
  'date',
268
- /** @param {*} val @returns {val is Date} */
277
+ /** @param {unknown} val @returns {val is Date} */
269
278
  (val) => val instanceof Date,
270
279
  ],
271
280
  [
272
281
  'regexp',
273
- /** @param {*} val @returns {val is RegExp} */
282
+ /** @param {unknown} val @returns {val is RegExp} */
274
283
  (val) => val instanceof RegExp,
275
284
  ],
276
285
  [
277
286
  'map',
278
287
  /**
279
- * @template {any} Key
280
- * @template {any} Value
281
- * @param {*} val @returns {val is Map<Key, Value>}
288
+ * @param {unknown} val @returns {val is Map<unknown, unknown>}
282
289
  */
283
290
  (val) => val instanceof Map,
284
291
  ],
285
292
  [
286
293
  'set',
287
294
  /**
288
- * @template {any} Value
289
- * @param {*} val @returns {val is Set<Value>}
295
+ * @param {unknown} val @returns {val is Set<unknown>}
290
296
  */
291
297
  (val) => val instanceof Set,
292
298
  ],
293
299
  [
294
300
  'weakmap',
295
301
  /**
296
- * @template {WeakKey} Key
297
- * @template {any} Value
298
- * @param {*} val @returns {val is WeakMap<Key, Value>}
302
+ * @param {unknown} val @returns {val is WeakMap<unknown, unknown>}
299
303
  */
300
304
  (val) => val instanceof WeakMap,
301
305
  ],
302
306
  [
303
307
  'weakset',
304
308
  /**
305
- * @template {WeakKey} Value
306
- * @param {*} val @returns {val is WeakSet<Value>}
309
+ * @param {unknown} val @returns {val is WeakSet<unknown>}
307
310
  */
308
311
  (val) => val instanceof WeakSet,
309
312
  ],
310
313
  [
311
314
  'promise',
312
315
  /**
313
- * @template {any} Value
314
- * @param {*} val @returns {val is Promise<Value>}
316
+ * @param {unknown} val @returns {val is Promise<unknown>}
315
317
  */
316
318
  (val) => val instanceof Promise,
317
319
  ],
@@ -320,7 +322,7 @@ if (isBrowser) {
320
322
  extendObjType([
321
323
  [
322
324
  'htmlelement',
323
- /** @param {*} val @returns {val is HTMLElement} */
325
+ /** @param {unknown} val @returns {val is HTMLElement} */
324
326
  (val) => typeof HTMLElement !== 'undefined' && val instanceof HTMLElement,
325
327
  ],
326
328
  ]);
@@ -329,9 +331,7 @@ extendObjType([
329
331
  [
330
332
  'object',
331
333
  /**
332
- * @template {string | number | symbol} Key
333
- * @template {any} Value
334
- * @param {*} val @returns {val is Record<Key, Value>}
334
+ * @param {unknown} val @returns {val is Record<string | number | symbol, unknown>}
335
335
  */
336
336
  (val) => isJsonObject(val),
337
337
  ],
package/dist/v1/index.cjs CHANGED
@@ -71,7 +71,9 @@ exports.getTimeDuration = clock.getTimeDuration;
71
71
  exports.checkObj = objFilter.checkObj;
72
72
  exports.cloneObjTypeOrder = objFilter.cloneObjTypeOrder;
73
73
  exports.extendObjType = objFilter.extendObjType;
74
+ exports.isObjType = objFilter.isObjType;
74
75
  exports.objType = objFilter.objType;
76
+ exports.objTypeName = objFilter.objTypeName;
75
77
  exports.reorderObjTypeOrder = objFilter.reorderObjTypeOrder;
76
78
  exports.countObj = objChecker.countObj;
77
79
  exports.isJsonObject = objChecker.isJsonObject;
@@ -1,7 +1,7 @@
1
1
  import TinyLevelUp from './libs/TinyLevelUp.mjs';
2
2
  import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks } from './basics/array.mjs';
3
3
  import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration } from './basics/clock.mjs';
4
- import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj } from './basics/objFilter.mjs';
4
+ import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj, objTypeName, isObjType } from './basics/objFilter.mjs';
5
5
  import { countObj, isJsonObject } from './basics/objChecker.mjs';
6
6
  import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange } from './basics/fullScreen.mjs';
7
7
  import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree } from './basics/simpleMath.mjs';
@@ -53,5 +53,5 @@ import TinyClassManager from './libs/TinyClassManager.mjs';
53
53
  import TinyRadioFm from './libs/TinyRadioFm.mjs';
54
54
  import TinyMediaPlayer from './libs/TinyMediaPlayer.mjs';
55
55
  import { createCheckDestroyed } from './libs/utils.mjs';
56
- export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock, TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
56
+ export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock, TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objTypeName, isObjType, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
57
57
  //# sourceMappingURL=index.d.mts.map
package/dist/v1/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import TinyLevelUp from './libs/TinyLevelUp.mjs';
2
2
  import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks, } from './basics/array.mjs';
3
3
  import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, } from './basics/clock.mjs';
4
- import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj, } from './basics/objFilter.mjs';
4
+ import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj, objTypeName, isObjType, } from './basics/objFilter.mjs';
5
5
  import { countObj, isJsonObject } from './basics/objChecker.mjs';
6
6
  import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './basics/fullScreen.mjs';
7
7
  import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree, } from './basics/simpleMath.mjs';
@@ -56,4 +56,4 @@ import { createCheckDestroyed } from './libs/utils.mjs';
56
56
  // import TinyHtmlElems from './libs/TinyHtml/index.mjs';
57
57
  export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock,
58
58
  // TinyHtmlElems,
59
- TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
59
+ TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objTypeName, isObjType, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
@@ -0,0 +1,14 @@
1
+ ### πŸ” `objType(obj, [type])`
2
+
3
+ Get the type of any value, or check it against a known type.
4
+
5
+ ```js
6
+ objType([], 'array'); // true
7
+ objType('hello'); // "string"
8
+ objType(undefined); // null
9
+ ```
10
+
11
+ Returns:
12
+ - `true` / `false` if a type is provided
13
+ - The detected type name as a string if no type is provided
14
+ - `null` if `undefined` is passed
@@ -23,23 +23,6 @@ Whether you’re validating inputs, writing schema validators, or building tools
23
23
 
24
24
  ## Usage
25
25
 
26
- ### πŸ” `objType(obj, [type])`
27
-
28
- Get the type of any value, or check it against a known type.
29
-
30
- ```js
31
- objType([], 'array'); // true
32
- objType('hello'); // "string"
33
- objType(undefined); // null
34
- ```
35
-
36
- Returns:
37
- - `true` / `false` if a type is provided
38
- - The detected type name as a string if no type is provided
39
- - `null` if `undefined` is passed
40
-
41
- ---
42
-
43
26
  ### πŸ” `checkObj(obj)`
44
27
 
45
28
  Checks the type of a given object and returns the validation result if a known type is detected.
@@ -73,6 +56,37 @@ Returns:
73
56
 
74
57
  ---
75
58
 
59
+ ### 🏷️ `objTypeName(val)`
60
+
61
+ Returns the detected type name of a given value as a string.
62
+
63
+ ```js
64
+ objTypeName([]); // "array"
65
+ objTypeName(null); // "null"
66
+ objTypeName(new Set()); // "set"
67
+ ```
68
+
69
+ Returns:
70
+ - A string representing the type name (e.g., `"array"`, `"date"`, `"map"`).
71
+ - `"unknown"` if no matching type is found.
72
+
73
+ ---
74
+
75
+ ### βœ… `isObjType(obj, type)`
76
+
77
+ Checks whether a given object matches a specific type. This check is case-insensitive.
78
+
79
+ ```js
80
+ isObjType([], 'array'); // true
81
+ isObjType({}, 'object'); // true
82
+ isObjType('hello', 'string'); // true
83
+ isObjType(123, 'boolean'); // false
84
+ ```
85
+
86
+ *Note: Throws a `TypeError` if the `type` argument is not a string.*
87
+
88
+ ---
89
+
76
90
  ### βž• `extendObjType(newTypes, [index])`
77
91
 
78
92
  Add your own custom types. You can optionally define where in the check order they go.