typetify 2.1.0 → 2.4.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.
Files changed (225) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/README.md +108 -0
  3. package/dist/async/index.js +1 -49
  4. package/dist/async/index.mjs +1 -4
  5. package/dist/chunk-272Z3AXV.js +1 -0
  6. package/dist/chunk-2YRFWQ6M.mjs +1 -0
  7. package/dist/chunk-35CB7HNN.js +1 -0
  8. package/dist/chunk-4JG7CFRK.js +1 -0
  9. package/dist/chunk-5FBZYPQM.mjs +1 -0
  10. package/dist/chunk-5XQRYI2Q.mjs +1 -0
  11. package/dist/chunk-6HA2SN23.js +1 -0
  12. package/dist/chunk-6NWIIOHH.js +1 -0
  13. package/dist/chunk-6WGRWYAD.js +1 -0
  14. package/dist/chunk-7LBL6CYT.js +1 -0
  15. package/dist/chunk-7UMXGQE4.mjs +1 -0
  16. package/dist/chunk-7XHBEA63.js +1 -0
  17. package/dist/chunk-B3R73UK5.mjs +1 -0
  18. package/dist/chunk-BLUG7TSP.js +1 -0
  19. package/dist/chunk-EAHFED6V.mjs +1 -0
  20. package/dist/chunk-EKSHS4DL.mjs +1 -0
  21. package/dist/chunk-F76ECQKE.js +1 -0
  22. package/dist/chunk-FHCBXSNA.js +1 -0
  23. package/dist/chunk-GKOA3XGQ.js +1 -0
  24. package/dist/chunk-GQIJLGEZ.mjs +1 -0
  25. package/dist/chunk-I4YSQ4HB.js +1 -0
  26. package/dist/chunk-JZXLCA2E.mjs +1 -0
  27. package/dist/chunk-M5OMYDI7.mjs +1 -0
  28. package/dist/chunk-MB77QAOC.mjs +1 -0
  29. package/dist/chunk-MPY3WRLG.mjs +1 -0
  30. package/dist/chunk-NENRAPOL.mjs +1 -0
  31. package/dist/chunk-NOW4Q26G.mjs +1 -0
  32. package/dist/chunk-P4UNM7SF.js +1 -0
  33. package/dist/chunk-P5E2JDCX.mjs +1 -0
  34. package/dist/chunk-Q7SUL7MD.js +1 -0
  35. package/dist/chunk-QKNZICUO.mjs +1 -0
  36. package/dist/chunk-RHMANSTA.mjs +1 -0
  37. package/dist/chunk-SF64HETW.js +1 -0
  38. package/dist/chunk-T66YO63J.js +1 -0
  39. package/dist/chunk-TNK6EVQK.mjs +1 -0
  40. package/dist/chunk-TSJFKV3R.js +1 -0
  41. package/dist/chunk-TVCWWECJ.mjs +1 -0
  42. package/dist/chunk-U7MK5AR5.mjs +1 -0
  43. package/dist/chunk-W5I352FJ.js +1 -0
  44. package/dist/chunk-WAT4QJB2.js +1 -0
  45. package/dist/chunk-WCG5ODRX.mjs +1 -0
  46. package/dist/chunk-WDFIRO2J.js +1 -0
  47. package/dist/chunk-WOT6VMZA.js +1 -0
  48. package/dist/chunk-WS743BFA.js +1 -0
  49. package/dist/chunk-WWU7P2L2.mjs +1 -0
  50. package/dist/chunk-XPY5CWKZ.mjs +1 -0
  51. package/dist/collection/index.d.mts +125 -1
  52. package/dist/collection/index.d.ts +125 -1
  53. package/dist/collection/index.js +1 -125
  54. package/dist/collection/index.mjs +1 -4
  55. package/dist/color/index.d.mts +274 -0
  56. package/dist/color/index.d.ts +274 -0
  57. package/dist/color/index.js +1 -0
  58. package/dist/color/index.mjs +1 -0
  59. package/dist/core/index.js +1 -41
  60. package/dist/core/index.mjs +1 -4
  61. package/dist/decorator/index.js +1 -57
  62. package/dist/decorator/index.mjs +1 -4
  63. package/dist/dom/index.d.mts +353 -0
  64. package/dist/dom/index.d.ts +353 -0
  65. package/dist/dom/index.js +1 -0
  66. package/dist/dom/index.mjs +1 -0
  67. package/dist/dx/index.js +1 -53
  68. package/dist/dx/index.mjs +1 -4
  69. package/dist/flow/index.js +1 -50
  70. package/dist/flow/index.mjs +1 -5
  71. package/dist/fn/index.js +1 -37
  72. package/dist/fn/index.mjs +1 -4
  73. package/dist/guards/index.js +1 -233
  74. package/dist/guards/index.mjs +1 -4
  75. package/dist/index.d.mts +482 -410
  76. package/dist/index.d.ts +482 -410
  77. package/dist/index.js +3 -2507
  78. package/dist/index.mjs +3 -1546
  79. package/dist/input/index.js +1 -74
  80. package/dist/input/index.mjs +1 -5
  81. package/dist/iterator/index.js +1 -85
  82. package/dist/iterator/index.mjs +1 -4
  83. package/dist/logic/index.js +1 -201
  84. package/dist/logic/index.mjs +1 -4
  85. package/dist/math/index.js +1 -45
  86. package/dist/math/index.mjs +1 -4
  87. package/dist/narrowing/index.js +1 -141
  88. package/dist/narrowing/index.mjs +1 -4
  89. package/dist/object/index.d.mts +137 -1
  90. package/dist/object/index.d.ts +137 -1
  91. package/dist/object/index.js +1 -113
  92. package/dist/object/index.mjs +1 -4
  93. package/dist/result/index.js +1 -86
  94. package/dist/result/index.mjs +1 -5
  95. package/dist/schema/index.js +1 -110
  96. package/dist/schema/index.mjs +1 -5
  97. package/dist/storage/index.d.mts +197 -0
  98. package/dist/storage/index.d.ts +197 -0
  99. package/dist/storage/index.js +1 -0
  100. package/dist/storage/index.mjs +1 -0
  101. package/dist/string/index.d.mts +201 -1
  102. package/dist/string/index.d.ts +201 -1
  103. package/dist/string/index.js +1 -49
  104. package/dist/string/index.mjs +1 -4
  105. package/dist/typed/index.js +1 -193
  106. package/dist/typed/index.mjs +1 -4
  107. package/package.json +23 -3
  108. package/dist/async/index.js.map +0 -1
  109. package/dist/async/index.mjs.map +0 -1
  110. package/dist/chunk-2LJ6NZ6K.js +0 -108
  111. package/dist/chunk-2LJ6NZ6K.js.map +0 -1
  112. package/dist/chunk-4NXETABV.mjs +0 -116
  113. package/dist/chunk-4NXETABV.mjs.map +0 -1
  114. package/dist/chunk-6ZBTL74K.js +0 -129
  115. package/dist/chunk-6ZBTL74K.js.map +0 -1
  116. package/dist/chunk-7G4ZSMQX.js +0 -470
  117. package/dist/chunk-7G4ZSMQX.js.map +0 -1
  118. package/dist/chunk-CN3GYRJN.mjs +0 -137
  119. package/dist/chunk-CN3GYRJN.mjs.map +0 -1
  120. package/dist/chunk-CNTE6ZVH.js +0 -359
  121. package/dist/chunk-CNTE6ZVH.js.map +0 -1
  122. package/dist/chunk-CWHYQWNU.mjs +0 -224
  123. package/dist/chunk-CWHYQWNU.mjs.map +0 -1
  124. package/dist/chunk-DBENOSTA.js +0 -156
  125. package/dist/chunk-DBENOSTA.js.map +0 -1
  126. package/dist/chunk-DWIG5GF2.js +0 -135
  127. package/dist/chunk-DWIG5GF2.js.map +0 -1
  128. package/dist/chunk-EAUTTWTQ.mjs +0 -231
  129. package/dist/chunk-EAUTTWTQ.mjs.map +0 -1
  130. package/dist/chunk-FEX5C4OH.mjs +0 -1007
  131. package/dist/chunk-FEX5C4OH.mjs.map +0 -1
  132. package/dist/chunk-FN553YPU.js +0 -441
  133. package/dist/chunk-FN553YPU.js.map +0 -1
  134. package/dist/chunk-FT2EK4AM.mjs +0 -420
  135. package/dist/chunk-FT2EK4AM.mjs.map +0 -1
  136. package/dist/chunk-FXWYPHA3.mjs +0 -13
  137. package/dist/chunk-FXWYPHA3.mjs.map +0 -1
  138. package/dist/chunk-GS3PP67B.js +0 -200
  139. package/dist/chunk-GS3PP67B.js.map +0 -1
  140. package/dist/chunk-IGA3VEZM.mjs +0 -503
  141. package/dist/chunk-IGA3VEZM.mjs.map +0 -1
  142. package/dist/chunk-J5LGTIGS.mjs +0 -9
  143. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  144. package/dist/chunk-JB6UXRKD.mjs +0 -97
  145. package/dist/chunk-JB6UXRKD.mjs.map +0 -1
  146. package/dist/chunk-JQAQV75V.js +0 -561
  147. package/dist/chunk-JQAQV75V.js.map +0 -1
  148. package/dist/chunk-JQHUBZ4M.js +0 -88
  149. package/dist/chunk-JQHUBZ4M.js.map +0 -1
  150. package/dist/chunk-LT7JK7RJ.js +0 -87
  151. package/dist/chunk-LT7JK7RJ.js.map +0 -1
  152. package/dist/chunk-N6IUADIP.mjs +0 -414
  153. package/dist/chunk-N6IUADIP.mjs.map +0 -1
  154. package/dist/chunk-OEJK37LO.mjs +0 -328
  155. package/dist/chunk-OEJK37LO.mjs.map +0 -1
  156. package/dist/chunk-OKB3MS5F.js +0 -547
  157. package/dist/chunk-OKB3MS5F.js.map +0 -1
  158. package/dist/chunk-OPVES6W2.js +0 -16
  159. package/dist/chunk-OPVES6W2.js.map +0 -1
  160. package/dist/chunk-OWNUKWXV.js +0 -291
  161. package/dist/chunk-OWNUKWXV.js.map +0 -1
  162. package/dist/chunk-POD52NJ3.mjs +0 -526
  163. package/dist/chunk-POD52NJ3.mjs.map +0 -1
  164. package/dist/chunk-PQTXSQ4P.js +0 -369
  165. package/dist/chunk-PQTXSQ4P.js.map +0 -1
  166. package/dist/chunk-PZ5AY32C.js +0 -11
  167. package/dist/chunk-PZ5AY32C.js.map +0 -1
  168. package/dist/chunk-QFR7DVAJ.mjs +0 -63
  169. package/dist/chunk-QFR7DVAJ.mjs.map +0 -1
  170. package/dist/chunk-S535LAXW.js +0 -1054
  171. package/dist/chunk-S535LAXW.js.map +0 -1
  172. package/dist/chunk-SGQNLTRK.js +0 -73
  173. package/dist/chunk-SGQNLTRK.js.map +0 -1
  174. package/dist/chunk-SRDWUHDY.mjs +0 -188
  175. package/dist/chunk-SRDWUHDY.mjs.map +0 -1
  176. package/dist/chunk-TXU7NTT4.js +0 -249
  177. package/dist/chunk-TXU7NTT4.js.map +0 -1
  178. package/dist/chunk-TZEWREAC.mjs +0 -277
  179. package/dist/chunk-TZEWREAC.mjs.map +0 -1
  180. package/dist/chunk-V6CWFDIJ.mjs +0 -123
  181. package/dist/chunk-V6CWFDIJ.mjs.map +0 -1
  182. package/dist/chunk-X55EORNF.js +0 -259
  183. package/dist/chunk-X55EORNF.js.map +0 -1
  184. package/dist/chunk-YBJC5WMX.mjs +0 -341
  185. package/dist/chunk-YBJC5WMX.mjs.map +0 -1
  186. package/dist/chunk-YOPAXITF.mjs +0 -75
  187. package/dist/chunk-YOPAXITF.mjs.map +0 -1
  188. package/dist/chunk-ZE4FDBRI.mjs +0 -79
  189. package/dist/chunk-ZE4FDBRI.mjs.map +0 -1
  190. package/dist/collection/index.js.map +0 -1
  191. package/dist/collection/index.mjs.map +0 -1
  192. package/dist/core/index.js.map +0 -1
  193. package/dist/core/index.mjs.map +0 -1
  194. package/dist/decorator/index.js.map +0 -1
  195. package/dist/decorator/index.mjs.map +0 -1
  196. package/dist/dx/index.js.map +0 -1
  197. package/dist/dx/index.mjs.map +0 -1
  198. package/dist/flow/index.js.map +0 -1
  199. package/dist/flow/index.mjs.map +0 -1
  200. package/dist/fn/index.js.map +0 -1
  201. package/dist/fn/index.mjs.map +0 -1
  202. package/dist/guards/index.js.map +0 -1
  203. package/dist/guards/index.mjs.map +0 -1
  204. package/dist/index.js.map +0 -1
  205. package/dist/index.mjs.map +0 -1
  206. package/dist/input/index.js.map +0 -1
  207. package/dist/input/index.mjs.map +0 -1
  208. package/dist/iterator/index.js.map +0 -1
  209. package/dist/iterator/index.mjs.map +0 -1
  210. package/dist/logic/index.js.map +0 -1
  211. package/dist/logic/index.mjs.map +0 -1
  212. package/dist/math/index.js.map +0 -1
  213. package/dist/math/index.mjs.map +0 -1
  214. package/dist/narrowing/index.js.map +0 -1
  215. package/dist/narrowing/index.mjs.map +0 -1
  216. package/dist/object/index.js.map +0 -1
  217. package/dist/object/index.mjs.map +0 -1
  218. package/dist/result/index.js.map +0 -1
  219. package/dist/result/index.mjs.map +0 -1
  220. package/dist/schema/index.js.map +0 -1
  221. package/dist/schema/index.mjs.map +0 -1
  222. package/dist/string/index.js.map +0 -1
  223. package/dist/string/index.mjs.map +0 -1
  224. package/dist/typed/index.js.map +0 -1
  225. package/dist/typed/index.mjs.map +0 -1
