@rzl-zone/utils-js 3.10.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -129
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +487 -215
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-SN5HAK3Y.js → chunk-22V4WP3H.js} +4 -4
- package/dist/{chunk-EJV5AF4L.js → chunk-2XSZ2ANI.js} +2 -2
- package/dist/{chunk-OSSFLQDD.js → chunk-3T6VSWYX.js} +2 -2
- package/dist/{chunk-3LE6NX57.js → chunk-5WIEDF2J.js} +4 -4
- package/dist/{chunk-WLEZ2KSG.cjs → chunk-6EDFZJZ5.cjs} +126 -126
- package/dist/{chunk-GHU356XQ.js → chunk-6LXWT2I5.js} +3 -3
- package/dist/{chunk-GKDSBOYE.js → chunk-6YGBRENU.js} +3 -3
- package/dist/{chunk-NAOVH4OH.cjs → chunk-7FGNVDEV.cjs} +7 -7
- package/dist/{chunk-X6ULJZ3X.js → chunk-AXDYWO67.js} +2 -2
- package/dist/{chunk-UV5BKAYW.cjs → chunk-B6PMNZ4M.cjs} +7 -7
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-YHFRCVTN.js → chunk-BLF7SD66.js} +3 -3
- package/dist/{chunk-QZI5PVCI.cjs → chunk-BMZZXZJ2.cjs} +4 -4
- package/dist/{chunk-DXPM4NOU.js → chunk-BOYP3ARU.js} +4 -4
- package/dist/{chunk-UXT4XSUK.js → chunk-BPYW5YL7.js} +2 -2
- package/dist/{chunk-QGTFQ7RO.cjs → chunk-C2PV3VWC.cjs} +6 -6
- package/dist/{chunk-MZ3T6L7Z.js → chunk-CCJ2MSN7.js} +2 -2
- package/dist/{chunk-H44QVAZL.cjs → chunk-DAPAK2W3.cjs} +31 -31
- package/dist/{chunk-OYFUBKEG.cjs → chunk-DLS3G6WQ.cjs} +4 -4
- package/dist/{chunk-MS2KSKD7.js → chunk-DNMCR5JH.js} +9 -9
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-IX6PF5ZP.cjs → chunk-EBYFYZW4.cjs} +4 -4
- package/dist/{chunk-5Y6JL47L.js → chunk-ENMRZ4BE.js} +3 -3
- package/dist/{chunk-7EIFPHV3.js → chunk-FJ4BQFVO.js} +8 -8
- package/dist/{chunk-TJ5OY6MC.cjs → chunk-GIKL4PUF.cjs} +10 -10
- package/dist/{chunk-M5QB2GM5.js → chunk-GOFINGT6.js} +2 -2
- package/dist/{chunk-J6VLFVIL.js → chunk-GXKQ3LHF.js} +3 -3
- package/dist/{chunk-5KDVIEVO.js → chunk-HNBRGN4R.js} +2 -2
- package/dist/{chunk-OCTHWEZK.cjs → chunk-HYN6FC5A.cjs} +34 -34
- package/dist/{chunk-MBFVTGYS.js → chunk-IZGVBYFN.js} +4 -4
- package/dist/{chunk-QXTJVDWE.js → chunk-JIE447J5.js} +3 -3
- package/dist/{chunk-UFYMRRJH.cjs → chunk-JXEIJM5M.cjs} +61 -61
- package/dist/{chunk-WB3FT62A.js → chunk-K47GZDBH.js} +3 -3
- package/dist/{chunk-KUVRZ2JW.cjs → chunk-K5536YHG.cjs} +50 -50
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-NJ24M6ZH.cjs → chunk-KXJ7X325.cjs} +37 -37
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-SRWL4YCP.js → chunk-LJHPTLWB.js} +7 -7
- package/dist/{chunk-6AMDHVS2.cjs → chunk-M7ELWZXM.cjs} +9 -9
- package/dist/chunk-MSUW5VHZ.js +1590 -0
- package/dist/{chunk-2XGQQZ6A.cjs → chunk-MUHRPRR7.cjs} +3 -3
- package/dist/{chunk-XYWC4EQ3.cjs → chunk-MV3TSQSH.cjs} +71 -71
- package/dist/{chunk-VCYXNIZ2.cjs → chunk-NLZLXWAU.cjs} +9 -9
- package/dist/{chunk-76ATVDCR.cjs → chunk-NVRZPF5M.cjs} +3 -3
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-62FS7WMB.cjs → chunk-PGNL7JXO.cjs} +31 -31
- package/dist/{chunk-JI57K7D4.cjs → chunk-Q4GEQS7X.cjs} +161 -161
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/{chunk-ZTHJQJ5F.cjs → chunk-QYI2VJLS.cjs} +9 -9
- package/dist/{chunk-C7GC2PFX.js → chunk-RBWZII5I.js} +3 -3
- package/dist/{chunk-MMRHKYT6.cjs → chunk-RMP7VMPB.cjs} +12 -12
- package/dist/{chunk-TXOVQZPU.js → chunk-RZOGBYIS.js} +2 -2
- package/dist/{chunk-ALRISPTL.cjs → chunk-SU3UELUB.cjs} +3 -3
- package/dist/chunk-SYHPSOUU.cjs +1626 -0
- package/dist/{chunk-R2DR7SPJ.js → chunk-SZUNAEMR.js} +6 -6
- package/dist/{chunk-YVRUY4EW.cjs → chunk-TER22LO4.cjs} +8 -8
- package/dist/{chunk-WRGN6UBK.js → chunk-TJHGRQ4P.js} +2 -2
- package/dist/{chunk-I33PB44Q.cjs → chunk-U23I7JPB.cjs} +15 -15
- package/dist/{chunk-VBSLIIDB.js → chunk-U7HHN47R.js} +10 -10
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-44X74C26.js → chunk-UIAWUZ4H.js} +4 -4
- package/dist/{chunk-5O66AUEC.js → chunk-ULQPCIA2.js} +2 -2
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-6WVOUVWD.js → chunk-WETQI6HM.js} +9 -9
- package/dist/{chunk-FWWPEL7J.cjs → chunk-WLOQQFDS.cjs} +3 -3
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-WKM6UVMG.cjs → chunk-WXFTVXBF.cjs} +4 -4
- package/dist/{chunk-YQHJB7KR.cjs → chunk-XPVTIGU2.cjs} +26 -26
- package/dist/{chunk-PWKOFPAH.cjs → chunk-XX6RUGTM.cjs} +3 -3
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/{chunk-7NXFGJJE.cjs → chunk-ZPDMWDGZ.cjs} +14 -14
- package/dist/{chunk-JYOCB6OV.js → chunk-ZVWZEGQP.js} +2 -2
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +489 -333
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +35 -29
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +917 -873
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +9 -9
- package/dist/generators/index.d.ts +104 -86
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/isPlainObject-0p3VveWr.d.ts +534 -0
- package/dist/next/index.cjs +37 -37
- package/dist/next/index.d.ts +36 -21
- package/dist/next/index.js +9 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +6 -3
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +14 -5
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -6
- package/dist/parsers/index.d.ts +68 -65
- package/dist/parsers/index.js +5 -5
- package/dist/predicates/index.cjs +77 -77
- package/dist/predicates/index.d.ts +442 -258
- package/dist/predicates/index.js +14 -14
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +28 -16
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +82 -54
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +186 -169
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -23
- package/dist/urls/index.d.ts +252 -229
- package/dist/urls/index.js +16 -16
- package/package.json +6 -4
- package/dist/chunk-7C7TQC5J.cjs +0 -620
- package/dist/chunk-J4TT33ZX.js +0 -584
- package/dist/isPlainObject-BTPjv6zB.d.ts +0 -178
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* ====================================================
|
|
3
|
-
* Rzl Utils-JS.
|
|
4
|
-
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.10.0.
|
|
6
|
-
* Author: Rizalvin Dwiky.
|
|
7
|
-
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
-
* ====================================================
|
|
9
|
-
*/
|
|
10
|
-
import{NonPlainObject}from'@rzl-zone/ts-types-plus';
|
|
11
|
-
/** ---------------------------------------------------------------------------
|
|
12
|
-
* * ***Type Options for {@link getPreciseType | `getPreciseType`}.***
|
|
13
|
-
* ---------------------------------------------------------------------------
|
|
14
|
-
*/
|
|
15
|
-
type GetPreciseTypeOptions={
|
|
16
|
-
/** -------------------------------------------------------
|
|
17
|
-
* * ***Specifies the format in which the returned string type should be transformed.***
|
|
18
|
-
* -------------------------------------------------------
|
|
19
|
-
* **ℹ️ For special string literals in `SPECIAL_CASES` (`"-Infinity" | "Infinity" | "NaN"`), which will remain unchanged.**
|
|
20
|
-
* @default "toLowerCase"
|
|
21
|
-
* @description
|
|
22
|
-
* Supported formats:
|
|
23
|
-
* - `"toLowerCase"` (default) — converts all letters to lowercase.
|
|
24
|
-
* - ➔ `"result example type"`
|
|
25
|
-
* - `"toDotCase"` — words separated by dots.
|
|
26
|
-
* - ➔ `"result.example.type"`
|
|
27
|
-
* - `"toCamelCase"` — first word lowercase, subsequent words capitalized.
|
|
28
|
-
* - ➔ `"resultExampleType"`
|
|
29
|
-
* - `"toKebabCase"` — words separated by hyphens.
|
|
30
|
-
* - ➔ `"result-example-type"`
|
|
31
|
-
* - `"toSnakeCase"` — words separated by underscores.
|
|
32
|
-
* - ➔ `"result_example_type"`
|
|
33
|
-
* - `"toPascalCase"` — all words capitalized, no spaces.
|
|
34
|
-
* - ➔ `"ResultExampleType"`
|
|
35
|
-
* - `"toPascalCaseSpace"` — all words capitalized with spaces between words.
|
|
36
|
-
* - ➔ `"Result Example Type"`
|
|
37
|
-
* - `"slugify"` — URL-friendly slug (lowercase with hyphens).
|
|
38
|
-
* - ➔ `"result-example-type"`
|
|
39
|
-
* @note
|
|
40
|
-
* ⚠️ If an invalid value is provided, the function will automatically fallback to the default `"toLowerCase"`.
|
|
41
|
-
*/
|
|
42
|
-
formatCase?:"toPascalCaseSpace"|"toPascalCase"|"toCamelCase"|"toKebabCase"|"toSnakeCase"|"toDotCase"|"slugify"|"toLowerCase";};
|
|
43
|
-
/** ----------------------------------------------------------
|
|
44
|
-
* * ***Utility-Predicate: `getPreciseType`.***
|
|
45
|
-
* ----------------------------------------------------------
|
|
46
|
-
* **Returns a detailed and normalized type string for the given value.**
|
|
47
|
-
* @description
|
|
48
|
-
* The returned string is human-readable _**toLowerCase**_ with spaces _***(by default)***_ or formatted according to the `options.formatCase` setting.
|
|
49
|
-
* - **Handles:**
|
|
50
|
-
* - Primitives (`string`, `number`, `boolean`, `null`, `undefined`, `symbol`, `bigint`)
|
|
51
|
-
* - Built-in objects (`Array`, `Map`, `Set`, `Error subclasses`, `Typed Arrays`, `etc`)
|
|
52
|
-
* - Objects created with `Object.create(null)`
|
|
53
|
-
* - Generator instances
|
|
54
|
-
* - Node.js `Buffer` instances
|
|
55
|
-
* - Proxy detection (returns `"Proxy"` if detected; detection is not 100% accurate)
|
|
56
|
-
* - Uses cached mapping table (`FIXES`) for known types to provide consistent naming
|
|
57
|
-
* - Falls back to constructor name or `Object.prototype.toString` tag
|
|
58
|
-
* @param {*} value - The value to detect the precise type of
|
|
59
|
-
* @param {GetPreciseTypeOptions} [options] - Optional configuration
|
|
60
|
-
* @param {GetPreciseTypeOptions["formatCase"]} [options.formatCase="toLowerCase"]
|
|
61
|
-
* Specifies how the returned type string should be formatted.
|
|
62
|
-
* - ⚠️ Special string literals in `SPECIAL_CASES`
|
|
63
|
-
* (`"-Infinity" | "Infinity" | "NaN"`) will remain
|
|
64
|
-
* unchanged even if a different `formatCase` is applied.
|
|
65
|
-
* @returns {string} The normalized and formatted type string
|
|
66
|
-
* @example
|
|
67
|
-
* getPreciseType(123); // ➔ "number"
|
|
68
|
-
* getPreciseType(null); // ➔ "null"
|
|
69
|
-
* getPreciseType(/regex/,{ formatCase: "toKebabCase" });
|
|
70
|
-
* // ➔ "reg-exp"
|
|
71
|
-
* getPreciseType(function* () {}, { formatCase: "toCamelCase" });
|
|
72
|
-
* // ➔ "generatorFunction"
|
|
73
|
-
* getPreciseType(async function () {}, { formatCase: "toPascalCaseSpace" });
|
|
74
|
-
* // ➔ "Async Function"
|
|
75
|
-
* getPreciseType(NaN, { formatCase: "toKebabCase" });
|
|
76
|
-
* // ➔ "NaN" (SPECIAL_CASES remain)
|
|
77
|
-
*/
|
|
78
|
-
declare const getPreciseType:(value:unknown,options?:GetPreciseTypeOptions)=>string;type IsNumberOptions={
|
|
79
|
-
/** If set to `true`, `NaN` will be considered a valid number, defaultValue: `false`.
|
|
80
|
-
*
|
|
81
|
-
* @default false
|
|
82
|
-
*/
|
|
83
|
-
includeNaN?:boolean;};
|
|
84
|
-
/** ---------------------------------------------------------
|
|
85
|
-
* * ***Type guard: `isNumber`.***
|
|
86
|
-
* ----------------------------------------------------------
|
|
87
|
-
* **Checks if a value is of type **`number`**.**
|
|
88
|
-
* - **Behavior:**
|
|
89
|
-
* - Uses `typeof value === "number"`.
|
|
90
|
-
* - By default, excludes **`NaN`**.
|
|
91
|
-
* - If `options.includeNaN` is `true`, then **`NaN`** is also considered valid.
|
|
92
|
-
* - Still considers `Infinity` and `-Infinity` as **numbers** (consistent with JavaScript).
|
|
93
|
-
* - **ℹ️ Note:**
|
|
94
|
-
* - To exclude `Infinity` and `-Infinity`, use **{@link isFinite | `isFinite`}** instead.
|
|
95
|
-
* @param {*} value - The value to check.
|
|
96
|
-
* @param {IsNumberOptions} [options] - Optional settings.
|
|
97
|
-
* @param {boolean} [options.includeNaN=false] If `true`, `NaN` will be considered a valid number, defaults to `false`, which excludes `NaN`.
|
|
98
|
-
* @returns {boolean} Returns `true` if the value is a number (and depending on `includeNaN`, `NaN` is included or excluded).
|
|
99
|
-
* @example
|
|
100
|
-
* isNumber(42);
|
|
101
|
-
* // ➔ true
|
|
102
|
-
* isNumber(Infinity);
|
|
103
|
-
* // ➔ true
|
|
104
|
-
* isNumber(-Infinity);
|
|
105
|
-
* // ➔ true
|
|
106
|
-
* isNumber(NaN);
|
|
107
|
-
* // ➔ false (default)
|
|
108
|
-
* isNumber(NaN, { includeNaN: true });
|
|
109
|
-
* // ➔ true
|
|
110
|
-
* isNumber("42");
|
|
111
|
-
* // ➔ false
|
|
112
|
-
*/
|
|
113
|
-
declare const isNumber:(value:unknown,options?:IsNumberOptions)=>value is number;type IsHasKeysObject<T>=keyof T extends never?false:true;
|
|
114
|
-
/** ----------------------------------------------------------
|
|
115
|
-
* * ***Utility type: `IsPlainObjectResult`.***
|
|
116
|
-
* ----------------------------------------------------------
|
|
117
|
-
* **Represents the inferred type after asserting a value is a **plain object**.**
|
|
118
|
-
* - **Behavior:**
|
|
119
|
-
* - If `T` is `unknown`, the resulting type is `Record<PropertyKey, unknown> & T`.
|
|
120
|
-
* - If `T` is an object:
|
|
121
|
-
* - If it is a non-plain object (class instance, built-in object, etc.), the result is `never`.
|
|
122
|
-
* - If it has no keys (`IsHasKeysObject<T>` checked by **{@link IsHasKeysObject|`IsHasKeysObject`}** is false), the result is `Record<PropertyKey, unknown> & T`.
|
|
123
|
-
* - Otherwise, the result is `T` itself.
|
|
124
|
-
* - For any other types, the result is `never`.
|
|
125
|
-
* @template T - The input type to be asserted as a plain object.
|
|
126
|
-
* @example
|
|
127
|
-
* ```ts
|
|
128
|
-
* type A = IsPlainObjectResult<unknown>;
|
|
129
|
-
* // ➔ Record<PropertyKey, unknown> & unknown
|
|
130
|
-
* type B = IsPlainObjectResult<{}>;
|
|
131
|
-
* // ➔ Record<PropertyKey, unknown> & {}
|
|
132
|
-
* type C = IsPlainObjectResult<{ foo: string }>;
|
|
133
|
-
* // ➔ { foo: string }
|
|
134
|
-
* type D = IsPlainObjectResult<Date>;
|
|
135
|
-
* // ➔ never
|
|
136
|
-
* ```
|
|
137
|
-
*/
|
|
138
|
-
type IsPlainObjectResult<T>=unknown extends T?Record<PropertyKey,unknown>& T:T extends object?T extends NonPlainObject?never:IsHasKeysObject<T>extends false?Record<PropertyKey,unknown>& T:T:Extract<T,Record<PropertyKey,unknown>>;
|
|
139
|
-
/** ----------------------------------------------------------
|
|
140
|
-
* * ***Type guard: `isPlainObject`.***
|
|
141
|
-
* ----------------------------------------------------------
|
|
142
|
-
* **Checks if a value is a **plain-object**.**
|
|
143
|
-
* - **A plain object is:**
|
|
144
|
-
* - Created by the `Object` constructor, or
|
|
145
|
-
* - Has a `[[Prototype]]` of `null` (e.g. `Object.create(null)`).
|
|
146
|
-
* - **✅ Returns `true` for:**
|
|
147
|
-
* - Empty object literals: `{}`
|
|
148
|
-
* - Objects with null prototype: `Object.create(null)`
|
|
149
|
-
* - **❌ Returns `false` for:**
|
|
150
|
-
* - Arrays (`[]`, `new Array()`)
|
|
151
|
-
* - Functions (regular, arrow, or class constructors)
|
|
152
|
-
* - Built-in objects: `Date`, `RegExp`, `Error`, `Map`, `Set`, `WeakMap`, `WeakSet`
|
|
153
|
-
* - Boxed primitives: `new String()`, `new Number()`, `new Boolean()`
|
|
154
|
-
* - `null` or `undefined`
|
|
155
|
-
* - Symbols
|
|
156
|
-
* - Class instances
|
|
157
|
-
* @template T - The type of the value being checked.
|
|
158
|
-
* @param {*} value - The value to check.
|
|
159
|
-
* @returns {boolean} Return `true` if `value` is a `plain-object`, otherwise `false`.
|
|
160
|
-
* @example
|
|
161
|
-
* isPlainObject({});
|
|
162
|
-
* // ➔ true
|
|
163
|
-
* isPlainObject(Object.create(null));
|
|
164
|
-
* // ➔ true
|
|
165
|
-
* isPlainObject(null);
|
|
166
|
-
* // ➔ false
|
|
167
|
-
* isPlainObject(() => {});
|
|
168
|
-
* // ➔ false
|
|
169
|
-
* isPlainObject([1, 2, 3]);
|
|
170
|
-
* // ➔ false
|
|
171
|
-
* isPlainObject(new Date());
|
|
172
|
-
* // ➔ false
|
|
173
|
-
* isPlainObject(new MyClass());
|
|
174
|
-
* // ➔ false
|
|
175
|
-
* isPlainObject(new String("x"));
|
|
176
|
-
* // ➔ false
|
|
177
|
-
*/
|
|
178
|
-
declare function isPlainObject<T>(value:T):value is IsPlainObjectResult<T>;declare function isPlainObject<T>(value:T):value is NonNullable<Extract<T,Record<PropertyKey,unknown>>>;export{type GetPreciseTypeOptions as G,type IsNumberOptions as I,type IsPlainObjectResult as a,isPlainObject as b,type IsHasKeysObject as c,getPreciseType as g,isNumber as i};
|