@rzl-zone/utils-js 3.2.6-beta.0 → 3.3.0
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 +14 -16
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +33 -0
- package/dist/{any-BmdI8UbK.d.ts → any-v4TsK9ES.d.ts} +25 -26
- package/dist/{arrays-normalize-recursive-CnjYJ9xg.d.ts → arrays-normalize-recursive-BqmVuFlD.d.ts} +20 -20
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +96 -70
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-2CQX5CBG.js +1 -0
- package/dist/chunk-2IOOEY45.cjs +1 -0
- package/dist/chunk-3IBQ5MOM.js +1 -0
- package/dist/{chunk-OGPPP2S3.js → chunk-3VA554KW.js} +1 -1
- package/dist/{chunk-FV7SEBKD.cjs → chunk-5757UBXJ.cjs} +1 -1
- package/dist/{chunk-MTUBDVJ2.js → chunk-5IGC6PBH.js} +1 -1
- package/dist/{chunk-O7UT5AN3.cjs → chunk-5KJFVIQT.cjs} +1 -1
- package/dist/chunk-6JFCSH7J.js +1 -0
- package/dist/{chunk-VHAPTHEA.cjs → chunk-6JFZL7YE.cjs} +1 -1
- package/dist/chunk-7ODAAXX5.cjs +1 -0
- package/dist/{chunk-6C3ATUGM.cjs → chunk-CAH33WOQ.cjs} +1 -1
- package/dist/{chunk-ECRNH4FW.js → chunk-CKTLUNWX.js} +1 -1
- package/dist/chunk-CMW2TBOQ.js +1 -0
- package/dist/chunk-D3ENH7H6.cjs +1 -0
- package/dist/{chunk-3YCFMGRB.js → chunk-DEZZUYE2.js} +1 -1
- package/dist/chunk-DWF2R5GD.cjs +1 -0
- package/dist/chunk-E55EQK2U.cjs +1 -0
- package/dist/chunk-E74U6CYP.cjs +1 -0
- package/dist/{chunk-XC3QHAK2.cjs → chunk-EL6A35UR.cjs} +1 -1
- package/dist/chunk-F6IPNNSJ.cjs +1 -0
- package/dist/chunk-FJZGG54N.cjs +1 -0
- package/dist/chunk-FWCKOJZM.js +1 -0
- package/dist/{chunk-IMCLPT5V.cjs → chunk-FWHNWL2P.cjs} +1 -1
- package/dist/chunk-GGEADHZO.js +1 -0
- package/dist/{chunk-IRGE5W7L.js → chunk-GQR4R5WY.js} +1 -1
- package/dist/chunk-H66AC7GK.cjs +1 -0
- package/dist/{chunk-M47QIBXI.cjs → chunk-HQWOFR56.cjs} +1 -1
- package/dist/{chunk-VCFXNV3Q.cjs → chunk-HYRQMTRH.cjs} +1 -1
- package/dist/{chunk-EUANTHVN.js → chunk-IRFL4MAX.js} +1 -1
- package/dist/{chunk-GGWPB23G.cjs → chunk-IVL7CKVH.cjs} +1 -1
- package/dist/chunk-IZPBKKPO.js +1 -0
- package/dist/chunk-JBQMXC5I.cjs +1 -0
- package/dist/chunk-JEQEF5WD.js +1 -0
- package/dist/chunk-JMJQCN74.js +1 -0
- package/dist/chunk-JYQTCICM.js +1 -0
- package/dist/chunk-KVAL5PAG.cjs +1 -0
- package/dist/chunk-LS6U7FAY.cjs +1 -0
- package/dist/chunk-NBZWMBO6.js +1 -0
- package/dist/chunk-NRF6LWBC.cjs +1 -0
- package/dist/chunk-OI5XKNZO.js +1 -0
- package/dist/chunk-OYTYSY7G.js +1 -0
- package/dist/chunk-PET42Z7W.js +1 -0
- package/dist/chunk-PZQ6I4JJ.cjs +1 -0
- package/dist/chunk-QBKAEVYG.js +1 -0
- package/dist/{chunk-YV3K2EKJ.js → chunk-RIPKY4RU.js} +1 -1
- package/dist/chunk-RZW35UN5.cjs +1 -0
- package/dist/chunk-SBFNXGTJ.js +1 -0
- package/dist/{chunk-T4CIAKEK.js → chunk-SBKGWRS5.js} +1 -1
- package/dist/{chunk-5Z2G23WP.js → chunk-SIM77PU4.js} +1 -1
- package/dist/chunk-T2T7K3KR.js +1 -0
- package/dist/chunk-T7PU2V7X.cjs +1 -0
- package/dist/chunk-V45XJKHW.cjs +1 -0
- package/dist/chunk-W2WNBUDE.js +1 -0
- package/dist/chunk-XABCB3Y7.cjs +1 -0
- package/dist/chunk-XEDXFSGI.js +1 -0
- package/dist/chunk-YKPSRP5G.js +1 -0
- package/dist/chunk-YLA3DURS.cjs +1 -0
- package/dist/chunk-ZETAZZLD.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +515 -321
- package/dist/conversions/index.js +1 -1
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +25 -20
- package/dist/events/index.js +1 -1
- package/dist/{extends-Bk_SBGdT.d.ts → extends-DtdRjDyU.d.ts} +63 -87
- package/dist/{formatting → formatters}/index.cjs +1 -1
- package/dist/formatters/index.d.ts +2106 -0
- package/dist/formatters/index.js +1 -0
- package/dist/generators/index.cjs +1 -0
- package/dist/{generator → generators}/index.d.ts +57 -59
- package/dist/generators/index.js +1 -0
- package/dist/{if-CvT4R7Kh.d.ts → if-ChM35c_q.d.ts} +6 -5
- package/dist/index.d.ts +14 -0
- package/dist/{is-array--YjXV-Wx.d.ts → is-array-BJeHxPM3.d.ts} +287 -542
- package/dist/{isPlainObject-BVhBAPHX.d.ts → isPlainObject-DGJkcFYw.d.ts} +6 -6
- package/dist/{never-BfayMBF9.d.ts → never-D89PbPh5.d.ts} +10 -19
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.d.ts +15 -12
- package/dist/next/index.js +1 -1
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +1 -1
- package/dist/{nils-DMz3kU7M.d.ts → nils-CO8zLHSB.d.ts} +39 -65
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +4 -4
- package/dist/operations/index.js +1 -1
- package/dist/or-C6qzKt2I.d.ts +82 -0
- package/dist/override-CL2olHE5.d.ts +59 -0
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.js +1 -1
- package/dist/pick-BSMX6Xe2.d.ts +15 -0
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +425 -106
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-3o8_Kw6b.d.ts +564 -0
- package/dist/promises/index.cjs +1 -0
- package/dist/promises/index.d.ts +107 -0
- package/dist/promises/index.js +1 -0
- package/dist/promises-LU7K00H0.d.ts +72 -0
- package/dist/rzl-utils.global.js +1 -1
- package/dist/{string-XA-til3C.d.ts → string-B1jlOnws.d.ts} +82 -121
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +209 -210
- package/dist/strings/index.js +1 -1
- package/dist/tailwind/index.cjs +1 -1
- package/dist/tailwind/index.d.ts +23 -17
- package/dist/tailwind/index.js +1 -1
- package/dist/types/index.d.ts +899 -1181
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +113 -108
- package/dist/urls/index.js +1 -1
- package/package.json +33 -40
- package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +0 -26
- package/dist/chunk-2HSNUPEO.cjs +0 -1
- package/dist/chunk-4Z75R3IT.cjs +0 -1
- package/dist/chunk-AJ25PWXX.cjs +0 -1
- package/dist/chunk-BHIBDDQF.js +0 -1
- package/dist/chunk-CE4JI2YB.js +0 -1
- package/dist/chunk-CMJ6UYWW.cjs +0 -1
- package/dist/chunk-D3VSHABU.cjs +0 -1
- package/dist/chunk-DG2GWBTS.cjs +0 -1
- package/dist/chunk-EKS4IZJR.cjs +0 -1
- package/dist/chunk-EOZKYR5S.cjs +0 -1
- package/dist/chunk-EW3I4O7X.js +0 -1
- package/dist/chunk-F3E77L46.js +0 -1
- package/dist/chunk-G5LXIEFO.js +0 -0
- package/dist/chunk-GVWGQNLF.js +0 -1
- package/dist/chunk-H3FXL4DU.cjs +0 -1
- package/dist/chunk-HHPDLSX2.cjs +0 -1
- package/dist/chunk-JARPXKBM.cjs +0 -1
- package/dist/chunk-JFJUPYDT.cjs +0 -1
- package/dist/chunk-JLP56WSM.js +0 -1
- package/dist/chunk-K3MV4AIN.cjs +0 -1
- package/dist/chunk-KOVO72OM.js +0 -1
- package/dist/chunk-LJ4M3VGE.js +0 -1
- package/dist/chunk-LJVGJLP4.js +0 -1
- package/dist/chunk-MISCBZJC.js +0 -1
- package/dist/chunk-MMSYCIJ2.cjs +0 -1
- package/dist/chunk-OLPKAX7F.cjs +0 -1
- package/dist/chunk-ORZFHBEY.js +0 -1
- package/dist/chunk-OWV2P376.js +0 -1
- package/dist/chunk-RV2WK5E6.js +0 -1
- package/dist/chunk-SBF43G3B.cjs +0 -1
- package/dist/chunk-X74TUJSE.cjs +0 -1
- package/dist/chunk-XLDAIZRK.js +0 -1
- package/dist/chunk-XZJ7C4N6.js +0 -1
- package/dist/chunk-ZHV5ZYVN.cjs +0 -1
- package/dist/chunk-ZL7J6GTP.js +0 -1
- package/dist/chunk-ZTCLKKMB.js +0 -1
- package/dist/env/index.cjs +0 -1
- package/dist/env/index.d.ts +0 -16
- package/dist/env/index.js +0 -1
- package/dist/formatting/index.d.ts +0 -950
- package/dist/formatting/index.js +0 -1
- package/dist/generator/index.cjs +0 -1
- package/dist/generator/index.js +0 -1
- package/dist/omit-VvmIsZmX.d.ts +0 -28
- package/dist/prettify-C4xLcYOP.d.ts +0 -353
- package/dist/promise/index.cjs +0 -1
- package/dist/promise/index.d.ts +0 -31
- package/dist/promise/index.js +0 -1
- package/dist/type-data-DDs-u2kq.d.ts +0 -261
- /package/dist/{chunk-5C2SMIGX.cjs → chunk-BAV5T2E3.cjs} +0 -0
- /package/dist/{chunk-MC3LXMCQ.js → chunk-L5RDAVVH.js} +0 -0
- /package/dist/{chunk-J2RGTPGK.cjs → chunk-VJDDGRIK.cjs} +0 -0
- /package/dist/{chunk-FIAAX3UE.js → chunk-YWHHVDT4.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as IsPositive,P as ParseNumber,I as IsStringLiteral,C as CharAt,c as IsUnknown,j as IsReadonlyArray,l as IsArray}from'../is-array-BJeHxPM3.js';import{A as AnyString,a as IsEmptyString,T as Trim}from'../string-B1jlOnws.js';import{I as IsAny}from'../any-v4TsK9ES.js';import{P as Prettify,A as AnyFunction,g as AnObjectNonArray,T as TypedArray}from'../prettify-3o8_Kw6b.js';import{E as Extends}from'../extends-DtdRjDyU.js';import{N as NumberRangeUnion}from'../NumberRangeUnion-B6bhM2s7.js';import{a as IsPlainObjectResult}from'../isPlainObject-DGJkcFYw.js';export{G as GetPreciseTypeOptions,I as IsNumberOptions,g as getPreciseType,i as isNumber,b as isPlainObject}from'../isPlainObject-DGJkcFYw.js';import{I as IsNever}from'../never-D89PbPh5.js';import{O as OrArr}from'../or-C6qzKt2I.js';import'../if-ChM35c_q.js';
|
|
2
2
|
/** ----------------------------------------------------------
|
|
3
3
|
* * ***Predicate: `areArraysEqual`.***
|
|
4
4
|
* ----------------------------------------------------------
|
|
@@ -6,11 +6,11 @@ import{k as IsPositive,P as ParseNumber,I as IsStringLiteral,C as CharAt,d as Is
|
|
|
6
6
|
* @description Supports deep comparison of arrays containing nested arrays or objects,
|
|
7
7
|
* can also ignore the order of elements at all levels by recursively sorting.
|
|
8
8
|
* @param {unknown[]} array1
|
|
9
|
-
* The first array to compare
|
|
9
|
+
* ***The first array to compare, can contain nested arrays or objects.***
|
|
10
10
|
* @param {unknown[]} array2
|
|
11
|
-
* The second array to compare against
|
|
11
|
+
* ***The second array to compare against, should match structure of `array1`.***
|
|
12
12
|
* @param {boolean|undefined} [ignoreOrder=false]
|
|
13
|
-
* Whether to ignore the order of elements when comparing
|
|
13
|
+
* ***Whether to ignore the order of elements when comparing.***
|
|
14
14
|
* - If `true`, will sort both arrays recursively before comparing, default is `false`.
|
|
15
15
|
* @returns {boolean}
|
|
16
16
|
* Returns `true` if both arrays are deeply equal, otherwise `false`.
|
|
@@ -56,19 +56,31 @@ declare const areObjectsEqual:(object1:unknown,object2:unknown)=>boolean;
|
|
|
56
56
|
* @returns {boolean} Returns `true` if both URLs are the same (ignoring search parameters), otherwise `false`.
|
|
57
57
|
* @example
|
|
58
58
|
* // Same domain, same path, different query -> true
|
|
59
|
-
* areURLsEqualPath(
|
|
59
|
+
* areURLsEqualPath(
|
|
60
|
+
* new URL("https://example.com/page?a=1"),
|
|
61
|
+
* new URL("https://example.com/page?b=2")
|
|
62
|
+
* );
|
|
60
63
|
* // ➔ true
|
|
61
64
|
*
|
|
62
65
|
* // Same domain, different path -> false
|
|
63
|
-
* areURLsEqualPath(
|
|
66
|
+
* areURLsEqualPath(
|
|
67
|
+
* new URL("https://example.com/page1"),
|
|
68
|
+
* new URL("https://example.com/page2")
|
|
69
|
+
* );
|
|
64
70
|
* // ➔ false
|
|
65
71
|
*
|
|
66
72
|
* // Different protocol -> false
|
|
67
|
-
* areURLsEqualPath(
|
|
73
|
+
* areURLsEqualPath(
|
|
74
|
+
* new URL("http://example.com/page"),
|
|
75
|
+
* new URL("https://example.com/page")
|
|
76
|
+
* );
|
|
68
77
|
* // ➔ false
|
|
69
78
|
*
|
|
70
79
|
* // Same protocol, same host, same path (ignores query & hash) -> true
|
|
71
|
-
* areURLsEqualPath(
|
|
80
|
+
* areURLsEqualPath(
|
|
81
|
+
* new URL("https://example.com/page#section"),
|
|
82
|
+
* new URL("https://example.com/page")
|
|
83
|
+
* );
|
|
72
84
|
* // ➔ true
|
|
73
85
|
*/
|
|
74
86
|
declare const areURLsEqualPath:(urlA:URL,urlB:URL)=>boolean;
|
|
@@ -81,19 +93,31 @@ declare const areURLsEqualPath:(urlA:URL,urlB:URL)=>boolean;
|
|
|
81
93
|
* @returns {boolean} Returns `true` if both URLs are identical, otherwise `false`.
|
|
82
94
|
* @example
|
|
83
95
|
* // Identical URLs -> true
|
|
84
|
-
* areURLsIdentical(
|
|
96
|
+
* areURLsIdentical(
|
|
97
|
+
* new URL("https://example.com/page?a=1"),
|
|
98
|
+
* new URL("https://example.com/page?a=1")
|
|
99
|
+
* );
|
|
85
100
|
* // ➔ true
|
|
86
101
|
*
|
|
87
102
|
* // Same path, different query parameter -> false
|
|
88
|
-
* areURLsIdentical(
|
|
103
|
+
* areURLsIdentical(
|
|
104
|
+
* new URL("https://example.com/page?a=1"),
|
|
105
|
+
* new URL("https://example.com/page?b=2")
|
|
106
|
+
* );
|
|
89
107
|
* // ➔ false
|
|
90
108
|
*
|
|
91
109
|
* // Same host & query, but different protocol -> false
|
|
92
|
-
* areURLsIdentical(
|
|
110
|
+
* areURLsIdentical(
|
|
111
|
+
* new URL("http://example.com/page?a=1"),
|
|
112
|
+
* new URL("https://example.com/page?a=1")
|
|
113
|
+
* );
|
|
93
114
|
* // ➔ false
|
|
94
115
|
*
|
|
95
116
|
* // Same everything except trailing slash -> false
|
|
96
|
-
* areURLsIdentical(
|
|
117
|
+
* areURLsIdentical(
|
|
118
|
+
* new URL("https://example.com/page"),
|
|
119
|
+
* new URL("https://example.com/page/")
|
|
120
|
+
* );
|
|
97
121
|
* // ➔ false
|
|
98
122
|
*/
|
|
99
123
|
declare const areURLsIdentical:(urlA:URL,urlB:URL)=>boolean;type OptionsTextContainsAll={
|
|
@@ -189,9 +213,9 @@ declare const textContainsAny:<T extends string>(text?:T|null,searchWords?:T[]|s
|
|
|
189
213
|
* key exists at each level, even if its value is `null` or `undefined`.
|
|
190
214
|
* - Optimized to return `true` immediately when the key is found (short-circuits).
|
|
191
215
|
* - Handles edge cases gracefully:
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
216
|
+
* - Returns `false` for `null`, `undefined`, or non-object inputs.
|
|
217
|
+
* - Returns `false` if key is not found anywhere, even in deeply nested
|
|
218
|
+
* structures.
|
|
195
219
|
* - **ℹ️ Note:**
|
|
196
220
|
* - This function only checks for **the existence of the key itself**,
|
|
197
221
|
* not whether its value is non-null or non-undefined.
|
|
@@ -292,9 +316,14 @@ type EffectiveDiscardNull<O extends boolean|undefined>=O extends boolean?O:false
|
|
|
292
316
|
type UnwrapArray<T>=T extends(infer U)[]?U:T extends readonly(infer U)[]?U:T;
|
|
293
317
|
/** Force symbol key to be deep required. */
|
|
294
318
|
type IsOptionalKey<T,K extends keyof T>=Record<never,never>extends Pick<T,K>?true:false;
|
|
295
|
-
/** Returns numeric keys of an object
|
|
319
|
+
/** * ***Returns numeric keys of an object.***
|
|
320
|
+
*
|
|
321
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
322
|
+
*/
|
|
296
323
|
type NumericKeyOfHasOwnProp<Obj>=Extract<keyof Obj,number>;
|
|
297
|
-
/** Generate all nested keys of an object or array in dot/bracket notation
|
|
324
|
+
/** * ***Generate all nested keys of an object or array in dot/bracket notation.***
|
|
325
|
+
*
|
|
326
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
298
327
|
*
|
|
299
328
|
* Example:
|
|
300
329
|
* ```ts
|
|
@@ -322,28 +351,43 @@ type RefineArrayAtIndex<T extends readonly unknown[],N extends number,U>=T &{[K
|
|
|
322
351
|
* @template DN - discard null
|
|
323
352
|
*/
|
|
324
353
|
type NarrowByPathHasOwnProp<T,P extends string,DU extends boolean=true,DN extends boolean=false>=P extends`${infer Head}.${infer Rest}`?Head extends`[${infer N extends number}]`?T extends readonly(infer U)[]?RefineArrayAtIndex<T,N,NarrowByPathHasOwnProp<U,Rest,DU,DN>>:T:Head extends keyof T?Rest extends`[${infer M extends number}]${infer R}`?M extends R?{[K in keyof T]-?:NarrowByPathHasOwnProp<EffectiveDiscardUndefined<DU>extends true?NonUndef<T[K]>:EffectiveDiscardNull<DN>extends true?NonNull<T[K]>:T[K],Rest,DU,DN>;}:EffectiveDiscardUndefined<DU>extends true?{[K in keyof T]-?:K extends Head?Exclude<NarrowByPathHasOwnProp<EffectiveDiscardNull<DN>extends true?Exclude<T[K],null>:EffectiveDiscardUndefined<DU>extends true?Exclude<T[K],undefined>:T[K],Rest,DU,DN>,undefined>:EffectiveDiscardNull<DN>extends true?Exclude<T[K],null>:EffectiveDiscardUndefined<DU>extends true?Exclude<T[K],undefined>:T[K];}:{[K in keyof T]:K extends Head?NarrowByPathHasOwnProp<EffectiveDiscardNull<DN>extends true?Exclude<T[K],null>:EffectiveDiscardUndefined<DU>extends true?Exclude<T[K],undefined>:T[K],Rest,DU,DN>:EffectiveDiscardNull<DN>extends true?Exclude<T[K],null>:EffectiveDiscardUndefined<DU>extends true?Exclude<T[K],undefined>:T[K];}:{[K in keyof T]:K extends Head?NarrowByPathHasOwnProp<NonNullable<T[K]>,Rest,DU,DN>:T[K];}&{[K in Head]-?:NarrowByPathHasOwnProp<NonNullable<T[K]>,Rest,DU,DN>;}:T:P extends`[${infer N extends number}]`?T extends readonly(infer U)[]?RefineArrayAtIndex<T,N,ApplyLastRulesHasOwnProp<NonNullable<U>,DU,DN>>:T:P extends keyof T?DU extends true?{[K in keyof T]:K extends P?ApplyLastRulesHasOwnProp<T[K],DU,DN>:T[K];}&{[K in P]-?:ApplyLastRulesHasOwnProp<T[P],DU,DN>;}:{[K in keyof T]:K extends P?ApplyLastRulesHasOwnProp<T[K],DU,DN>:T[K];}:T;
|
|
325
|
-
/** Expand an array/string/function into a nested type according
|
|
326
|
-
|
|
327
|
-
|
|
354
|
+
/** * ***Expand an array/string/function into a nested type according
|
|
355
|
+
* to a dot/bracket path.***
|
|
356
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
357
|
+
*/
|
|
358
|
+
type SmartDetectStringHasOwnProp<Obj extends string|undefined|null,Key extends string|number>=Obj extends undefined?undefined:Obj extends null?null:IsPositive<ParseNumber<Key>>extends true?Extends<IsStringLiteral<Obj>,true>extends true?CharAt<Exclude<Obj,null|undefined>,ParseNumber<Key>>:string|undefined|null:IsPositive<ParseNumber<Key>>extends true?string|undefined|null:AnyString|undefined|null;
|
|
359
|
+
/** @private ***types for {@link hasOwnProp}.*** */
|
|
360
|
+
type SmartDetectArrayFuncHasOwnProp<Obj extends unknown[]|AnyFunction,Key extends PropertyKey>=Prettify<Obj & DotToNestedSpecialSmartDetect<Key>&{length:number;},{recursive:false;}>;
|
|
361
|
+
/** * ***Smartly detect nested path keys of an unknown object or function,
|
|
362
|
+
* falls-back to inferred nested structure when path is not valid.***
|
|
363
|
+
*
|
|
364
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
365
|
+
*/
|
|
328
366
|
type SmartDetectUnknownKeyHasOwnProp<Obj extends unknown|AnyFunction,Key extends PropertyKey,DiscardUndefined extends boolean=true,DiscardNull extends boolean=false>=Trim<Key>extends""?Obj:Prettify<Obj &(Key extends NestedKeyOfHasOwnProp<Obj>?GuardedHasOwnProp<Obj,Key,DiscardUndefined,DiscardNull>:DotToNestedSpecialSmartDetect<Key>),{recursive:true;}>;
|
|
329
367
|
/** Convert dot/bracket path string to nested object type with leaf value.
|
|
330
|
-
* Path not found in object key
|
|
368
|
+
* Path not found in object key ➔ return unknown.
|
|
331
369
|
*/
|
|
332
370
|
type DotToNestedSpecialSmartDetect<Path extends PropertyKey,Value=unknown>=IsEmptyString<Extract<Path,string>>extends true?undefined:Path extends`${infer Head}.${infer Rest}`?Head extends`[${number}]`?DotToNestedSpecialSmartDetect<Rest,Value>[]:{[Key in Head]:DotToNestedSpecialSmartDetect<Rest,Value>;}:Path extends`[${number}]`?Value[]:{[Key in Path]:Value;};
|
|
333
|
-
/** Guarded wrapper for `NarrowByPathHasOwnProp` with `Prettify
|
|
371
|
+
/** * ***Guarded wrapper for `NarrowByPathHasOwnProp` with `Prettify`.***
|
|
372
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
373
|
+
*/
|
|
334
374
|
type GuardedHasOwnProp<Obj,Key extends NestedKeyOfHasOwnProp<Obj>,DiscardUndefined extends boolean|undefined,DiscardNull extends boolean|undefined>=Prettify<Obj & NarrowByPathHasOwnProp<Obj,Key & string,EffectiveDiscardUndefined<DiscardUndefined>,EffectiveDiscardNull<DiscardNull>>,{recursive:true;}>;
|
|
335
|
-
/** Make a specific symbol key deeply required in an object symbols
|
|
336
|
-
*
|
|
337
|
-
*
|
|
375
|
+
/** * ***Make a specific symbol key deeply required in an object symbols.***
|
|
376
|
+
* **Used internally to enforce stronger type narrowing.**
|
|
377
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
338
378
|
*/
|
|
339
379
|
type DeepRequiredSymbolHasOwnProp<Obj,Sym extends symbol,DU extends boolean=true,DN extends boolean=false>=Prettify<Obj &({[K in keyof Obj & Sym as DU extends true?K:never]-?:DN extends true?NonNull<NonUndef<Obj[K]>>:NonUndef<Obj[K]>;}&{[K in keyof Obj & Sym as DU extends true?never:K]?:DN extends true?NonNull<Obj[K]>:Obj[K];}),{recursive:true;}>;
|
|
340
|
-
/** Apply discard rules to numeric keys in an object type
|
|
380
|
+
/** * ***Apply discard rules to numeric keys in an object type.***
|
|
341
381
|
*
|
|
342
|
-
* - If `discardUndefined = true`
|
|
343
|
-
* - If `discardNull = true`
|
|
382
|
+
* - If `discardUndefined = true` ➔ undefined removed, key required
|
|
383
|
+
* - If `discardNull = true` ➔ null removed
|
|
384
|
+
*
|
|
385
|
+
* @private ***types for {@link hasOwnProp}.***
|
|
344
386
|
*/
|
|
345
387
|
type NumericKeyHasOwnPropMapped<Obj extends object,K extends NumericKeyOfHasOwnProp<Obj>,DU extends boolean,DN extends boolean>=Prettify<Obj &(IsOptionalKey<Obj,K>extends true?{[P in K]?:DN extends true?NonNull<Obj[K]>:Obj[K];}&(DU extends true?{[P in K]-?:NonUndef<Obj[K]>;}:Record<never,never>):{[P in K]-?:DN extends true?NonNull<Obj[K]>:Obj[K];}&(DU extends true?{[P in K]-?:NonUndef<Obj[K]>;}:Record<never,never>)),{recursive:true;}>;
|
|
346
|
-
/** Options to control `hasOwnProp` behavior
|
|
388
|
+
/** * ***Options to control `hasOwnProp` behavior.***
|
|
389
|
+
* @private ***types options for {@link hasOwnProp}.***
|
|
390
|
+
*/
|
|
347
391
|
type HasOwnPropOptions<DiscardUndefined extends boolean=true,DiscardNull extends boolean=false>={
|
|
348
392
|
/** If `true` ***(default)***, properties with `undefined` values are treated as non-existent.
|
|
349
393
|
*
|
|
@@ -372,31 +416,30 @@ discardUndefined?:DiscardUndefined;
|
|
|
372
416
|
*/
|
|
373
417
|
discardNull?:DiscardNull;};
|
|
374
418
|
/** -------------------------------------------------------
|
|
375
|
-
* * ***
|
|
419
|
+
* * ***Predicate: `hasOwnProp`.***
|
|
376
420
|
* -------------------------------------------------------
|
|
377
421
|
* **A **type-safe** replacement for `Object.prototype.hasOwnProperty` with runtime validation and **TypeScript-aware type narrowing**.**
|
|
378
422
|
* - #### Supported Targets:
|
|
379
|
-
* - **Plain objects** ➔ `{ foo: "bar" }
|
|
380
|
-
* - **Arrays** ➔ `[ { id: 1 }, { id: 2 } ]
|
|
381
|
-
* - **Strings** ➔ `"hello"` (as array-like objects with `.length`, index, etc.)
|
|
382
|
-
* - **Functions** ➔ callable objects with extra props
|
|
383
|
-
* - **Symbols** ➔ own property symbols
|
|
423
|
+
* - **Plain objects** ➔ `{ foo: "bar" }`.
|
|
424
|
+
* - **Arrays** ➔ `[ { id: 1 }, { id: 2 } ]`.
|
|
425
|
+
* - **Strings** ➔ `"hello"` (as array-like objects with `.length`, index, etc.).
|
|
426
|
+
* - **Functions** ➔ callable objects with extra props.
|
|
427
|
+
* - **Symbols** ➔ own property symbols.
|
|
384
428
|
* - #### Key Advantages over `in` or `obj.hasOwnProperty(key)`:
|
|
385
|
-
* - Supports **dot/bracket path notation** (e.g. `"user.address.city"`, `"addresses[0].zip"`)
|
|
386
|
-
* - Handles **symbol** keys safely
|
|
387
|
-
* - **Narrows** the type of `obj` in TypeScript (stronger type safety)
|
|
388
|
-
* - Configurable handling of **`undefined`** and **`null
|
|
429
|
+
* - Supports **dot/bracket path notation** (e.g. `"user.address.city"`, `"addresses[0].zip"`).
|
|
430
|
+
* - Handles **symbol** keys safely.
|
|
431
|
+
* - **Narrows** the type of `obj` in TypeScript (stronger type safety).
|
|
432
|
+
* - Configurable handling of **`undefined`** and **`null`**.
|
|
389
433
|
* - #### Runtime Behavior:
|
|
390
434
|
* - ***✅ Returns `true` if:***
|
|
391
|
-
* - `obj` is an object/array/string/function **and**
|
|
392
|
-
*
|
|
393
|
-
* - it passes the `options` checks
|
|
435
|
+
* - Value `obj` is an object/array/string/function **and** the property
|
|
436
|
+
* exists **and**, it passes the `options` checks.
|
|
394
437
|
* - ***❌ Returns `false` if:***
|
|
395
|
-
* - `obj` is not a valid type
|
|
396
|
-
* -
|
|
397
|
-
* -
|
|
398
|
-
* -
|
|
399
|
-
* -
|
|
438
|
+
* - Value `obj` is not a valid type.
|
|
439
|
+
* - The property does not exist.
|
|
440
|
+
* - The value is `undefined` and `discardUndefined: true` (**default**).
|
|
441
|
+
* - The value is `null` and `discardNull: true`.
|
|
442
|
+
* - The `key` (after trimming) is an **empty string** ➔ treated as **invalid**.
|
|
400
443
|
* - #### TypeScript Behavior:
|
|
401
444
|
* - ***Inside an `if (hasOwnProp(...)) {}` block:***
|
|
402
445
|
* - The property is **guaranteed to exist**.
|
|
@@ -417,18 +460,17 @@ discardNull?:DiscardNull;};
|
|
|
417
460
|
* **TypeScript IntelliSense to hang or crash**.
|
|
418
461
|
* - ℹ️ You can still check higher indices manually (e.g. `"[999].id"`),
|
|
419
462
|
* but they will not show up in IntelliSense suggestions.
|
|
420
|
-
* -
|
|
421
|
-
* @param {HasOwnPropOptions} [options] - Optional configuration object.
|
|
463
|
+
* @param {HasOwnPropOptions} [options] - ***Optional configuration object.***
|
|
422
464
|
* @param {HasOwnPropOptions["discardUndefined"]} [options.discardUndefined=true]
|
|
423
|
-
* If `true`, properties with `undefined` values are treated as **missing**, default: `true
|
|
465
|
+
* ***If `true`, properties with `undefined` values are treated as **missing**, default: `true`.***
|
|
424
466
|
* @param {HasOwnPropOptions["discardNull"]} [options.discardNull=false]
|
|
425
|
-
* If `true`, properties with `null` values are treated as **missing**, default: `false
|
|
426
|
-
* @param {*} obj
|
|
467
|
+
* ***If `true`, properties with `null` values are treated as **missing**, default: `false`.***
|
|
468
|
+
* @param {*} obj ***The `object`, `array`, `string`, `function`, or `other value` to check against.***
|
|
427
469
|
* @param {PropertyKey} key
|
|
428
|
-
* The property key to check, can be
|
|
429
|
-
* - `string` (supports dot/bracket paths, e.g. `"user.address.city"`, `"[0].id"`)
|
|
430
|
-
* - `number` (array-like index)
|
|
431
|
-
* - `symbol` (own property symbols)
|
|
470
|
+
* ***The property key to check, can be:***
|
|
471
|
+
* - `string` (supports dot/bracket paths, e.g. `"user.address.city"`, `"[0].id"`).
|
|
472
|
+
* - `number` (array-like index).
|
|
473
|
+
* - `symbol` (own property symbols).
|
|
432
474
|
* @returns {boolean} Return `true` if the property exists (and passes `options`), otherwise `false`.
|
|
433
475
|
* @example
|
|
434
476
|
*
|
|
@@ -610,14 +652,14 @@ declare function isArrayLikeObject<T extends{__anyHack:unknown;}>(value:T):boole
|
|
|
610
652
|
/** ----------------------------------------------------------
|
|
611
653
|
* * ***Type guard: `isBigInt`.***
|
|
612
654
|
* ----------------------------------------------------------
|
|
613
|
-
* **Checks if a value is of type
|
|
655
|
+
* **Checks if a value is of type **[`BigInt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)**.**
|
|
614
656
|
* - **Behavior:**
|
|
615
657
|
* - Uses `typeof value === "bigint"` for strict type checking.
|
|
616
658
|
* - Supports TypeScript type narrowing with `value is bigint`.
|
|
617
659
|
* - Returns `false` for `BigInt` object (object-wrapped), e.g:
|
|
618
660
|
* - `Object(BigInt(123))`.
|
|
619
661
|
* @param {*} value - The value to check.
|
|
620
|
-
* @returns {boolean} Return `true` if value is a primitive
|
|
662
|
+
* @returns {boolean} Return `true` if value is a primitive bigint.
|
|
621
663
|
* @example
|
|
622
664
|
* isBigInt(123n);
|
|
623
665
|
* // ➔ true
|
|
@@ -632,21 +674,35 @@ declare const isBigInt:(value:unknown)=>value is bigint;
|
|
|
632
674
|
/** ----------------------------------------------------------
|
|
633
675
|
* * ***Type guard: `isBoolean`.***
|
|
634
676
|
* ----------------------------------------------------------
|
|
635
|
-
* **Checks if a value is of type boolean
|
|
677
|
+
* **Checks if a value is of type **[`boolean`](https://developer.mozilla.org/en-US/docs/Glossary/Boolean/JavaScript)**.**
|
|
636
678
|
* @param {*} value - The value to check.
|
|
637
|
-
* @returns {boolean} Returns `true` if the value is a
|
|
679
|
+
* @returns {boolean} Returns `true` if the value is a `boolean`, otherwise `false`.
|
|
638
680
|
* @example
|
|
639
681
|
* isBoolean(true); // ➔ true
|
|
640
682
|
* isBoolean(false); // ➔ true
|
|
641
683
|
* isBoolean("true"); // ➔ false
|
|
642
684
|
*/
|
|
643
685
|
declare const isBoolean:(value:unknown)=>value is boolean;
|
|
686
|
+
/** ----------------------------------------------------
|
|
687
|
+
* * ***Type guard: `isBooleanObject`.***
|
|
688
|
+
* ----------------------------------------------------
|
|
689
|
+
* **Checks if a value is a **`Boolean` object wrapper**
|
|
690
|
+
* (`new Boolean(...)`), not a primitive boolean.**
|
|
691
|
+
* @param {*} value The value to check.
|
|
692
|
+
* @returns {value is Boolean} Returns `true` if `value` is a `Boolean` object.
|
|
693
|
+
* @example
|
|
694
|
+
* isBooleanObject(new Boolean(true));
|
|
695
|
+
* // ➔ true
|
|
696
|
+
* isBooleanObject(true);
|
|
697
|
+
* // ➔ false
|
|
698
|
+
*/
|
|
699
|
+
declare function isBooleanObject(value:unknown):value is Boolean;
|
|
644
700
|
/** ----------------------------------------------------
|
|
645
701
|
* * ***Type guard: `isBuffer`.***
|
|
646
702
|
* ----------------------------------------------------------
|
|
647
|
-
* **Checks if a value is a
|
|
703
|
+
* **Checks if a value is a *****{@link Buffer | `Node.js - Buffer`}***** instance.**
|
|
648
704
|
* @param {*} value The value to check.
|
|
649
|
-
* @returns {boolean} Returns `true` if `value` is a
|
|
705
|
+
* @returns {boolean} Returns `true` if `value` is a `Buffer`, else `false`.
|
|
650
706
|
* @example
|
|
651
707
|
* isBuffer(new Buffer(2));
|
|
652
708
|
* // ➔ true
|
|
@@ -663,12 +719,12 @@ declare const isBoolean:(value:unknown)=>value is boolean;
|
|
|
663
719
|
*/
|
|
664
720
|
declare const isBuffer:(value:unknown)=>value is Buffer;
|
|
665
721
|
/** -----------------------------------------------------------
|
|
666
|
-
* * ***
|
|
722
|
+
* * ***Predicate: `isCurrencyLike`.***
|
|
667
723
|
* -----------------------------------------------------------
|
|
668
724
|
* **Determines if the given `input` can be interpreted as a currency-like number,
|
|
669
725
|
* using the same **multi-locale parsing logic** as ***{@link parseCurrencyString | `parseCurrencyString`}***.**
|
|
670
726
|
* - **Highlights:**
|
|
671
|
-
* - Supports strings or numbers like
|
|
727
|
+
* - *Supports strings or numbers like:*
|
|
672
728
|
* - `"15.000,10"` ***(European)***.
|
|
673
729
|
* - `"15,000.10"` ***(US)***.
|
|
674
730
|
* - `"15'000.10"` ***(Swiss)***.
|
|
@@ -695,27 +751,46 @@ declare const isBuffer:(value:unknown)=>value is Buffer;
|
|
|
695
751
|
* isCurrencyLike("abc");
|
|
696
752
|
* // ➔ false
|
|
697
753
|
*/
|
|
698
|
-
declare const isCurrencyLike:(input:unknown)=>boolean;
|
|
754
|
+
declare const isCurrencyLike:(input:unknown)=>boolean;type isDateOptions={
|
|
755
|
+
/** * ***Skip the validity check (`!isNaN(date.getTime())`).***
|
|
756
|
+
*
|
|
757
|
+
* When `true`, the function only checks that the value is an
|
|
758
|
+
* instance of `Date` without verifying that it represents a valid
|
|
759
|
+
* date value, default: `false`.
|
|
760
|
+
*
|
|
761
|
+
* @default false
|
|
762
|
+
*/
|
|
763
|
+
skipInvalidDate?:boolean;};
|
|
699
764
|
/** ----------------------------------------------------------
|
|
700
765
|
* * ***Type guard: `isDate`.***
|
|
701
766
|
* ----------------------------------------------------------
|
|
702
767
|
* **Determines whether the given `value` is a real, valid JavaScript
|
|
703
768
|
* **[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date)** object.**
|
|
704
769
|
* - **Behavior:**
|
|
705
|
-
* -
|
|
706
|
-
*
|
|
707
|
-
*
|
|
770
|
+
* - Returns **true** only if:
|
|
771
|
+
* - `value` is an instance of `Date`.
|
|
772
|
+
* - and, unless `options.skipInvalidDate` is `true`,
|
|
773
|
+
* the underlying time value is valid (`!isNaN(value.getTime())`).
|
|
774
|
+
* - Returns **false** for:
|
|
775
|
+
* - non-Date values (strings, numbers, etc.).
|
|
776
|
+
* - `Date` instances that represent an invalid time value
|
|
777
|
+
* (e.g. `new Date("bad")`), unless skipping is enabled.
|
|
708
778
|
* @param {*} value - The value to check.
|
|
779
|
+
* @param {isDateOptions} [options] - Optional settings.
|
|
709
780
|
* @returns {boolean} Return `true` if value is a valid Date object.
|
|
710
781
|
* @example
|
|
711
782
|
* isDate(new Date());
|
|
712
|
-
* //
|
|
783
|
+
* // ➜ true
|
|
713
784
|
* isDate(new Date("invalid"));
|
|
714
|
-
* //
|
|
785
|
+
* // ➜ false
|
|
715
786
|
* isDate("2024-01-01");
|
|
716
|
-
* //
|
|
787
|
+
* // ➜ false
|
|
788
|
+
*
|
|
789
|
+
* // Skipping validity check:
|
|
790
|
+
* isDate(new Date("invalid"), { skipInvalidDate: true });
|
|
791
|
+
* // ➜ true
|
|
717
792
|
*/
|
|
718
|
-
declare const isDate:(value:unknown)=>value is Date;
|
|
793
|
+
declare const isDate:(value:unknown,options?:isDateOptions)=>value is Date;
|
|
719
794
|
/** ----------------------------------------------------------
|
|
720
795
|
* * ***Predicate: `isDeepEqual`.***
|
|
721
796
|
* ----------------------------------------------------------
|
|
@@ -794,8 +869,68 @@ declare const isDeepEqual:(a:unknown,b:unknown)=>boolean;
|
|
|
794
869
|
* // ➔ false
|
|
795
870
|
*/
|
|
796
871
|
declare function isElement(value:[]):value is [];declare function isElement<T extends Element>(value:T):value is T;declare function isElement(value:unknown):value is Element;
|
|
872
|
+
/**
|
|
873
|
+
* -------------------------------------------------------------------
|
|
874
|
+
* * ***Array-like structure interface.***
|
|
875
|
+
* -------------------------------------------------------------------
|
|
876
|
+
* **Represents objects with indexed elements and a `length` property,
|
|
877
|
+
* similar to arrays, but not necessarily full Array instances.**
|
|
878
|
+
* @template T The type of elements stored in the array-like object.
|
|
879
|
+
* @example
|
|
880
|
+
* ```ts
|
|
881
|
+
* function logArrayLike<T>(items: ArrayLike<T>) {
|
|
882
|
+
* for (let i = 0; i < items.length; i++) {
|
|
883
|
+
* console.log(items[i]);
|
|
884
|
+
* }
|
|
885
|
+
* }
|
|
886
|
+
*
|
|
887
|
+
* const myNodeList: ArrayLike<Element> = document.querySelectorAll("div");
|
|
888
|
+
* logArrayLike(myNodeList);
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
interface ArrayLike<T>{
|
|
892
|
+
/** * ***Number of elements in the array-like object.*** */
|
|
893
|
+
readonly length:number;
|
|
894
|
+
/** * ***Indexed access to elements.*** */
|
|
895
|
+
readonly [n:number]:T;}
|
|
896
|
+
/** -------------------------------------------------------------------
|
|
897
|
+
* * ***Represents an object with no allowed properties.***
|
|
898
|
+
* -------------------------------------------------------------------
|
|
899
|
+
* **Useful for cases where you want to ensure a type has **no keys**.**
|
|
900
|
+
* @template T - The base type to convert into an empty object type.
|
|
901
|
+
* @example
|
|
902
|
+
* ```ts
|
|
903
|
+
* type Test = EmptyObject<{ a: number }>;
|
|
904
|
+
* // ➔ { a?: never }
|
|
905
|
+
* ```
|
|
906
|
+
*/
|
|
907
|
+
type EmptyObject<T>={[K in keyof T]?:never;};
|
|
908
|
+
/** -------------------------------------------------------------------
|
|
909
|
+
* * ***Conditional empty object type.***
|
|
910
|
+
* -------------------------------------------------------------------
|
|
911
|
+
* **Produces `EmptyObject<T>` only if it is assignable to `T`.**
|
|
912
|
+
* @template T - The base type to check.
|
|
913
|
+
* @example
|
|
914
|
+
* ```ts
|
|
915
|
+
* type Test = EmptyObjectOf<{ a: number }>;
|
|
916
|
+
* // ➔ { a?: never } | never depending on assignability
|
|
917
|
+
* ```
|
|
918
|
+
*/
|
|
919
|
+
type EmptyObjectOf<T>=EmptyObject<T>extends T?EmptyObject<T>:never;
|
|
920
|
+
/** -------------------------------------------------------------------
|
|
921
|
+
* * ***List type alias.***
|
|
922
|
+
* -------------------------------------------------------------------
|
|
923
|
+
* **Represents any array-like structure.**
|
|
924
|
+
* @template T - The type of elements in the list.
|
|
925
|
+
* @example
|
|
926
|
+
* ```ts
|
|
927
|
+
* const arr: List<number> = [1, 2, 3];
|
|
928
|
+
* const nodeList: List<Element> = document.querySelectorAll("div");
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
type List<T>=ArrayLike<T>;
|
|
797
932
|
/** ----------------------------------------------------
|
|
798
|
-
* * ***
|
|
933
|
+
* * ***Predicate: `isEmpty`.***
|
|
799
934
|
* ----------------------------------------------------------
|
|
800
935
|
* **Checks if `value` is an empty object, collection, map, or set.**
|
|
801
936
|
* - **Behavior:**
|
|
@@ -838,11 +973,11 @@ declare function isElement(value:[]):value is [];declare function isElement<T ex
|
|
|
838
973
|
*/
|
|
839
974
|
declare function isEmpty<T extends{__trapAny:any;}>(value?:T):boolean;declare function isEmpty(value:string):value is"";declare function isEmpty(value:Map<any,any>|Set<any>|List<any>|null|undefined):boolean;declare function isEmpty(value:object):boolean;declare function isEmpty<T extends object>(value:T|null|undefined):value is EmptyObjectOf<T>|null|undefined;declare function isEmpty(value:any):boolean;
|
|
840
975
|
/** ----------------------------------------------------------
|
|
841
|
-
* * ***
|
|
976
|
+
* * ***Predicate: `isEmptyArray`.***
|
|
842
977
|
* ----------------------------------------------------------
|
|
843
978
|
* **Checks whether a given value is an empty array.**
|
|
844
979
|
* - **Behavior:**
|
|
845
|
-
* - Non-array inputs are considered
|
|
980
|
+
* - Non-array inputs are considered ***`empty`*** ***(defensive strategy)***.
|
|
846
981
|
* @param {*} [value] - The value to check.
|
|
847
982
|
* @returns {boolean} Returns `true` if it's ***not an array*** or ***an empty-array***.
|
|
848
983
|
* @example
|
|
@@ -895,7 +1030,7 @@ declare const isEmptyArray:(value:unknown)=>boolean;
|
|
|
895
1030
|
* // ➔ true
|
|
896
1031
|
*/
|
|
897
1032
|
declare const isEmptyDeep:(value:unknown)=>boolean;type IsEmptyObjectOptions={
|
|
898
|
-
/** Whether to check for symbol properties in addition to string keys, defaultValue: `
|
|
1033
|
+
/** Whether to check for symbol properties in addition to string keys, defaultValue: `false`.
|
|
899
1034
|
*
|
|
900
1035
|
* @default false
|
|
901
1036
|
*/
|
|
@@ -933,12 +1068,12 @@ checkSymbols?:boolean;};
|
|
|
933
1068
|
declare function isEmptyObject(value:unknown,options?:IsEmptyObjectOptions):boolean;type IsEmptyStringOptions={
|
|
934
1069
|
/** Whether to trim the string before checking, defaultValue: `true`.
|
|
935
1070
|
*
|
|
936
|
-
* @default
|
|
1071
|
+
* @default true */
|
|
937
1072
|
trim?:boolean;};
|
|
938
1073
|
/** ----------------------------------------------------------
|
|
939
1074
|
* * ***Predicate: `isEmptyString`.***
|
|
940
1075
|
* ----------------------------------------------------------
|
|
941
|
-
* **Checks whether a given value is an **empty
|
|
1076
|
+
* **Checks whether a given value is an **empty-string**.**
|
|
942
1077
|
* - **Behavior:**
|
|
943
1078
|
* - Considers `""` and whitespace-only strings as
|
|
944
1079
|
* empty (if `trim` is enabled, which is the default).
|
|
@@ -969,9 +1104,8 @@ trim?:boolean;};
|
|
|
969
1104
|
* }
|
|
970
1105
|
*/
|
|
971
1106
|
declare const isEmptyString:(value:unknown,options?:IsEmptyStringOptions)=>boolean;type IsEmptyValueOptions={
|
|
972
|
-
/** Whether to check symbol properties when checking empty objects
|
|
973
|
-
*
|
|
974
|
-
* DefaultValue: `false`.
|
|
1107
|
+
/** **Whether to check symbol properties when checking empty objects.**
|
|
1108
|
+
* - **DefaultValue:** `false`.
|
|
975
1109
|
*
|
|
976
1110
|
* @default false
|
|
977
1111
|
*/
|
|
@@ -1072,6 +1206,52 @@ declare const isEmptyValue:(value:unknown,options?:IsEmptyValueOptions)=>boolean
|
|
|
1072
1206
|
* // ➔ false
|
|
1073
1207
|
*/
|
|
1074
1208
|
declare function isEqual(value:unknown,other:unknown):boolean;
|
|
1209
|
+
/** -------------------------------------------------------------------
|
|
1210
|
+
* * ***Customizer function for `isEqualWith`.***
|
|
1211
|
+
* -------------------------------------------------------------------
|
|
1212
|
+
* **Allows customizing how two values are compared for deep equality.**
|
|
1213
|
+
* @param value
|
|
1214
|
+
* - The current value being compared.
|
|
1215
|
+
* @param other
|
|
1216
|
+
* - The corresponding value from the other object.
|
|
1217
|
+
* @param indexOrKey
|
|
1218
|
+
* - The property key (for objects) or index (for arrays) of the current value.
|
|
1219
|
+
* @param parent
|
|
1220
|
+
* - The parent object or array containing `value`.
|
|
1221
|
+
* @param otherParent
|
|
1222
|
+
* - The parent object or array containing `other`.
|
|
1223
|
+
* @param stack
|
|
1224
|
+
* - WeakMap or tracking structure for already visited objects to handle circular references.
|
|
1225
|
+
* @returns
|
|
1226
|
+
* - `true` → Treat the values as equal.
|
|
1227
|
+
* - `false` → Treat the values as unequal.
|
|
1228
|
+
* - `undefined` → Fallback to default deep equality comparison.
|
|
1229
|
+
* @example
|
|
1230
|
+
* ```ts
|
|
1231
|
+
* const customizer: CustomizerIsEqualWith = (value, other, key) => {
|
|
1232
|
+
* if (typeof value === "string" && typeof other === "string") {
|
|
1233
|
+
* return value.toLowerCase() === other.toLowerCase();
|
|
1234
|
+
* }
|
|
1235
|
+
* return undefined;
|
|
1236
|
+
* };
|
|
1237
|
+
*
|
|
1238
|
+
* baseDeepEqual({ name: "Alice" }, { name: "alice" }, customizer);
|
|
1239
|
+
* // returns true
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
type CustomizerIsEqualWith=(
|
|
1243
|
+
/** * ***The current value being compared.*** */
|
|
1244
|
+
value:unknown,
|
|
1245
|
+
/** * ***The corresponding value from the other object.*** */
|
|
1246
|
+
other:unknown,
|
|
1247
|
+
/** * ***Property key (for objects) or index (for arrays) of the current value.*** */
|
|
1248
|
+
indexOrKey:PropertyKey,
|
|
1249
|
+
/** * ***Parent object or array containing `value`.*** */
|
|
1250
|
+
parent:unknown,
|
|
1251
|
+
/** * ***Parent object or array containing `other`.*** */
|
|
1252
|
+
otherParent:unknown,
|
|
1253
|
+
/** * ***WeakMap or tracking structure for visited objects to handle circular references.*** */
|
|
1254
|
+
stack:unknown)=>boolean|undefined;
|
|
1075
1255
|
/** ----------------------------------------------------
|
|
1076
1256
|
* * ***Predicate: `isEqualWith`.***
|
|
1077
1257
|
* ----------------------------------------------------
|
|
@@ -1114,12 +1294,12 @@ declare function isEqualWith(value:unknown,other:unknown,customizer?:CustomizerI
|
|
|
1114
1294
|
/** ----------------------------------------------------------
|
|
1115
1295
|
* * ***Type guard: `isError`.***
|
|
1116
1296
|
* ----------------------------------------------------------
|
|
1117
|
-
* **Checks whether the given value is an
|
|
1297
|
+
* **Checks whether the given value is an ****[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)** object**.**
|
|
1118
1298
|
* - **Behavior:**
|
|
1119
1299
|
* - Ensures that the provided value is a valid JavaScript error instance.
|
|
1120
1300
|
* - Useful in TypeScript for narrowing types during error handling.
|
|
1121
1301
|
* @param {*} error - The value to check.
|
|
1122
|
-
* @returns {boolean} Returns `true` if `value` is instance of **[Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)**, else `false`.
|
|
1302
|
+
* @returns {boolean} Returns `true` if `value` is instance of **[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error)**, else `false`.
|
|
1123
1303
|
* @example
|
|
1124
1304
|
* isError(new Error("Something went wrong"));
|
|
1125
1305
|
* // ➔ true
|
|
@@ -1143,7 +1323,7 @@ declare const isError:(error:unknown)=>error is Error;
|
|
|
1143
1323
|
* @param {*} value - The value to check.
|
|
1144
1324
|
* @returns {boolean} Returns `true` if `value` is a finite primitive number, else `false`.
|
|
1145
1325
|
* @example
|
|
1146
|
-
* import * as RzlUtilsJs from "@rzl-zone/utils-js";
|
|
1326
|
+
* import * as RzlUtilsJs from "@rzl-zone/utils-js/predicates";
|
|
1147
1327
|
*
|
|
1148
1328
|
* // Strict finite number check (only primitive numbers)
|
|
1149
1329
|
* RzlUtilsJs.isFinite(3);
|
|
@@ -1187,10 +1367,36 @@ declare function isFinite(value:unknown):value is number;
|
|
|
1187
1367
|
* // ➔ false
|
|
1188
1368
|
*/
|
|
1189
1369
|
declare const isFunction:(value:unknown)=>value is AnyFunction;
|
|
1370
|
+
/** ----------------------------------------------------
|
|
1371
|
+
* * ***Type guard: `isInfinityNumber`.***
|
|
1372
|
+
* ----------------------------------------------------
|
|
1373
|
+
* **Checks if a value is positive or negative
|
|
1374
|
+
* [`Infinity`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Infinity).**
|
|
1375
|
+
* - **ℹ️ Note:**
|
|
1376
|
+
* - This is stricter than the global `isFinite`,
|
|
1377
|
+
* because it only returns `true` for `Infinity` or `-Infinity`,
|
|
1378
|
+
* not other non-finite values.
|
|
1379
|
+
* @param {*} value The value to check.
|
|
1380
|
+
* @returns {boolean} Returns `true` if `value` is `Infinity` or `-Infinity`, else `false`.
|
|
1381
|
+
* @example
|
|
1382
|
+
* import * as RzlUtilsJs from "@rzl-zone/utils-js/predicates";
|
|
1383
|
+
*
|
|
1384
|
+
* RzlUtilsJs.isInfinityNumber(Infinity);
|
|
1385
|
+
* // ➔ true
|
|
1386
|
+
* RzlUtilsJs.isInfinityNumber(-Infinity);
|
|
1387
|
+
* // ➔ true
|
|
1388
|
+
* RzlUtilsJs.isInfinityNumber(new Number(Infinity));
|
|
1389
|
+
* // ➔ true
|
|
1390
|
+
* RzlUtilsJs.isInfinityNumber(NaN);
|
|
1391
|
+
* // ➔ false
|
|
1392
|
+
* RzlUtilsJs.isInfinityNumber(123);
|
|
1393
|
+
* // ➔ false
|
|
1394
|
+
*/
|
|
1395
|
+
declare function isInfinityNumber(value:unknown):boolean;
|
|
1190
1396
|
/** ---------------------------------------------------------
|
|
1191
1397
|
* * ***Type guard: `isInteger`.***
|
|
1192
1398
|
* ----------------------------------------------------------
|
|
1193
|
-
* **Checks if a value is an integer.**
|
|
1399
|
+
* **Checks if a value is an integer number.**
|
|
1194
1400
|
* - **ℹ️ Note:**
|
|
1195
1401
|
* - This method is based on
|
|
1196
1402
|
* [`Number.isInteger`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger).
|
|
@@ -1212,7 +1418,7 @@ declare const isFunction:(value:unknown)=>value is AnyFunction;
|
|
|
1212
1418
|
*/
|
|
1213
1419
|
declare function isInteger(value:unknown):value is number;
|
|
1214
1420
|
/** ----------------------------------------
|
|
1215
|
-
* * ***
|
|
1421
|
+
* * ***Predicate: `isLength`.***
|
|
1216
1422
|
* ----------------------------------------------------------
|
|
1217
1423
|
* **Checks whether the given value is a **valid array-like length**.**
|
|
1218
1424
|
* - **Behavior:**
|
|
@@ -1220,10 +1426,10 @@ declare function isInteger(value:unknown):value is number;
|
|
|
1220
1426
|
* - ✅ Ensures the value is **not greater than `Number.MAX_SAFE_INTEGER`**.
|
|
1221
1427
|
* - ❌ Excludes non-numeric values, `Infinity`, and fractional numbers.
|
|
1222
1428
|
* - **ℹ️ Note:**
|
|
1223
|
-
* - This method is loosely based
|
|
1429
|
+
* - This method is loosely based-on
|
|
1430
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
1224
1431
|
* - A valid length must be a non-negative integer and **not greater
|
|
1225
1432
|
* than `Number.MAX_SAFE_INTEGER`**.
|
|
1226
|
-
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
1227
1433
|
* @param {*} value The value to check.
|
|
1228
1434
|
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
|
|
1229
1435
|
* @example
|
|
@@ -1250,12 +1456,12 @@ declare function isLength(value:unknown):boolean;
|
|
|
1250
1456
|
/** --------------------------------------------------
|
|
1251
1457
|
* * ***Type guard: `isMap`.***
|
|
1252
1458
|
* ----------------------------------------------------------
|
|
1253
|
-
* **Checks whether the given value is a
|
|
1459
|
+
* **Checks whether the given value is a **[`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) object**.**
|
|
1254
1460
|
* - **Behavior:**
|
|
1255
|
-
* - Ensures that the provided value is an instance of **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)**.
|
|
1461
|
+
* - Ensures that the provided value is an instance of **[`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)**.
|
|
1256
1462
|
* - Useful in TypeScript for narrowing types when working with collections.
|
|
1257
1463
|
* @param {*} value The value to check.
|
|
1258
|
-
* @returns {boolean} Returns `true` if `value` is instance of **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)**, else `false`.
|
|
1464
|
+
* @returns {boolean} Returns `true` if `value` is instance of **[`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)**, else `false`.
|
|
1259
1465
|
* @example
|
|
1260
1466
|
* isMap(new Map());
|
|
1261
1467
|
* // ➔ true
|
|
@@ -1294,6 +1500,48 @@ declare function isMap<K=unknown,V=unknown>(value:Map<K,V>):value is Map<K,V>;de
|
|
|
1294
1500
|
* // ➔ true (treats arrays as objects with index keys)
|
|
1295
1501
|
*/
|
|
1296
1502
|
declare function isMatch(object:object,source:object):boolean;
|
|
1503
|
+
/** -------------------------------------------------------------------
|
|
1504
|
+
* * ***Customizer function for `isMatchWith`.***
|
|
1505
|
+
* -------------------------------------------------------------------
|
|
1506
|
+
* **Allows customizing how two values are compared for partial/object match.**
|
|
1507
|
+
* @param value
|
|
1508
|
+
* - The current value from the object being tested.
|
|
1509
|
+
* @param other
|
|
1510
|
+
* - The corresponding value from the source object.
|
|
1511
|
+
* @param indexOrKey
|
|
1512
|
+
* - The property key (for objects) or index (for arrays) of the current value.
|
|
1513
|
+
* @param object
|
|
1514
|
+
* - The parent object containing `value`.
|
|
1515
|
+
* @param source
|
|
1516
|
+
* - The parent source object containing `other`.
|
|
1517
|
+
* @returns
|
|
1518
|
+
* - `true` → Treat the values as matching.
|
|
1519
|
+
* - `false` → Treat the values as not matching.
|
|
1520
|
+
* - `undefined` → Fallback to default match comparison.
|
|
1521
|
+
* @example
|
|
1522
|
+
* ```ts
|
|
1523
|
+
* const customizer: CustomizerIsMatchWith = (value, other) => {
|
|
1524
|
+
* if (typeof value === "string" && typeof other === "string") {
|
|
1525
|
+
* return value.toLowerCase() === other.toLowerCase();
|
|
1526
|
+
* }
|
|
1527
|
+
* return undefined;
|
|
1528
|
+
* };
|
|
1529
|
+
*
|
|
1530
|
+
* baseIsMatch({ name: "Alice" }, { name: "alice" }, customizer);
|
|
1531
|
+
* // returns true
|
|
1532
|
+
* ```
|
|
1533
|
+
*/
|
|
1534
|
+
type CustomizerIsMatchWith=(
|
|
1535
|
+
/** * ***Current value from the object being tested.*** */
|
|
1536
|
+
value:unknown,
|
|
1537
|
+
/** * ***Corresponding value from the source object.*** */
|
|
1538
|
+
other:unknown,
|
|
1539
|
+
/** * ***Property key (objects) or index (arrays) of the current value.*** */
|
|
1540
|
+
indexOrKey:PropertyKey,
|
|
1541
|
+
/** * ***Parent object containing `value`.*** */
|
|
1542
|
+
object:object,
|
|
1543
|
+
/** * ***Parent source object containing `other`.*** */
|
|
1544
|
+
source:object)=>boolean|undefined;
|
|
1297
1545
|
/** ----------------------------------------------------
|
|
1298
1546
|
* * ***Predicate: `isMatchWith`.***
|
|
1299
1547
|
* ----------------------------------------------------
|
|
@@ -1345,7 +1593,7 @@ declare function isMatchWith(value:object,other:object,customizer?:CustomizerIsM
|
|
|
1345
1593
|
* @param {*} value The value to check.
|
|
1346
1594
|
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
1347
1595
|
* @example
|
|
1348
|
-
* import * as RzlUtilsJs from "@rzl-zone/utils-js";
|
|
1596
|
+
* import * as RzlUtilsJs from "@rzl-zone/utils-js/predicates";
|
|
1349
1597
|
*
|
|
1350
1598
|
* RzlUtilsJs.isNaN(NaN);
|
|
1351
1599
|
* // ➔ true
|
|
@@ -1376,7 +1624,7 @@ declare function isNaN(value:unknown):boolean;
|
|
|
1376
1624
|
* isNative(Array.prototype.push);
|
|
1377
1625
|
* // ➔ true
|
|
1378
1626
|
*
|
|
1379
|
-
* import * as RzlUtilsJs from "@rzl-zone/utils-js";
|
|
1627
|
+
* import * as RzlUtilsJs from "@rzl-zone/utils-js/predicates";
|
|
1380
1628
|
* isNative(RzlUtilsJs);
|
|
1381
1629
|
* // ➔ false
|
|
1382
1630
|
*/
|
|
@@ -1418,10 +1666,9 @@ declare function isNil(value:unknown):value is null|undefined;
|
|
|
1418
1666
|
* isNonEmptyArray("test"); // ➔ false
|
|
1419
1667
|
*/
|
|
1420
1668
|
declare function isNonEmptyArray(value:[]):value is [];declare function isNonEmptyArray<T extends unknown[]>(value:T):value is NonNullable<Extract<T,unknown[]>>;declare function isNonEmptyArray(value:unknown):value is unknown[];type IsNonEmptyStringOptions={
|
|
1421
|
-
/**
|
|
1422
|
-
* Whether to trim the string before checking.
|
|
1669
|
+
/** Whether to trim the string before checking, defaultValue: `true`.
|
|
1423
1670
|
*
|
|
1424
|
-
* @default
|
|
1671
|
+
* @default true */
|
|
1425
1672
|
trim?:boolean;};
|
|
1426
1673
|
/** ----------------------------------------------------------
|
|
1427
1674
|
* * ***Type guard: `isNonEmptyString`.***
|
|
@@ -1539,7 +1786,21 @@ declare const isNonEmptyValue:(value:unknown,options?:IsNonEmptyValueOptions)=>b
|
|
|
1539
1786
|
* isNull(0); // ➔ false
|
|
1540
1787
|
* isNull(undefined); // ➔ false
|
|
1541
1788
|
*/
|
|
1542
|
-
declare const isNull:(val:unknown)=>val is null;
|
|
1789
|
+
declare const isNull:(val:unknown)=>val is null;
|
|
1790
|
+
/** ----------------------------------------------------
|
|
1791
|
+
* * ***Type guard: `isNumberObject`.***
|
|
1792
|
+
* ----------------------------------------------------
|
|
1793
|
+
* **Checks if a value is a **`Number` object wrapper**
|
|
1794
|
+
* (`new Number(...)`), not a primitive number.**
|
|
1795
|
+
* @param {*} value The value to check.
|
|
1796
|
+
* @returns {boolean} Returns `true` if `value` is a `Number` object.
|
|
1797
|
+
* @example
|
|
1798
|
+
* isNumberObject(new Number(42));
|
|
1799
|
+
* // ➔ true
|
|
1800
|
+
* isNumberObject(42);
|
|
1801
|
+
* // ➔ false
|
|
1802
|
+
*/
|
|
1803
|
+
declare function isNumberObject(value:unknown):value is Number;type HasKeys$1<T>=keyof T extends never?false:true;type IsObject<T>=unknown extends T?T & Record<PropertyKey,unknown>:T extends object?T extends AnObjectNonArray?T:HasKeys$1<T>extends false?T & Record<PropertyKey,unknown>:IsArray<T>extends true?Exclude<T,unknown[]>:T:never;
|
|
1543
1804
|
/** ---------------------------------------------------------
|
|
1544
1805
|
* * ***Type guard: `isObject`.***
|
|
1545
1806
|
* ----------------------------------------------------------
|
|
@@ -1560,7 +1821,8 @@ declare const isNull:(val:unknown)=>val is null;type HasKeys$1<T>=keyof T extend
|
|
|
1560
1821
|
* - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
|
|
1561
1822
|
* - `undefined` (including `NaN`, which is a primitive number)
|
|
1562
1823
|
* - **ℹ️ Note:**
|
|
1563
|
-
* - If you specifically need to check for ***plain-objects
|
|
1824
|
+
* - If you specifically need to check for ***plain-objects*** only, use **{@link isPlainObject}** instead.
|
|
1825
|
+
* - If you specifically need to check for ***object***, ***plain-objects***, and include ***array***, use **{@link isObjectOrArray}** instead.
|
|
1564
1826
|
* @template T - The type of the value being checked.
|
|
1565
1827
|
* @param {*} value - The value to check.
|
|
1566
1828
|
* @returns {boolean} Returns `true` if the value is a ***plain-objects***, otherwise `false`.
|
|
@@ -1641,8 +1903,8 @@ declare function isObjectLoose<T=object>(value:unknown):value is T;type HasKeys<
|
|
|
1641
1903
|
* @param {*} value - The value to check.
|
|
1642
1904
|
* @returns {boolean} Returns `true` if the value is an `object` or `array`.
|
|
1643
1905
|
* @example
|
|
1644
|
-
* isObjectOrArray({ name: "Alice" }); // ➔ true
|
|
1645
1906
|
* isObjectOrArray([1,2,3]); // ➔ true
|
|
1907
|
+
* isObjectOrArray({ name: "Alice" }); // ➔ true
|
|
1646
1908
|
* isObjectOrArray(null); // ➔ false
|
|
1647
1909
|
* isObjectOrArray(undefined); // ➔ false
|
|
1648
1910
|
* isObjectOrArray("hello"); // ➔ false
|
|
@@ -1678,9 +1940,9 @@ declare function isPropertyKey(value:unknown):value is PropertyKey;
|
|
|
1678
1940
|
/** ----------------------------------------------------------
|
|
1679
1941
|
* * ***Type guard: `isRegExp`.***
|
|
1680
1942
|
* ----------------------------------------------------------
|
|
1681
|
-
* **Checks if a value is a RegExp instance.**
|
|
1943
|
+
* **Checks if a value is a [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.**
|
|
1682
1944
|
* @param {*} value - The value to check.
|
|
1683
|
-
* @returns {boolean} Return `true` if value is an instance of
|
|
1945
|
+
* @returns {boolean} Return `true` if value is an instance of **`RegExp`**.
|
|
1684
1946
|
* @example
|
|
1685
1947
|
* isRegExp(/abc/); // ➔ true
|
|
1686
1948
|
* isRegExp(new RegExp("abc")); // ➔ true
|
|
@@ -1698,7 +1960,7 @@ declare const isRegExp:(value:unknown)=>value is RegExp;
|
|
|
1698
1960
|
* - It can be exactly represented without rounding errors.
|
|
1699
1961
|
* - It lies within the range **-(2^53 - 1) to 2^53 - 1**.
|
|
1700
1962
|
* - **Note:**
|
|
1701
|
-
* - This method is based on **{@link Number.isSafeInteger}**.
|
|
1963
|
+
* - This method is based on **{@link Number.isSafeInteger | `Number.isSafeInteger`}**.
|
|
1702
1964
|
* @param {*} value - The value to check.
|
|
1703
1965
|
* @returns {boolean} Return `true` if `value` is a safe integer, otherwise `false`.
|
|
1704
1966
|
* @example
|
|
@@ -1712,6 +1974,28 @@ declare const isRegExp:(value:unknown)=>value is RegExp;
|
|
|
1712
1974
|
* // ➔ false
|
|
1713
1975
|
*/
|
|
1714
1976
|
declare function isSafeInteger(value:unknown):value is number;
|
|
1977
|
+
/** ---------------------------------------------------------
|
|
1978
|
+
* * ***Environment Predicate: `isServer`.***
|
|
1979
|
+
* ---------------------------------------------------------
|
|
1980
|
+
* **Detects whether the current code is executing in a
|
|
1981
|
+
* **non-browser JavaScript runtime** (server-side) rather
|
|
1982
|
+
* than in a web browser.**
|
|
1983
|
+
* @description
|
|
1984
|
+
* It simply checks for the absence of key browser globals like
|
|
1985
|
+
* [**`window`**](https://developer.mozilla.org/docs/Web/API/Window/window) and
|
|
1986
|
+
* [**`document`**](https://developer.mozilla.org/docs/Web/API/Window/document).
|
|
1987
|
+
* - *If those globals aren’t present, we treat the runtime as a server environment.*
|
|
1988
|
+
* @returns {boolean}
|
|
1989
|
+
* * ***true** – Code is executing on the `server`.*
|
|
1990
|
+
* * ***false** – Code is executing in a `browser`.*
|
|
1991
|
+
* @example
|
|
1992
|
+
* if (isServer()) {
|
|
1993
|
+
* console.log("Running on a server-side runtime");
|
|
1994
|
+
* } else {
|
|
1995
|
+
* console.log("Running in a browser");
|
|
1996
|
+
* }
|
|
1997
|
+
*/
|
|
1998
|
+
declare const isServer:()=>boolean;
|
|
1715
1999
|
/** ---------------------------------------------------------
|
|
1716
2000
|
* * ***Type guard: `isSet`.***
|
|
1717
2001
|
* ----------------------------------------------------------
|
|
@@ -1751,6 +2035,20 @@ declare function isSet<T=unknown>(value:Set<T>):value is Set<T>;declare function
|
|
|
1751
2035
|
* }
|
|
1752
2036
|
*/
|
|
1753
2037
|
declare const isString:(value:unknown)=>value is string;
|
|
2038
|
+
/** ----------------------------------------------------
|
|
2039
|
+
* * ***Type guard: `isStringObject`.***
|
|
2040
|
+
* ----------------------------------------------------
|
|
2041
|
+
* **Checks if a value is a **`String` object wrapper**
|
|
2042
|
+
* (`new String(...)`), not a primitive string.**
|
|
2043
|
+
* @param {*} value The value to check.
|
|
2044
|
+
* @returns {boolean} Returns `true` if `value` is a `String` object.
|
|
2045
|
+
* @example
|
|
2046
|
+
* isStringObject(new String("hello"));
|
|
2047
|
+
* // ➔ true
|
|
2048
|
+
* isStringObject("hello");
|
|
2049
|
+
* // ➔ false
|
|
2050
|
+
*/
|
|
2051
|
+
declare function isStringObject(value:unknown):value is String;
|
|
1754
2052
|
/** ----------------------------------------------------------
|
|
1755
2053
|
* * ***Type guard: `isSymbol`.***
|
|
1756
2054
|
* ----------------------------------------------------------
|
|
@@ -1772,11 +2070,11 @@ declare const isSymbol:(value:unknown)=>value is symbol;
|
|
|
1772
2070
|
* * ***Type guard: `isTypedArray`.***
|
|
1773
2071
|
* ----------------------------------------------------------
|
|
1774
2072
|
* **Checks if `value` is classified as a
|
|
1775
|
-
* **[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)**.**
|
|
2073
|
+
* **[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray)**.**
|
|
1776
2074
|
* - **Behavior:**
|
|
1777
2075
|
* - Validates that `value` is a non-null object.
|
|
1778
2076
|
* - Uses `Object.prototype.toString` tag matching against known typed array tags.
|
|
1779
|
-
* - Narrows type to **{@link TypedArray}** when true.
|
|
2077
|
+
* - Narrows type to **{@link TypedArray | `TypedArray`}** when true.
|
|
1780
2078
|
* @param {*} value - The value to check.
|
|
1781
2079
|
* @returns {boolean} Returns `true` if the value is a typed array, otherwise `false`.
|
|
1782
2080
|
* @example
|
|
@@ -1830,7 +2128,7 @@ declare const isUndefined:(value:unknown)=>value is undefined;
|
|
|
1830
2128
|
* **Validates whether a given string is a properly formatted URL.**
|
|
1831
2129
|
* - **Ensures that the input is:**
|
|
1832
2130
|
* - A non-empty string.
|
|
1833
|
-
* - A valid **[URL](https://developer.mozilla.org/docs/Web/API/URL)** with `http://` or `https://` scheme.
|
|
2131
|
+
* - A valid **[`URL`](https://developer.mozilla.org/docs/Web/API/URL)** with `http://` or `https://` scheme.
|
|
1834
2132
|
* - **Behavior:**
|
|
1835
2133
|
* - ✅ Includes decoding for percent-encoded URLs (e.g., `https%3A%2F%2F...`).
|
|
1836
2134
|
* - ❌ Rejects invalid strings, unsupported schemes, and malformed domains.
|
|
@@ -1862,4 +2160,25 @@ declare const isValidURL:(url:unknown)=>boolean;
|
|
|
1862
2160
|
* isWeakMap(new Map);
|
|
1863
2161
|
* // ➔ false
|
|
1864
2162
|
*/
|
|
1865
|
-
declare function isWeakMap<K extends object=object,V=unknown>(value:unknown):value is WeakMap<K,V>;
|
|
2163
|
+
declare function isWeakMap<K extends object=object,V=unknown>(value:unknown):value is WeakMap<K,V>;
|
|
2164
|
+
/** ----------------------------------------------------------
|
|
2165
|
+
* * ***List of common acronyms that should remain uppercase in formatted output, extend this list if you have more acronyms to support.***
|
|
2166
|
+
* ----------------------------------------------------------
|
|
2167
|
+
*
|
|
2168
|
+
* - **⚠️ Internal:**
|
|
2169
|
+
* - Helper constant for **{@link getPreciseType | `getPreciseType`}**.
|
|
2170
|
+
* - Don't use on your code base, this internal helper of **{@link getPreciseType | `getPreciseType`}** function.
|
|
2171
|
+
*/
|
|
2172
|
+
declare const __internalAcronyms__:readonly string[];
|
|
2173
|
+
/** ----------------------------------------------------------
|
|
2174
|
+
* * ***Mapping of common JavaScript built-in and environment-specific
|
|
2175
|
+
* type names to canonical human-readable PascalCase strings.***
|
|
2176
|
+
* ----------------------------------------------------------
|
|
2177
|
+
* ***Keys are normalized for flexible matching, values are formatted names used as type descriptions.***
|
|
2178
|
+
* @description
|
|
2179
|
+
* Add or remove entries depending on your target environment.
|
|
2180
|
+
* - **⚠️ Internal:**
|
|
2181
|
+
* - Helper constant for **{@link getPreciseType | `getPreciseType`}**.
|
|
2182
|
+
* - Don't use on your code base, this internal helper of **{@link getPreciseType | `getPreciseType`}** function.
|
|
2183
|
+
*/
|
|
2184
|
+
declare const FIXES_RAW:{readonly string:"String";readonly number:"Number";readonly boolean:"Boolean";readonly bigint:"Big Int";readonly symbol:"Symbol";readonly undefined:"Undefined";readonly null:"Null";readonly regexp:"Reg Exp";readonly reflect:"Reflect";readonly proxy:"Proxy";readonly atomics:"Atomics";readonly object:"Object";readonly array:"Array";readonly arguments:"Arguments";readonly function:"Function";readonly asyncfunction:"Async Function";readonly generatorfunction:"Generator Function";readonly asyncgeneratorfunction:"Async Generator Function";readonly generator:"Generator";readonly promise:"Promise";readonly evalerror:"Eval Error";readonly rangeerror:"Range Error";readonly referenceerror:"Reference Error";readonly syntaxerror:"Syntax Error";readonly typeerror:"Type Error";readonly urierror:"URI Error";readonly aggregateerror:"Aggregate Error";readonly error:"Error";readonly int8array:"Int 8 Array";readonly uint8array:"Uint 8 Array";readonly uint8clampedarray:"Uint 8 Clamped Array";readonly int16array:"Int 16 Array";readonly uint16array:"Uint 16 Array";readonly int32array:"Int 32 Array";readonly uint32array:"Uint 32 Array";readonly float32array:"Float 32 Array";readonly float64array:"Float 64 Array";readonly bigint64array:"Big Int 64 Array";readonly biguint64array:"Big Uint 64 Array";readonly arraybuffer:"Array Buffer";readonly sharedarraybuffer:"Shared Array Buffer";readonly dataview:"Data View";readonly arraybufferview:"Array Buffer View";readonly map:"Map";readonly set:"Set";readonly weakmap:"Weak Map";readonly weakset:"Weak Set";readonly mapiterator:"Map Iterator";readonly setiterator:"Set Iterator";readonly arrayiterator:"Array Iterator";readonly stringiterator:"String Iterator";readonly readablestream:"Readable Stream";readonly writablestream:"Writable Stream";readonly transformstream:"Transform Stream";readonly readablestreamdefaultreader:"Readable Stream Default Reader";readonly writablestreamdefaultwriter:"Writable Stream Default Writer";readonly readablestreamdefaultcontroller:"Readable Stream Default Controller";readonly transformstreamdefaultcontroller:"Transform Stream Default Controller";readonly abortcontroller:"Abort Controller";readonly abortsignal:"Abort Signal";readonly fetch:"fetch";readonly request:"Request";readonly response:"Response";readonly headers:"Headers";readonly formdata:"FormData";readonly blob:"Blob";readonly file:"File";readonly filelist:"FileList";readonly filereader:"FileReader";readonly intl:"Intl";readonly collator:"Intl. Collator";readonly datetimeformat:"Intl. Date Time Format";readonly listformat:"Intl. List Format";readonly numberformat:"Intl. Number Format";readonly pluralrules:"Intl. Plural Rules";readonly relativetimeformat:"Intl. Relative Time Format";readonly segmenter:"Intl. Segmenter";readonly locale:"Intl. Locale";readonly displaynames:"Intl. Display Names";readonly finalizationregistry:"Finalization Registry";readonly weakref:"Weak Ref";readonly structuredclone:"structured Clone";readonly urlpattern:"URL Pattern";readonly performance:"Performance";readonly performanceobserver:"Performance Observer";readonly performanceentry:"Performance Entry";readonly performancemark:"Performance Mark";readonly performancemeasure:"Performance Measure";readonly webassembly:"Web Assembly";readonly wasmmodule:"WebAssembly .Module";readonly wasminstance:"WebAssembly. Instance";readonly wasmmemory:"WebAssembly. Memory";readonly wasmtable:"WebAssembly. Table";readonly buffer:"Buffer";readonly process:"Process";readonly eventemitter:"Event Emitter";readonly stream:"Stream";readonly fs:"fs";readonly path:"path";readonly url:"URL";readonly urlsearchparams:"URL Search Params";readonly node:"Node";readonly element:"Element";readonly htmlelement:"HTML Element";readonly svgelement:"SVG Element";readonly document:"Document";readonly documentfragment:"Document Fragment";readonly shadowroot:"Shadow Root";readonly nodelist:"Node List";readonly htmlcollection:"HTML Collection";readonly mutationobserver:"Mutation Observer";readonly intersectionobserver:"Intersection Observer";readonly resizeobserver:"Resize Observer";};export{FIXES_RAW,type IsArrayResult,IsPlainObjectResult,__internalAcronyms__,areArraysEqual,areObjectsEqual,areURLsEqualPath,areURLsIdentical,arrayHasAnyMatch,doesKeyExist,hasOwnProp,isArguments,isArray,isArrayBuffer,isArrayLike,isArrayLikeObject,isBigInt,isBoolean,isBooleanObject,isBuffer,isCurrencyLike,isDate,isDeepEqual,isElement,isEmpty,isEmptyArray,isEmptyDeep,isEmptyObject,isEmptyString,isEmptyValue,isEqual,isEqualWith,isError,isFinite,isFunction,isInfinityNumber,isInteger,isLength,isMap,isMatch,isMatchWith,isNaN,isNative,isNil,isNonEmptyArray,isNonEmptyString,isNonEmptyValue,isNull,isNumberObject,isObject,isObjectLoose,isObjectOrArray,isPropertyKey,isRegExp,isSafeInteger,isServer,isSet,isString,isStringObject,isSymbol,isTypedArray,isURL,isUndefined,isValidURL,isWeakMap,textContainsAll,textContainsAny};
|