@@ -1,97 +0,0 @@
1
- import { __export } from './chunk-J5LGTIGS.mjs';
2
-
3
- // src/math/index.ts
4
- var math_exports = {};
5
- __export(math_exports, {
6
- average: () => average,
7
- max: () => max,
8
- median: () => median,
9
- min: () => min,
10
- percentage: () => percentage,
11
- randomFloat: () => randomFloat,
12
- randomInt: () => randomInt,
13
- round: () => round,
14
- sum: () => sum
15
- });
16
-
17
- // src/math/sum.ts
18
- function sum(numbers) {
19
- let total = 0;
20
- for (const n of numbers) {
21
- total += n;
22
- }
23
- return total;
24
- }
25
-
26
- // src/math/average.ts
27
- function average(numbers) {
28
- if (numbers.length === 0) return NaN;
29
- let total = 0;
30
- for (const n of numbers) {
31
- total += n;
32
- }
33
- return total / numbers.length;
34
- }
35
-
36
- // src/math/median.ts
37
- function median(numbers) {
38
- if (numbers.length === 0) return NaN;
39
- const sorted = [...numbers].sort((a, b) => a - b);
40
- const mid = Math.floor(sorted.length / 2);
41
- if (sorted.length % 2 === 0) {
42
- return (sorted[mid - 1] + sorted[mid]) / 2;
43
- }
44
- return sorted[mid];
45
- }
46
-
47
- // src/math/round.ts
48
- function round(num, precision = 0) {
49
- const factor = Math.pow(10, precision);
50
- return Math.round(num * factor) / factor;
51
- }
52
-
53
- // src/math/randomInt.ts
54
- function randomInt(min2, max2) {
55
- min2 = Math.ceil(min2);
56
- max2 = Math.floor(max2);
57
- return Math.floor(Math.random() * (max2 - min2 + 1)) + min2;
58
- }
59
-
60
- // src/math/randomFloat.ts
61
- function randomFloat(min2, max2) {
62
- return Math.random() * (max2 - min2) + min2;
63
- }
64
-
65
- // src/math/percentage.ts
66
- function percentage(value, total) {
67
- if (total === 0) return 0;
68
- return value / total * 100;
69
- }
70
-
71
- // src/math/min.ts
72
- function min(numbers) {
73
- if (numbers.length === 0) return void 0;
74
- let result = numbers[0];
75
- for (let i = 1; i < numbers.length; i++) {
76
- if (numbers[i] < result) {
77
- result = numbers[i];
78
- }
79
- }
80
- return result;
81
- }
82
-
83
- // src/math/max.ts
84
- function max(numbers) {
85
- if (numbers.length === 0) return void 0;
86
- let result = numbers[0];
87
- for (let i = 1; i < numbers.length; i++) {
88
- if (numbers[i] > result) {
89
- result = numbers[i];
90
- }
91
- }
92
- return result;
93
- }
94
-
95
- export { average, math_exports, max, median, min, percentage, randomFloat, randomInt, round, sum };
96
- //# sourceMappingURL=chunk-JB6UXRKD.mjs.map
97
- //# sourceMappingURL=chunk-JB6UXRKD.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/math/index.ts","../src/math/sum.ts","../src/math/average.ts","../src/math/median.ts","../src/math/round.ts","../src/math/randomInt.ts","../src/math/randomFloat.ts","../src/math/percentage.ts","../src/math/min.ts","../src/math/max.ts"],"names":["min","max"],"mappings":"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","file":"chunk-JB6UXRKD.mjs","sourcesContent":["export { sum } from './sum'\nexport { average } from './average'\nexport { median } from './median'\nexport { round } from './round'\nexport { randomInt } from './randomInt'\nexport { randomFloat } from './randomFloat'\nexport { percentage } from './percentage'\nexport { min } from './min'\nexport { max } from './max'\n","/**\n * Returns the sum of all numbers in an array.\n *\n * @example\n * sum([1, 2, 3, 4, 5]) // 15\n * sum([]) // 0\n */\nexport function sum(numbers: readonly number[]): number {\n let total = 0\n for (const n of numbers) {\n total += n\n }\n return total\n}\n","/**\n * Returns the average (mean) of all numbers in an array.\n *\n * @example\n * average([1, 2, 3, 4, 5]) // 3\n * average([10, 20]) // 15\n * average([]) // NaN\n */\nexport function average(numbers: readonly number[]): number {\n if (numbers.length === 0) return NaN\n let total = 0\n for (const n of numbers) {\n total += n\n }\n return total / numbers.length\n}\n","/**\n * Returns the median of all numbers in an array.\n *\n * @example\n * median([1, 2, 3, 4, 5]) // 3\n * median([1, 2, 3, 4]) // 2.5\n * median([]) // NaN\n */\nexport function median(numbers: readonly number[]): number {\n if (numbers.length === 0) return NaN\n\n const sorted = [...numbers].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n\n if (sorted.length % 2 === 0) {\n return (sorted[mid - 1]! + sorted[mid]!) / 2\n }\n\n return sorted[mid]!\n}\n","/**\n * Rounds a number to a specified precision.\n *\n * @example\n * round(3.14159, 2) // 3.14\n * round(3.5) // 4\n * round(1234.5, -2) // 1200\n */\nexport function round(num: number, precision: number = 0): number {\n const factor = Math.pow(10, precision)\n return Math.round(num * factor) / factor\n}\n","/**\n * Returns a random integer between min and max (inclusive).\n *\n * @example\n * randomInt(1, 10) // Random integer from 1 to 10\n * randomInt(0, 100) // Random integer from 0 to 100\n */\nexport function randomInt(min: number, max: number): number {\n min = Math.ceil(min)\n max = Math.floor(max)\n return Math.floor(Math.random() * (max - min + 1)) + min\n}\n","/**\n * Returns a random float between min and max.\n *\n * @example\n * randomFloat(0, 1) // Random float from 0 to 1\n * randomFloat(1.5, 3.5) // Random float from 1.5 to 3.5\n */\nexport function randomFloat(min: number, max: number): number {\n return Math.random() * (max - min) + min\n}\n","/**\n * Calculates the percentage of a value relative to a total.\n *\n * @example\n * percentage(25, 100) // 25\n * percentage(1, 4) // 25\n * percentage(0, 100) // 0\n */\nexport function percentage(value: number, total: number): number {\n if (total === 0) return 0\n return (value / total) * 100\n}\n","/**\n * Returns the minimum value in an array.\n *\n * @example\n * min([3, 1, 4, 1, 5]) // 1\n * min([]) // undefined\n */\nexport function min(numbers: readonly number[]): number | undefined {\n if (numbers.length === 0) return undefined\n let result = numbers[0]!\n for (let i = 1; i < numbers.length; i++) {\n if (numbers[i]! < result) {\n result = numbers[i]!\n }\n }\n return result\n}\n","/**\n * Returns the maximum value in an array.\n *\n * @example\n * max([3, 1, 4, 1, 5]) // 5\n * max([]) // undefined\n */\nexport function max(numbers: readonly number[]): number | undefined {\n if (numbers.length === 0) return undefined\n let result = numbers[0]!\n for (let i = 1; i < numbers.length; i++) {\n if (numbers[i]! > result) {\n result = numbers[i]!\n }\n }\n return result\n}\n"]}
@@ -1,561 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkPZ5AY32C_js = require('./chunk-PZ5AY32C.js');
4
-
5
- // src/guards/index.ts
6
- var guards_exports = {};
7
- chunkPZ5AY32C_js.__export(guards_exports, {
8
- castArray: () => castArray,
9
- cloneDeepWith: () => cloneDeepWith,
10
- cloneWith: () => cloneWith,
11
- conformsTo: () => conformsTo,
12
- eq: () => eq,
13
- gt: () => gt,
14
- gte: () => gte,
15
- hasKey: () => hasKey,
16
- hasKeys: () => hasKeys,
17
- isArguments: () => isArguments,
18
- isArray: () => isArray,
19
- isArrayBuffer: () => isArrayBuffer,
20
- isArrayLike: () => isArrayLike,
21
- isArrayLikeObject: () => isArrayLikeObject,
22
- isBoolean: () => isBoolean,
23
- isBuffer: () => isBuffer,
24
- isDate: () => isDate,
25
- isElement: () => isElement,
26
- isEmpty: () => isEmpty,
27
- isEqualWith: () => isEqualWith,
28
- isError: () => isError,
29
- isFinite: () => isFinite,
30
- isFunction: () => isFunction,
31
- isInteger: () => isInteger,
32
- isLength: () => isLength,
33
- isMap: () => isMap,
34
- isMatch: () => isMatch,
35
- isMatchWith: () => isMatchWith,
36
- isNaN: () => isNaN,
37
- isNative: () => isNative,
38
- isNonEmpty: () => isNonEmpty,
39
- isNull: () => isNull,
40
- isNumber: () => isNumber,
41
- isObject: () => isObject,
42
- isObjectLike: () => isObjectLike,
43
- isPlainObject: () => isPlainObject,
44
- isPromise: () => isPromise,
45
- isRegExp: () => isRegExp,
46
- isSafeInteger: () => isSafeInteger,
47
- isSet: () => isSet,
48
- isString: () => isString,
49
- isSymbol: () => isSymbol,
50
- isTypedArray: () => isTypedArray,
51
- isUndefined: () => isUndefined,
52
- isWeakMap: () => isWeakMap,
53
- isWeakSet: () => isWeakSet,
54
- lt: () => lt,
55
- lte: () => lte,
56
- toArray: () => toArray,
57
- toFinite: () => toFinite,
58
- toInteger: () => toInteger,
59
- toLength: () => toLength,
60
- toNumber: () => toNumber,
61
- toPlainObject: () => toPlainObject,
62
- toSafeInteger: () => toSafeInteger,
63
- toString: () => toString
64
- });
65
-
66
- // src/guards/isObject.ts
67
- function isObject(value) {
68
- return typeof value === "object" && value !== null && !Array.isArray(value);
69
- }
70
-
71
- // src/guards/isPlainObject.ts
72
- function isPlainObject(value) {
73
- if (typeof value !== "object" || value === null) {
74
- return false;
75
- }
76
- const prototype = Object.getPrototypeOf(value);
77
- return prototype === null || prototype === Object.prototype;
78
- }
79
-
80
- // src/guards/isString.ts
81
- function isString(value) {
82
- return typeof value === "string";
83
- }
84
-
85
- // src/guards/isNumber.ts
86
- function isNumber(value) {
87
- return typeof value === "number" && !Number.isNaN(value);
88
- }
89
-
90
- // src/guards/isBoolean.ts
91
- function isBoolean(value) {
92
- return typeof value === "boolean";
93
- }
94
-
95
- // src/guards/isFunction.ts
96
- function isFunction(value) {
97
- return typeof value === "function";
98
- }
99
-
100
- // src/guards/isArray.ts
101
- function isArray(value, guard) {
102
- if (!Array.isArray(value)) {
103
- return false;
104
- }
105
- if (guard) {
106
- return value.every(guard);
107
- }
108
- return true;
109
- }
110
-
111
- // src/guards/isDate.ts
112
- function isDate(value) {
113
- return value instanceof Date && !Number.isNaN(value.getTime());
114
- }
115
-
116
- // src/guards/isPromise.ts
117
- function isPromise(value) {
118
- return value instanceof Promise || value !== null && typeof value === "object" && "then" in value && typeof value.then === "function";
119
- }
120
-
121
- // src/guards/isError.ts
122
- function isError(value) {
123
- return value instanceof Error;
124
- }
125
-
126
- // src/guards/isSymbol.ts
127
- function isSymbol(value) {
128
- return typeof value === "symbol";
129
- }
130
-
131
- // src/guards/hasKey.ts
132
- function hasKey(obj, key) {
133
- return obj !== null && typeof obj === "object" && key in obj;
134
- }
135
-
136
- // src/guards/hasKeys.ts
137
- function hasKeys(obj, keys) {
138
- if (obj === null || typeof obj !== "object") {
139
- return false;
140
- }
141
- return keys.every((key) => key in obj);
142
- }
143
-
144
- // src/guards/isEmpty.ts
145
- function isEmpty(value) {
146
- if (value === null || value === void 0) {
147
- return true;
148
- }
149
- if (typeof value === "string") {
150
- return value.trim().length === 0;
151
- }
152
- if (Array.isArray(value)) {
153
- return value.length === 0;
154
- }
155
- if (value instanceof Map || value instanceof Set) {
156
- return value.size === 0;
157
- }
158
- if (typeof value === "object") {
159
- return Object.keys(value).length === 0;
160
- }
161
- return false;
162
- }
163
-
164
- // src/guards/isNonEmpty.ts
165
- function isNonEmpty(value) {
166
- return !isEmpty(value);
167
- }
168
-
169
- // src/guards/castArray.ts
170
- function castArray(value) {
171
- if (Array.isArray(value)) {
172
- return [...value];
173
- }
174
- return [value];
175
- }
176
-
177
- // src/guards/cloneWith.ts
178
- function cloneWith(value, customizer) {
179
- const result = customizer(value);
180
- if (result !== void 0) return result;
181
- if (value === null || typeof value !== "object") {
182
- return value;
183
- }
184
- if (Array.isArray(value)) {
185
- return value.map((item) => {
186
- const customResult = customizer(item);
187
- return customResult !== void 0 ? customResult : item;
188
- });
189
- }
190
- const cloned = {};
191
- for (const key of Object.keys(value)) {
192
- const val = value[key];
193
- const customResult = customizer(val);
194
- cloned[key] = customResult !== void 0 ? customResult : val;
195
- }
196
- return cloned;
197
- }
198
-
199
- // src/guards/cloneDeepWith.ts
200
- function cloneDeepWith(value, customizer) {
201
- const result = customizer(value);
202
- if (result !== void 0) return result;
203
- if (value === null || typeof value !== "object") {
204
- return value;
205
- }
206
- if (Array.isArray(value)) {
207
- return value.map((item) => cloneDeepWith(item, customizer));
208
- }
209
- const cloned = {};
210
- for (const key of Object.keys(value)) {
211
- cloned[key] = cloneDeepWith(
212
- value[key],
213
- customizer
214
- );
215
- }
216
- return cloned;
217
- }
218
-
219
- // src/guards/conformsTo.ts
220
- function conformsTo(object, source) {
221
- for (const key of Object.keys(source)) {
222
- const predicate = source[key];
223
- if (predicate && !predicate(object[key])) {
224
- return false;
225
- }
226
- }
227
- return true;
228
- }
229
-
230
- // src/guards/eq.ts
231
- function eq(value, other) {
232
- return value === other || Number.isNaN(value) && Number.isNaN(other);
233
- }
234
-
235
- // src/guards/gt.ts
236
- function gt(value, other) {
237
- return value > other;
238
- }
239
-
240
- // src/guards/gte.ts
241
- function gte(value, other) {
242
- return value >= other;
243
- }
244
-
245
- // src/guards/lt.ts
246
- function lt(value, other) {
247
- return value < other;
248
- }
249
-
250
- // src/guards/lte.ts
251
- function lte(value, other) {
252
- return value <= other;
253
- }
254
-
255
- // src/guards/isArguments.ts
256
- function isArguments(value) {
257
- return Object.prototype.toString.call(value) === "[object Arguments]";
258
- }
259
-
260
- // src/guards/isArrayBuffer.ts
261
- function isArrayBuffer(value) {
262
- return value instanceof ArrayBuffer;
263
- }
264
-
265
- // src/guards/isArrayLike.ts
266
- function isArrayLike(value) {
267
- if (value === null || value === void 0) return false;
268
- if (typeof value === "function") return false;
269
- const length = value.length;
270
- return typeof length === "number" && length >= 0 && length <= Number.MAX_SAFE_INTEGER && Number.isInteger(length);
271
- }
272
-
273
- // src/guards/isArrayLikeObject.ts
274
- function isArrayLikeObject(value) {
275
- return typeof value === "object" && value !== null && isArrayLike(value);
276
- }
277
-
278
- // src/guards/isBuffer.ts
279
- function isBuffer(value) {
280
- if (typeof Buffer === "undefined") return false;
281
- return Buffer.isBuffer(value);
282
- }
283
-
284
- // src/guards/isElement.ts
285
- function isElement(value) {
286
- if (typeof Element === "undefined") return false;
287
- return value instanceof Element;
288
- }
289
-
290
- // src/guards/isEqualWith.ts
291
- function isEqualWith(value, other, customizer) {
292
- const result = customizer(value, other);
293
- if (result !== void 0) return result;
294
- if (value === other) return true;
295
- if (value === null || other === null) return value === other;
296
- if (typeof value !== typeof other) return false;
297
- if (typeof value === "object" && typeof other === "object") {
298
- const valueKeys = Object.keys(value);
299
- const otherKeys = Object.keys(other);
300
- if (valueKeys.length !== otherKeys.length) return false;
301
- for (const key of valueKeys) {
302
- if (!isEqualWith(
303
- value[key],
304
- other[key],
305
- customizer
306
- )) {
307
- return false;
308
- }
309
- }
310
- return true;
311
- }
312
- return false;
313
- }
314
-
315
- // src/guards/isFinite.ts
316
- function isFinite(value) {
317
- return typeof value === "number" && Number.isFinite(value);
318
- }
319
-
320
- // src/guards/isInteger.ts
321
- function isInteger(value) {
322
- return typeof value === "number" && Number.isInteger(value);
323
- }
324
-
325
- // src/guards/isLength.ts
326
- function isLength(value) {
327
- return typeof value === "number" && value >= 0 && value <= Number.MAX_SAFE_INTEGER && Number.isInteger(value);
328
- }
329
-
330
- // src/guards/isMap.ts
331
- function isMap(value) {
332
- return value instanceof Map;
333
- }
334
-
335
- // src/guards/isMatch.ts
336
- function isMatch(object, source) {
337
- for (const key of Object.keys(source)) {
338
- if (!(key in object)) return false;
339
- const objVal = object[key];
340
- const srcVal = source[key];
341
- if (typeof srcVal === "object" && srcVal !== null && typeof objVal === "object" && objVal !== null) {
342
- if (!isMatch(objVal, srcVal)) {
343
- return false;
344
- }
345
- } else if (objVal !== srcVal) {
346
- return false;
347
- }
348
- }
349
- return true;
350
- }
351
-
352
- // src/guards/isMatchWith.ts
353
- function isMatchWith(object, source, customizer) {
354
- for (const key of Object.keys(source)) {
355
- if (!(key in object)) return false;
356
- const objVal = object[key];
357
- const srcVal = source[key];
358
- const result = customizer(objVal, srcVal, key);
359
- if (result !== void 0) {
360
- if (!result) return false;
361
- } else if (objVal !== srcVal) {
362
- return false;
363
- }
364
- }
365
- return true;
366
- }
367
-
368
- // src/guards/isNaN.ts
369
- function isNaN(value) {
370
- return typeof value === "number" && Number.isNaN(value);
371
- }
372
-
373
- // src/guards/isNative.ts
374
- function isNative(value) {
375
- if (typeof value !== "function") return false;
376
- const fnStr = Function.prototype.toString.call(value);
377
- return fnStr.includes("[native code]");
378
- }
379
-
380
- // src/guards/isNull.ts
381
- function isNull(value) {
382
- return value === null;
383
- }
384
-
385
- // src/guards/isUndefined.ts
386
- function isUndefined(value) {
387
- return value === void 0;
388
- }
389
-
390
- // src/guards/isObjectLike.ts
391
- function isObjectLike(value) {
392
- return typeof value === "object" && value !== null;
393
- }
394
-
395
- // src/guards/isRegExp.ts
396
- function isRegExp(value) {
397
- return value instanceof RegExp;
398
- }
399
-
400
- // src/guards/isSafeInteger.ts
401
- function isSafeInteger(value) {
402
- return typeof value === "number" && Number.isSafeInteger(value);
403
- }
404
-
405
- // src/guards/isSet.ts
406
- function isSet(value) {
407
- return value instanceof Set;
408
- }
409
-
410
- // src/guards/isTypedArray.ts
411
- function isTypedArray(value) {
412
- return ArrayBuffer.isView(value) && !(value instanceof DataView);
413
- }
414
-
415
- // src/guards/isWeakMap.ts
416
- function isWeakMap(value) {
417
- return value instanceof WeakMap;
418
- }
419
-
420
- // src/guards/isWeakSet.ts
421
- function isWeakSet(value) {
422
- return value instanceof WeakSet;
423
- }
424
-
425
- // src/guards/toArray.ts
426
- function toArray(value) {
427
- if (value === null || value === void 0) return [];
428
- if (Array.isArray(value)) return [...value];
429
- if (typeof value === "string") return [...value];
430
- if (typeof value === "object" && value !== null) {
431
- return Object.values(value);
432
- }
433
- return [];
434
- }
435
-
436
- // src/guards/toFinite.ts
437
- function toFinite(value) {
438
- if (value === null || value === void 0) return 0;
439
- if (typeof value === "number") {
440
- if (!Number.isFinite(value)) {
441
- return value > 0 ? Number.MAX_VALUE : -Number.MAX_VALUE;
442
- }
443
- return value;
444
- }
445
- const num = Number(value);
446
- if (Number.isNaN(num)) return 0;
447
- if (!Number.isFinite(num)) {
448
- return num > 0 ? Number.MAX_VALUE : -Number.MAX_VALUE;
449
- }
450
- return num;
451
- }
452
-
453
- // src/guards/toInteger.ts
454
- function toInteger(value) {
455
- const result = toFinite(value);
456
- return result === 0 ? 0 : Math.trunc(result);
457
- }
458
-
459
- // src/guards/toLength.ts
460
- function toLength(value) {
461
- const MAX_ARRAY_LENGTH = 4294967295;
462
- const result = toInteger(value);
463
- if (result < 0) return 0;
464
- if (result > MAX_ARRAY_LENGTH) return MAX_ARRAY_LENGTH;
465
- return result;
466
- }
467
-
468
- // src/guards/toNumber.ts
469
- function toNumber(value) {
470
- if (typeof value === "number") return value;
471
- if (typeof value === "symbol") return NaN;
472
- return Number(value);
473
- }
474
-
475
- // src/guards/toPlainObject.ts
476
- function toPlainObject(value) {
477
- if (value === null || value === void 0) return {};
478
- if (typeof value !== "object") return {};
479
- const result = {};
480
- for (const key in value) {
481
- result[key] = value[key];
482
- }
483
- return result;
484
- }
485
-
486
- // src/guards/toSafeInteger.ts
487
- function toSafeInteger(value) {
488
- const result = toInteger(value);
489
- if (result < Number.MIN_SAFE_INTEGER) return Number.MIN_SAFE_INTEGER;
490
- if (result > Number.MAX_SAFE_INTEGER) return Number.MAX_SAFE_INTEGER;
491
- return result;
492
- }
493
-
494
- // src/guards/toString.ts
495
- function toString(value) {
496
- if (value === null || value === void 0) return "";
497
- if (typeof value === "string") return value;
498
- if (Array.isArray(value)) return value.join(",");
499
- if (Object.is(value, -0)) return "-0";
500
- return String(value);
501
- }
502
-
503
- exports.castArray = castArray;
504
- exports.cloneDeepWith = cloneDeepWith;
505
- exports.cloneWith = cloneWith;
506
- exports.conformsTo = conformsTo;
507
- exports.eq = eq;
508
- exports.gt = gt;
509
- exports.gte = gte;
510
- exports.guards_exports = guards_exports;
511
- exports.hasKey = hasKey;
512
- exports.hasKeys = hasKeys;
513
- exports.isArguments = isArguments;
514
- exports.isArray = isArray;
515
- exports.isArrayBuffer = isArrayBuffer;
516
- exports.isArrayLike = isArrayLike;
517
- exports.isArrayLikeObject = isArrayLikeObject;
518
- exports.isBoolean = isBoolean;
519
- exports.isBuffer = isBuffer;
520
- exports.isDate = isDate;
521
- exports.isElement = isElement;
522
- exports.isEmpty = isEmpty;
523
- exports.isEqualWith = isEqualWith;
524
- exports.isError = isError;
525
- exports.isFinite = isFinite;
526
- exports.isFunction = isFunction;
527
- exports.isInteger = isInteger;
528
- exports.isLength = isLength;
529
- exports.isMap = isMap;
530
- exports.isMatch = isMatch;
531
- exports.isMatchWith = isMatchWith;
532
- exports.isNaN = isNaN;
533
- exports.isNative = isNative;
534
- exports.isNonEmpty = isNonEmpty;
535
- exports.isNull = isNull;
536
- exports.isNumber = isNumber;
537
- exports.isObject = isObject;
538
- exports.isObjectLike = isObjectLike;
539
- exports.isPlainObject = isPlainObject;
540
- exports.isPromise = isPromise;
541
- exports.isRegExp = isRegExp;
542
- exports.isSafeInteger = isSafeInteger;
543
- exports.isSet = isSet;
544
- exports.isString = isString;
545
- exports.isSymbol = isSymbol;
546
- exports.isTypedArray = isTypedArray;
547
- exports.isUndefined = isUndefined;
548
- exports.isWeakMap = isWeakMap;
549
- exports.isWeakSet = isWeakSet;
550
- exports.lt = lt;
551
- exports.lte = lte;
552
- exports.toArray = toArray;
553
- exports.toFinite = toFinite;
554
- exports.toInteger = toInteger;
555
- exports.toLength = toLength;
556
- exports.toNumber = toNumber;
557
- exports.toPlainObject = toPlainObject;
558
- exports.toSafeInteger = toSafeInteger;
559
- exports.toString = toString;
560
- //# sourceMappingURL=chunk-JQAQV75V.js.map
561
- //# sourceMappingURL=chunk-JQAQV75V.js.map