@fluixi/utils 1.0.0-alpha.100

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 (364) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -0
  3. package/dist/index.cjs +2858 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/index.mjs +2838 -0
  8. package/dist/lib/array/advanced.cjs +2227 -0
  9. package/dist/lib/array/advanced.d.ts +1116 -0
  10. package/dist/lib/array/advanced.d.ts.map +1 -0
  11. package/dist/lib/array/advanced.js +2429 -0
  12. package/dist/lib/array/advanced.mjs +2204 -0
  13. package/dist/lib/array/array.cjs +57 -0
  14. package/dist/lib/array/array.d.ts +6 -0
  15. package/dist/lib/array/array.d.ts.map +1 -0
  16. package/dist/lib/array/array.js +31 -0
  17. package/dist/lib/array/array.mjs +36 -0
  18. package/dist/lib/array/index.cjs +2344 -0
  19. package/dist/lib/array/index.d.ts +4 -0
  20. package/dist/lib/array/index.d.ts.map +1 -0
  21. package/dist/lib/array/index.js +3 -0
  22. package/dist/lib/array/index.mjs +2322 -0
  23. package/dist/lib/array/utils.cjs +103 -0
  24. package/dist/lib/array/utils.d.ts +100 -0
  25. package/dist/lib/array/utils.d.ts.map +1 -0
  26. package/dist/lib/array/utils.js +165 -0
  27. package/dist/lib/array/utils.mjs +82 -0
  28. package/dist/lib/color/color.cjs +2190 -0
  29. package/dist/lib/color/color.d.ts +366 -0
  30. package/dist/lib/color/color.d.ts.map +1 -0
  31. package/dist/lib/color/color.js +722 -0
  32. package/dist/lib/color/color.mjs +2167 -0
  33. package/dist/lib/color/constants.cjs +380 -0
  34. package/dist/lib/color/constants.d.ts +361 -0
  35. package/dist/lib/color/constants.d.ts.map +1 -0
  36. package/dist/lib/color/constants.js +358 -0
  37. package/dist/lib/color/constants.mjs +359 -0
  38. package/dist/lib/color/conversions.cjs +629 -0
  39. package/dist/lib/color/conversions.d.ts +166 -0
  40. package/dist/lib/color/conversions.d.ts.map +1 -0
  41. package/dist/lib/color/conversions.js +766 -0
  42. package/dist/lib/color/conversions.mjs +608 -0
  43. package/dist/lib/color/helpers.cjs +2534 -0
  44. package/dist/lib/color/helpers.d.ts +75 -0
  45. package/dist/lib/color/helpers.d.ts.map +1 -0
  46. package/dist/lib/color/helpers.js +419 -0
  47. package/dist/lib/color/helpers.mjs +2511 -0
  48. package/dist/lib/color/index.cjs +2641 -0
  49. package/dist/lib/color/index.d.ts +12 -0
  50. package/dist/lib/color/index.d.ts.map +1 -0
  51. package/dist/lib/color/index.js +15 -0
  52. package/dist/lib/color/index.mjs +2619 -0
  53. package/dist/lib/color/types.cjs +18 -0
  54. package/dist/lib/color/types.d.ts +179 -0
  55. package/dist/lib/color/types.d.ts.map +1 -0
  56. package/dist/lib/color/types.js +1 -0
  57. package/dist/lib/color/types.mjs +0 -0
  58. package/dist/lib/color/utils.cjs +962 -0
  59. package/dist/lib/color/utils.d.ts +199 -0
  60. package/dist/lib/color/utils.d.ts.map +1 -0
  61. package/dist/lib/color/utils.js +858 -0
  62. package/dist/lib/color/utils.mjs +939 -0
  63. package/dist/lib/compare/comparators.cjs +171 -0
  64. package/dist/lib/compare/comparators.d.ts +65 -0
  65. package/dist/lib/compare/comparators.d.ts.map +1 -0
  66. package/dist/lib/compare/comparators.js +210 -0
  67. package/dist/lib/compare/comparators.mjs +150 -0
  68. package/dist/lib/compare/index.cjs +172 -0
  69. package/dist/lib/compare/index.d.ts +2 -0
  70. package/dist/lib/compare/index.d.ts.map +1 -0
  71. package/dist/lib/compare/index.js +1 -0
  72. package/dist/lib/compare/index.mjs +152 -0
  73. package/dist/lib/cookie/codec.cjs +72 -0
  74. package/dist/lib/cookie/codec.d.ts +22 -0
  75. package/dist/lib/cookie/codec.d.ts.map +1 -0
  76. package/dist/lib/cookie/codec.js +67 -0
  77. package/dist/lib/cookie/codec.mjs +51 -0
  78. package/dist/lib/cookie/index.cjs +75 -0
  79. package/dist/lib/cookie/index.d.ts +2 -0
  80. package/dist/lib/cookie/index.d.ts.map +1 -0
  81. package/dist/lib/cookie/index.js +1 -0
  82. package/dist/lib/cookie/index.mjs +53 -0
  83. package/dist/lib/crypto/hash.cjs +83 -0
  84. package/dist/lib/crypto/hash.d.ts +6 -0
  85. package/dist/lib/crypto/hash.d.ts.map +1 -0
  86. package/dist/lib/crypto/hash.js +53 -0
  87. package/dist/lib/crypto/hash.mjs +62 -0
  88. package/dist/lib/crypto/index.cjs +85 -0
  89. package/dist/lib/crypto/index.d.ts +2 -0
  90. package/dist/lib/crypto/index.d.ts.map +1 -0
  91. package/dist/lib/crypto/index.js +1 -0
  92. package/dist/lib/crypto/index.mjs +62 -0
  93. package/dist/lib/dom/events.cjs +40 -0
  94. package/dist/lib/dom/events.d.ts +159 -0
  95. package/dist/lib/dom/events.d.ts.map +1 -0
  96. package/dist/lib/dom/events.js +50 -0
  97. package/dist/lib/dom/events.mjs +19 -0
  98. package/dist/lib/dom/index.cjs +78 -0
  99. package/dist/lib/dom/index.d.ts +3 -0
  100. package/dist/lib/dom/index.d.ts.map +1 -0
  101. package/dist/lib/dom/index.js +2 -0
  102. package/dist/lib/dom/index.mjs +56 -0
  103. package/dist/lib/dom/utils.cjs +57 -0
  104. package/dist/lib/dom/utils.d.ts +6 -0
  105. package/dist/lib/dom/utils.d.ts.map +1 -0
  106. package/dist/lib/dom/utils.js +37 -0
  107. package/dist/lib/dom/utils.mjs +36 -0
  108. package/dist/lib/functions/functions.cjs +366 -0
  109. package/dist/lib/functions/functions.d.ts +329 -0
  110. package/dist/lib/functions/functions.d.ts.map +1 -0
  111. package/dist/lib/functions/functions.js +585 -0
  112. package/dist/lib/functions/functions.mjs +345 -0
  113. package/dist/lib/functions/index.cjs +369 -0
  114. package/dist/lib/functions/index.d.ts +3 -0
  115. package/dist/lib/functions/index.d.ts.map +1 -0
  116. package/dist/lib/functions/index.js +1 -0
  117. package/dist/lib/functions/index.mjs +347 -0
  118. package/dist/lib/functions/types.cjs +18 -0
  119. package/dist/lib/functions/types.d.ts +2 -0
  120. package/dist/lib/functions/types.d.ts.map +1 -0
  121. package/dist/lib/functions/types.js +1 -0
  122. package/dist/lib/functions/types.mjs +0 -0
  123. package/dist/lib/helpers.cjs +78 -0
  124. package/dist/lib/helpers.d.ts +13 -0
  125. package/dist/lib/helpers.d.ts.map +1 -0
  126. package/dist/lib/helpers.js +66 -0
  127. package/dist/lib/helpers.mjs +59 -0
  128. package/dist/lib/index.cjs +2857 -0
  129. package/dist/lib/index.d.ts +6 -0
  130. package/dist/lib/index.d.ts.map +1 -0
  131. package/dist/lib/index.js +8 -0
  132. package/dist/lib/index.mjs +2836 -0
  133. package/dist/lib/maths/constants.cjs +70 -0
  134. package/dist/lib/maths/constants.d.ts +84 -0
  135. package/dist/lib/maths/constants.d.ts.map +1 -0
  136. package/dist/lib/maths/constants.js +79 -0
  137. package/dist/lib/maths/constants.mjs +50 -0
  138. package/dist/lib/maths/fn/advanced.cjs +231 -0
  139. package/dist/lib/maths/fn/advanced.d.ts +149 -0
  140. package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
  141. package/dist/lib/maths/fn/advanced.js +264 -0
  142. package/dist/lib/maths/fn/advanced.mjs +208 -0
  143. package/dist/lib/maths/fn/basic.cjs +212 -0
  144. package/dist/lib/maths/fn/basic.d.ts +182 -0
  145. package/dist/lib/maths/fn/basic.d.ts.map +1 -0
  146. package/dist/lib/maths/fn/basic.js +343 -0
  147. package/dist/lib/maths/fn/basic.mjs +191 -0
  148. package/dist/lib/maths/fn/complex.cjs +268 -0
  149. package/dist/lib/maths/fn/complex.d.ts +153 -0
  150. package/dist/lib/maths/fn/complex.d.ts.map +1 -0
  151. package/dist/lib/maths/fn/complex.js +383 -0
  152. package/dist/lib/maths/fn/complex.mjs +247 -0
  153. package/dist/lib/maths/fn/index.cjs +877 -0
  154. package/dist/lib/maths/fn/index.d.ts +10 -0
  155. package/dist/lib/maths/fn/index.d.ts.map +1 -0
  156. package/dist/lib/maths/fn/index.js +9 -0
  157. package/dist/lib/maths/fn/index.mjs +855 -0
  158. package/dist/lib/maths/fn/trigo.cjs +179 -0
  159. package/dist/lib/maths/fn/trigo.d.ts +147 -0
  160. package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
  161. package/dist/lib/maths/fn/trigo.js +227 -0
  162. package/dist/lib/maths/fn/trigo.mjs +156 -0
  163. package/dist/lib/maths/fn/vector.cjs +728 -0
  164. package/dist/lib/maths/fn/vector.d.ts +512 -0
  165. package/dist/lib/maths/fn/vector.d.ts.map +1 -0
  166. package/dist/lib/maths/fn/vector.js +1136 -0
  167. package/dist/lib/maths/fn/vector.mjs +707 -0
  168. package/dist/lib/maths/formatter.cjs +61 -0
  169. package/dist/lib/maths/formatter.d.ts +35 -0
  170. package/dist/lib/maths/formatter.d.ts.map +1 -0
  171. package/dist/lib/maths/formatter.js +56 -0
  172. package/dist/lib/maths/formatter.mjs +40 -0
  173. package/dist/lib/maths/guards.cjs +164 -0
  174. package/dist/lib/maths/guards.d.ts +166 -0
  175. package/dist/lib/maths/guards.d.ts.map +1 -0
  176. package/dist/lib/maths/guards.js +315 -0
  177. package/dist/lib/maths/guards.mjs +144 -0
  178. package/dist/lib/maths/index.cjs +1152 -0
  179. package/dist/lib/maths/index.d.ts +24 -0
  180. package/dist/lib/maths/index.d.ts.map +1 -0
  181. package/dist/lib/maths/index.js +29 -0
  182. package/dist/lib/maths/index.mjs +1130 -0
  183. package/dist/lib/maths/parser.cjs +75 -0
  184. package/dist/lib/maths/parser.d.ts +20 -0
  185. package/dist/lib/maths/parser.d.ts.map +1 -0
  186. package/dist/lib/maths/parser.js +78 -0
  187. package/dist/lib/maths/parser.mjs +54 -0
  188. package/dist/lib/maths/random.cjs +49 -0
  189. package/dist/lib/maths/random.d.ts +27 -0
  190. package/dist/lib/maths/random.d.ts.map +1 -0
  191. package/dist/lib/maths/random.js +49 -0
  192. package/dist/lib/maths/random.mjs +28 -0
  193. package/dist/lib/maths/types/advanced.cjs +18 -0
  194. package/dist/lib/maths/types/advanced.d.ts +357 -0
  195. package/dist/lib/maths/types/advanced.d.ts.map +1 -0
  196. package/dist/lib/maths/types/advanced.js +5 -0
  197. package/dist/lib/maths/types/advanced.mjs +0 -0
  198. package/dist/lib/maths/types/basic.cjs +18 -0
  199. package/dist/lib/maths/types/basic.d.ts +95 -0
  200. package/dist/lib/maths/types/basic.d.ts.map +1 -0
  201. package/dist/lib/maths/types/basic.js +5 -0
  202. package/dist/lib/maths/types/basic.mjs +0 -0
  203. package/dist/lib/maths/types/index.cjs +19 -0
  204. package/dist/lib/maths/types/index.d.ts +4 -0
  205. package/dist/lib/maths/types/index.d.ts.map +1 -0
  206. package/dist/lib/maths/types/index.js +3 -0
  207. package/dist/lib/maths/types/index.mjs +1 -0
  208. package/dist/lib/maths/types/negative.cjs +18 -0
  209. package/dist/lib/maths/types/negative.d.ts +51 -0
  210. package/dist/lib/maths/types/negative.d.ts.map +1 -0
  211. package/dist/lib/maths/types/negative.js +5 -0
  212. package/dist/lib/maths/types/negative.mjs +0 -0
  213. package/dist/lib/maths/types/operations.cjs +18 -0
  214. package/dist/lib/maths/types/operations.d.ts +188 -0
  215. package/dist/lib/maths/types/operations.d.ts.map +1 -0
  216. package/dist/lib/maths/types/operations.js +6 -0
  217. package/dist/lib/maths/types/operations.mjs +0 -0
  218. package/dist/lib/object/clone.cjs +88 -0
  219. package/dist/lib/object/clone.d.ts +46 -0
  220. package/dist/lib/object/clone.d.ts.map +1 -0
  221. package/dist/lib/object/clone.js +104 -0
  222. package/dist/lib/object/clone.mjs +65 -0
  223. package/dist/lib/object/diff.cjs +573 -0
  224. package/dist/lib/object/diff.d.ts +203 -0
  225. package/dist/lib/object/diff.d.ts.map +1 -0
  226. package/dist/lib/object/diff.js +805 -0
  227. package/dist/lib/object/diff.mjs +550 -0
  228. package/dist/lib/object/getter-setter.cjs +2351 -0
  229. package/dist/lib/object/getter-setter.d.ts +361 -0
  230. package/dist/lib/object/getter-setter.d.ts.map +1 -0
  231. package/dist/lib/object/getter-setter.js +1771 -0
  232. package/dist/lib/object/getter-setter.mjs +2330 -0
  233. package/dist/lib/object/index.cjs +3956 -0
  234. package/dist/lib/object/index.d.ts +13 -0
  235. package/dist/lib/object/index.d.ts.map +1 -0
  236. package/dist/lib/object/index.js +12 -0
  237. package/dist/lib/object/index.mjs +3936 -0
  238. package/dist/lib/object/merge.cjs +1029 -0
  239. package/dist/lib/object/merge.d.ts +93 -0
  240. package/dist/lib/object/merge.d.ts.map +1 -0
  241. package/dist/lib/object/merge.js +474 -0
  242. package/dist/lib/object/merge.mjs +1006 -0
  243. package/dist/lib/object/object.cjs +280 -0
  244. package/dist/lib/object/object.d.ts +128 -0
  245. package/dist/lib/object/object.d.ts.map +1 -0
  246. package/dist/lib/object/object.js +432 -0
  247. package/dist/lib/object/object.mjs +257 -0
  248. package/dist/lib/object/omit.cjs +2022 -0
  249. package/dist/lib/object/omit.d.ts +351 -0
  250. package/dist/lib/object/omit.d.ts.map +1 -0
  251. package/dist/lib/object/omit.js +656 -0
  252. package/dist/lib/object/omit.mjs +1999 -0
  253. package/dist/lib/object/reconcile.cjs +126 -0
  254. package/dist/lib/object/reconcile.d.ts +7 -0
  255. package/dist/lib/object/reconcile.d.ts.map +1 -0
  256. package/dist/lib/object/reconcile.js +122 -0
  257. package/dist/lib/object/reconcile.mjs +105 -0
  258. package/dist/lib/object/selector.cjs +303 -0
  259. package/dist/lib/object/selector.d.ts +50 -0
  260. package/dist/lib/object/selector.d.ts.map +1 -0
  261. package/dist/lib/object/selector.js +371 -0
  262. package/dist/lib/object/selector.mjs +282 -0
  263. package/dist/lib/object/sort.cjs +209 -0
  264. package/dist/lib/object/sort.d.ts +149 -0
  265. package/dist/lib/object/sort.d.ts.map +1 -0
  266. package/dist/lib/object/sort.js +298 -0
  267. package/dist/lib/object/sort.mjs +186 -0
  268. package/dist/lib/object/transform.cjs +2211 -0
  269. package/dist/lib/object/transform.d.ts +620 -0
  270. package/dist/lib/object/transform.d.ts.map +1 -0
  271. package/dist/lib/object/transform.js +1058 -0
  272. package/dist/lib/object/transform.mjs +2190 -0
  273. package/dist/lib/object/types.cjs +18 -0
  274. package/dist/lib/object/types.d.ts +250 -0
  275. package/dist/lib/object/types.d.ts.map +1 -0
  276. package/dist/lib/object/types.js +1 -0
  277. package/dist/lib/object/types.mjs +0 -0
  278. package/dist/lib/object/utils.cjs +326 -0
  279. package/dist/lib/object/utils.d.ts +165 -0
  280. package/dist/lib/object/utils.d.ts.map +1 -0
  281. package/dist/lib/object/utils.js +444 -0
  282. package/dist/lib/object/utils.mjs +305 -0
  283. package/dist/lib/primitive/boolean/boolean.cjs +407 -0
  284. package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
  285. package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
  286. package/dist/lib/primitive/boolean/boolean.js +615 -0
  287. package/dist/lib/primitive/boolean/boolean.mjs +386 -0
  288. package/dist/lib/primitive/boolean/index.cjs +382 -0
  289. package/dist/lib/primitive/boolean/index.d.ts +3 -0
  290. package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
  291. package/dist/lib/primitive/boolean/index.js +2 -0
  292. package/dist/lib/primitive/boolean/index.mjs +359 -0
  293. package/dist/lib/primitive/boolean/types.cjs +18 -0
  294. package/dist/lib/primitive/boolean/types.d.ts +14 -0
  295. package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
  296. package/dist/lib/primitive/boolean/types.js +1 -0
  297. package/dist/lib/primitive/boolean/types.mjs +0 -0
  298. package/dist/lib/primitive/date/date.cjs +1126 -0
  299. package/dist/lib/primitive/date/date.d.ts +641 -0
  300. package/dist/lib/primitive/date/date.d.ts.map +1 -0
  301. package/dist/lib/primitive/date/date.js +1998 -0
  302. package/dist/lib/primitive/date/date.mjs +1105 -0
  303. package/dist/lib/primitive/date/index.cjs +1128 -0
  304. package/dist/lib/primitive/date/index.d.ts +3 -0
  305. package/dist/lib/primitive/date/index.d.ts.map +1 -0
  306. package/dist/lib/primitive/date/index.js +2 -0
  307. package/dist/lib/primitive/date/index.mjs +1105 -0
  308. package/dist/lib/primitive/date/types.cjs +18 -0
  309. package/dist/lib/primitive/date/types.d.ts +205 -0
  310. package/dist/lib/primitive/date/types.d.ts.map +1 -0
  311. package/dist/lib/primitive/date/types.js +7 -0
  312. package/dist/lib/primitive/date/types.mjs +0 -0
  313. package/dist/lib/primitive/index.cjs +2338 -0
  314. package/dist/lib/primitive/index.d.ts +5 -0
  315. package/dist/lib/primitive/index.d.ts.map +1 -0
  316. package/dist/lib/primitive/index.js +4 -0
  317. package/dist/lib/primitive/index.mjs +2316 -0
  318. package/dist/lib/primitive/string/index.cjs +875 -0
  319. package/dist/lib/primitive/string/index.d.ts +3 -0
  320. package/dist/lib/primitive/string/index.d.ts.map +1 -0
  321. package/dist/lib/primitive/string/index.js +2 -0
  322. package/dist/lib/primitive/string/index.mjs +852 -0
  323. package/dist/lib/primitive/string/parser-2.cjs +543 -0
  324. package/dist/lib/primitive/string/parser-2.d.ts +17 -0
  325. package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
  326. package/dist/lib/primitive/string/parser-2.js +656 -0
  327. package/dist/lib/primitive/string/parser-2.mjs +522 -0
  328. package/dist/lib/primitive/string/parser.cjs +236 -0
  329. package/dist/lib/primitive/string/parser.d.ts +9 -0
  330. package/dist/lib/primitive/string/parser.d.ts.map +1 -0
  331. package/dist/lib/primitive/string/parser.js +775 -0
  332. package/dist/lib/primitive/string/parser.mjs +215 -0
  333. package/dist/lib/primitive/string/string.cjs +926 -0
  334. package/dist/lib/primitive/string/string.d.ts +535 -0
  335. package/dist/lib/primitive/string/string.d.ts.map +1 -0
  336. package/dist/lib/primitive/string/string.js +1301 -0
  337. package/dist/lib/primitive/string/string.mjs +903 -0
  338. package/dist/lib/primitive/string/types.cjs +18 -0
  339. package/dist/lib/primitive/string/types.d.ts +318 -0
  340. package/dist/lib/primitive/string/types.d.ts.map +1 -0
  341. package/dist/lib/primitive/string/types.js +5 -0
  342. package/dist/lib/primitive/string/types.mjs +0 -0
  343. package/dist/lib/primitive/types.cjs +18 -0
  344. package/dist/lib/primitive/types.d.ts +27 -0
  345. package/dist/lib/primitive/types.d.ts.map +1 -0
  346. package/dist/lib/primitive/types.js +1 -0
  347. package/dist/lib/primitive/types.mjs +0 -0
  348. package/dist/lib/url/index.cjs +327 -0
  349. package/dist/lib/url/index.d.ts +3 -0
  350. package/dist/lib/url/index.d.ts.map +1 -0
  351. package/dist/lib/url/index.js +2 -0
  352. package/dist/lib/url/index.mjs +304 -0
  353. package/dist/lib/url/parser.cjs +325 -0
  354. package/dist/lib/url/parser.d.ts +216 -0
  355. package/dist/lib/url/parser.d.ts.map +1 -0
  356. package/dist/lib/url/parser.js +488 -0
  357. package/dist/lib/url/parser.mjs +304 -0
  358. package/dist/lib/url/types.cjs +18 -0
  359. package/dist/lib/url/types.d.ts +18 -0
  360. package/dist/lib/url/types.d.ts.map +1 -0
  361. package/dist/lib/url/types.js +1 -0
  362. package/dist/lib/url/types.mjs +0 -0
  363. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  364. package/package.json +127 -0
@@ -0,0 +1,172 @@
1
+ /*! @fluixi/utils v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/lib/compare/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ deepEqual: () => deepEqual,
25
+ hasLength: () => hasLength,
26
+ isDeepEqual: () => isDeepEqual,
27
+ isEqual: () => isEqual
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/lib/helpers.ts
32
+ var import_primitive = require("@fluixi/utils/primitive");
33
+ var import_object = require("@fluixi/utils/object");
34
+ var import_array = require("@fluixi/utils/array");
35
+ var import_functions = require("@fluixi/utils/functions");
36
+ var isUndefinedOrNull = (element) => {
37
+ if (typeof element === "undefined" || element === null) return true;
38
+ return false;
39
+ };
40
+ function isPrimitive(v) {
41
+ const type = typeof v;
42
+ return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || (0, import_primitive.isDate)(v);
43
+ }
44
+
45
+ // src/lib/compare/comparators.ts
46
+ var import_object2 = require("@fluixi/utils/object");
47
+ var hasLength = (data) => {
48
+ const type = typeof data;
49
+ let hasValue = false;
50
+ if (isUndefinedOrNull(data)) {
51
+ return false;
52
+ }
53
+ switch (type) {
54
+ case "string":
55
+ hasValue = data.length > 0;
56
+ break;
57
+ case "number":
58
+ hasValue = true;
59
+ break;
60
+ case "object":
61
+ if (Array.isArray(data)) {
62
+ hasValue = data.length > 0;
63
+ } else {
64
+ hasValue = Object.keys(data).length > 0;
65
+ }
66
+ break;
67
+ case "boolean":
68
+ hasValue = data;
69
+ }
70
+ return hasValue;
71
+ };
72
+ var isDeepEqual = (compare1, compare2, keys) => {
73
+ if (compare1 === void 0 || compare2 === void 0) return false;
74
+ if (compare1 === null || compare2 === null) return compare1 === compare2;
75
+ if (Array.isArray(compare1) && Array.isArray(compare2)) {
76
+ if (compare1.length !== compare2.length) return false;
77
+ return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
78
+ }
79
+ if (keys && keys.length > 0) {
80
+ if (isPrimitive(compare1) && isPrimitive(compare2))
81
+ return compare1 === compare2;
82
+ if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2))
83
+ return keys.every(
84
+ (k) => isDeepEqual(compare1[k], compare2[k])
85
+ );
86
+ return false;
87
+ }
88
+ if ((0, import_object2.isObject)(compare1) && (0, import_object2.isObject)(compare2)) {
89
+ const obj1Keys = Object.keys(compare1).sort();
90
+ const obj2Keys = Object.keys(compare2).sort();
91
+ if (obj1Keys.length !== obj2Keys.length) return false;
92
+ return obj1Keys.every(
93
+ (key) => isDeepEqual(compare1[key], compare2[key])
94
+ );
95
+ }
96
+ return compare1 === compare2;
97
+ };
98
+ function unorderedArrayEqual(a, b, opts) {
99
+ const used = new Uint8Array(b.length);
100
+ outer: for (let i = 0; i < a.length; i++) {
101
+ for (let j = 0; j < b.length; j++) {
102
+ if (!used[j] && deepEqual(a[i], b[j], opts)) {
103
+ used[j] = 1;
104
+ continue outer;
105
+ }
106
+ }
107
+ return false;
108
+ }
109
+ return true;
110
+ }
111
+ var deepEqual = (obj1, obj2, options = {}) => {
112
+ if (obj1 === obj2) return true;
113
+ if (obj1 == null || obj2 == null) return false;
114
+ if (typeof obj1 !== typeof obj2) return false;
115
+ const isArr1 = Array.isArray(obj1);
116
+ const isArr2 = Array.isArray(obj2);
117
+ if (isArr1 !== isArr2) return false;
118
+ if (isArr1 && isArr2) {
119
+ if (obj1.length !== obj2.length) return false;
120
+ return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
121
+ }
122
+ if (typeof obj1 !== "object") return obj1 === obj2;
123
+ const isDate1 = obj1 instanceof Date;
124
+ const isDate2 = obj2 instanceof Date;
125
+ if (isDate1 !== isDate2) return false;
126
+ if (isDate1) return obj1.getTime() === obj2.getTime();
127
+ const isRE1 = obj1 instanceof RegExp;
128
+ const isRE2 = obj2 instanceof RegExp;
129
+ if (isRE1 !== isRE2) return false;
130
+ if (isRE1) return obj1.toString() === obj2.toString();
131
+ const isMap1 = obj1 instanceof Map;
132
+ const isMap2 = obj2 instanceof Map;
133
+ if (isMap1 !== isMap2) return false;
134
+ if (isMap1) {
135
+ if (obj1.size !== obj2.size) return false;
136
+ for (const [k, v] of obj1) {
137
+ if (!obj2.has(k)) return false;
138
+ if (!deepEqual(v, obj2.get(k), options)) return false;
139
+ }
140
+ return true;
141
+ }
142
+ const isSet1 = obj1 instanceof Set;
143
+ const isSet2 = obj2 instanceof Set;
144
+ if (isSet1 !== isSet2) return false;
145
+ if (isSet1) {
146
+ if (obj1.size !== obj2.size) return false;
147
+ const bArr = [...obj2];
148
+ const used = new Uint8Array(bArr.length);
149
+ outer: for (const v of obj1) {
150
+ for (let j = 0; j < bArr.length; j++) {
151
+ if (!used[j] && deepEqual(v, bArr[j], options)) {
152
+ used[j] = 1;
153
+ continue outer;
154
+ }
155
+ }
156
+ return false;
157
+ }
158
+ return true;
159
+ }
160
+ if (!(0, import_object2.isObject)(obj1) || !(0, import_object2.isObject)(obj2)) return false;
161
+ const keys1 = Object.keys(obj1);
162
+ const keys2 = Object.keys(obj2);
163
+ if (keys1.length !== keys2.length) return false;
164
+ for (const key of keys1) {
165
+ if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
166
+ if (!deepEqual(obj1[key], obj2[key], options)) return false;
167
+ }
168
+ return true;
169
+ };
170
+ function isEqual(a, b) {
171
+ return Object.is(a, b);
172
+ }
@@ -0,0 +1,2 @@
1
+ export * from './comparators.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/compare/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1 @@
1
+ export * from './comparators.js';
@@ -0,0 +1,152 @@
1
+ /*! @fluixi/utils v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+
3
+ // src/lib/helpers.ts
4
+ import {
5
+ isDate
6
+ } from "@fluixi/utils/primitive";
7
+ import { isClass, isObject } from "@fluixi/utils/object";
8
+ import { isArray } from "@fluixi/utils/array";
9
+ import { isFunction } from "@fluixi/utils/functions";
10
+ var isUndefinedOrNull = (element) => {
11
+ if (typeof element === "undefined" || element === null) return true;
12
+ return false;
13
+ };
14
+ function isPrimitive(v) {
15
+ const type = typeof v;
16
+ return v === null || type === "string" || type === "number" || type === "boolean" || type === "symbol" || type === "bigint" || type === "undefined" || isDate(v);
17
+ }
18
+
19
+ // src/lib/compare/comparators.ts
20
+ import { isObject as isObject2 } from "@fluixi/utils/object";
21
+ var hasLength = (data) => {
22
+ const type = typeof data;
23
+ let hasValue = false;
24
+ if (isUndefinedOrNull(data)) {
25
+ return false;
26
+ }
27
+ switch (type) {
28
+ case "string":
29
+ hasValue = data.length > 0;
30
+ break;
31
+ case "number":
32
+ hasValue = true;
33
+ break;
34
+ case "object":
35
+ if (Array.isArray(data)) {
36
+ hasValue = data.length > 0;
37
+ } else {
38
+ hasValue = Object.keys(data).length > 0;
39
+ }
40
+ break;
41
+ case "boolean":
42
+ hasValue = data;
43
+ }
44
+ return hasValue;
45
+ };
46
+ var isDeepEqual = (compare1, compare2, keys) => {
47
+ if (compare1 === void 0 || compare2 === void 0) return false;
48
+ if (compare1 === null || compare2 === null) return compare1 === compare2;
49
+ if (Array.isArray(compare1) && Array.isArray(compare2)) {
50
+ if (compare1.length !== compare2.length) return false;
51
+ return compare1.every((v, i) => isDeepEqual(v, compare2[i]));
52
+ }
53
+ if (keys && keys.length > 0) {
54
+ if (isPrimitive(compare1) && isPrimitive(compare2))
55
+ return compare1 === compare2;
56
+ if (isObject2(compare1) && isObject2(compare2))
57
+ return keys.every(
58
+ (k) => isDeepEqual(compare1[k], compare2[k])
59
+ );
60
+ return false;
61
+ }
62
+ if (isObject2(compare1) && isObject2(compare2)) {
63
+ const obj1Keys = Object.keys(compare1).sort();
64
+ const obj2Keys = Object.keys(compare2).sort();
65
+ if (obj1Keys.length !== obj2Keys.length) return false;
66
+ return obj1Keys.every(
67
+ (key) => isDeepEqual(compare1[key], compare2[key])
68
+ );
69
+ }
70
+ return compare1 === compare2;
71
+ };
72
+ function unorderedArrayEqual(a, b, opts) {
73
+ const used = new Uint8Array(b.length);
74
+ outer: for (let i = 0; i < a.length; i++) {
75
+ for (let j = 0; j < b.length; j++) {
76
+ if (!used[j] && deepEqual(a[i], b[j], opts)) {
77
+ used[j] = 1;
78
+ continue outer;
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ var deepEqual = (obj1, obj2, options = {}) => {
86
+ if (obj1 === obj2) return true;
87
+ if (obj1 == null || obj2 == null) return false;
88
+ if (typeof obj1 !== typeof obj2) return false;
89
+ const isArr1 = Array.isArray(obj1);
90
+ const isArr2 = Array.isArray(obj2);
91
+ if (isArr1 !== isArr2) return false;
92
+ if (isArr1 && isArr2) {
93
+ if (obj1.length !== obj2.length) return false;
94
+ return options.unordered ? unorderedArrayEqual(obj1, obj2, options) : obj1.every((item, i) => deepEqual(item, obj2[i], options));
95
+ }
96
+ if (typeof obj1 !== "object") return obj1 === obj2;
97
+ const isDate1 = obj1 instanceof Date;
98
+ const isDate2 = obj2 instanceof Date;
99
+ if (isDate1 !== isDate2) return false;
100
+ if (isDate1) return obj1.getTime() === obj2.getTime();
101
+ const isRE1 = obj1 instanceof RegExp;
102
+ const isRE2 = obj2 instanceof RegExp;
103
+ if (isRE1 !== isRE2) return false;
104
+ if (isRE1) return obj1.toString() === obj2.toString();
105
+ const isMap1 = obj1 instanceof Map;
106
+ const isMap2 = obj2 instanceof Map;
107
+ if (isMap1 !== isMap2) return false;
108
+ if (isMap1) {
109
+ if (obj1.size !== obj2.size) return false;
110
+ for (const [k, v] of obj1) {
111
+ if (!obj2.has(k)) return false;
112
+ if (!deepEqual(v, obj2.get(k), options)) return false;
113
+ }
114
+ return true;
115
+ }
116
+ const isSet1 = obj1 instanceof Set;
117
+ const isSet2 = obj2 instanceof Set;
118
+ if (isSet1 !== isSet2) return false;
119
+ if (isSet1) {
120
+ if (obj1.size !== obj2.size) return false;
121
+ const bArr = [...obj2];
122
+ const used = new Uint8Array(bArr.length);
123
+ outer: for (const v of obj1) {
124
+ for (let j = 0; j < bArr.length; j++) {
125
+ if (!used[j] && deepEqual(v, bArr[j], options)) {
126
+ used[j] = 1;
127
+ continue outer;
128
+ }
129
+ }
130
+ return false;
131
+ }
132
+ return true;
133
+ }
134
+ if (!isObject2(obj1) || !isObject2(obj2)) return false;
135
+ const keys1 = Object.keys(obj1);
136
+ const keys2 = Object.keys(obj2);
137
+ if (keys1.length !== keys2.length) return false;
138
+ for (const key of keys1) {
139
+ if (!Object.prototype.hasOwnProperty.call(obj2, key)) return false;
140
+ if (!deepEqual(obj1[key], obj2[key], options)) return false;
141
+ }
142
+ return true;
143
+ };
144
+ function isEqual(a, b) {
145
+ return Object.is(a, b);
146
+ }
147
+ export {
148
+ deepEqual,
149
+ hasLength,
150
+ isDeepEqual,
151
+ isEqual
152
+ };
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/cookie/codec.ts
21
+ var codec_exports = {};
22
+ __export(codec_exports, {
23
+ deleteCookie: () => deleteCookie,
24
+ isValidCookieName: () => isValidCookieName,
25
+ parseCookies: () => parseCookies,
26
+ serializeCookie: () => serializeCookie
27
+ });
28
+ module.exports = __toCommonJS(codec_exports);
29
+ var NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
30
+ function isValidCookieName(name) {
31
+ return NAME.test(name);
32
+ }
33
+ function decode(value) {
34
+ try {
35
+ return decodeURIComponent(value);
36
+ } catch {
37
+ return value;
38
+ }
39
+ }
40
+ function parseCookies(header) {
41
+ const out = {};
42
+ if (!header) return out;
43
+ for (const part of header.split(";")) {
44
+ const eq = part.indexOf("=");
45
+ if (eq < 0) continue;
46
+ const k = part.slice(0, eq).trim();
47
+ if (!k || k in out) continue;
48
+ let v = part.slice(eq + 1).trim();
49
+ if (v.length > 1 && v[0] === '"' && v[v.length - 1] === '"') v = v.slice(1, -1);
50
+ out[k] = decode(v);
51
+ }
52
+ return out;
53
+ }
54
+ function serializeCookie(name, value, opts = {}) {
55
+ if (!isValidCookieName(name)) throw new TypeError(`Invalid cookie name: ${JSON.stringify(name)}`);
56
+ const o = { path: "/", httpOnly: true, secure: true, sameSite: "lax", ...opts };
57
+ if (o.domain && /[;\s]/.test(o.domain)) throw new TypeError(`Invalid cookie domain: ${o.domain}`);
58
+ if (/[;\s]/.test(o.path)) throw new TypeError(`Invalid cookie path: ${o.path}`);
59
+ const secure = o.secure || o.sameSite === "none";
60
+ let s = `${name}=${encodeURIComponent(value)}`;
61
+ if (o.maxAge != null) s += `; Max-Age=${Math.floor(o.maxAge)}`;
62
+ if (o.expires) s += `; Expires=${o.expires.toUTCString()}`;
63
+ if (o.domain) s += `; Domain=${o.domain}`;
64
+ s += `; Path=${o.path}`;
65
+ if (o.httpOnly) s += "; HttpOnly";
66
+ if (secure) s += "; Secure";
67
+ s += `; SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`;
68
+ return s;
69
+ }
70
+ function deleteCookie(name, opts = {}) {
71
+ return serializeCookie(name, "", { ...opts, maxAge: 0, expires: /* @__PURE__ */ new Date(0) });
72
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Cookie codec shared by auth and storage. Pure string work, no request access.
3
+ * `serializeCookie` is secure by default (HttpOnly, Secure, SameSite=Lax, Path=/).
4
+ */
5
+ export interface CookieOptions {
6
+ /** Seconds. */
7
+ maxAge?: number;
8
+ expires?: Date;
9
+ path?: string;
10
+ domain?: string;
11
+ secure?: boolean;
12
+ httpOnly?: boolean;
13
+ sameSite?: 'strict' | 'lax' | 'none';
14
+ }
15
+ export declare function isValidCookieName(name: string): boolean;
16
+ /** Parse a `Cookie:` header into a record. The first occurrence of a name wins. */
17
+ export declare function parseCookies(header: string | null | undefined): Record<string, string>;
18
+ /** Serialize a cookie into a `Set-Cookie` value. Secure by default. */
19
+ export declare function serializeCookie(name: string, value: string, opts?: CookieOptions): string;
20
+ /** A `Set-Cookie` string that deletes a cookie. Path and domain must match the original. */
21
+ export declare function deleteCookie(name: string, opts?: CookieOptions): string;
22
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/lib/cookie/codec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,aAAa;IAC5B,eAAe;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CACtC;AAKD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAWD,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAatF;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAgB7F;AAED,4FAA4F;AAC5F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,aAAkB,GAAG,MAAM,CAE3E"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Cookie codec shared by auth and storage. Pure string work, no request access.
3
+ * `serializeCookie` is secure by default (HttpOnly, Secure, SameSite=Lax, Path=/).
4
+ */
5
+ // RFC 6265 cookie-name is an RFC 7230 token.
6
+ const NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
7
+ export function isValidCookieName(name) {
8
+ return NAME.test(name);
9
+ }
10
+ function decode(value) {
11
+ try {
12
+ return decodeURIComponent(value);
13
+ }
14
+ catch {
15
+ // A malformed escape from another writer stays readable as raw text.
16
+ return value;
17
+ }
18
+ }
19
+ /** Parse a `Cookie:` header into a record. The first occurrence of a name wins. */
20
+ export function parseCookies(header) {
21
+ const out = {};
22
+ if (!header)
23
+ return out;
24
+ for (const part of header.split(';')) {
25
+ const eq = part.indexOf('=');
26
+ if (eq < 0)
27
+ continue;
28
+ const k = part.slice(0, eq).trim();
29
+ if (!k || k in out)
30
+ continue;
31
+ let v = part.slice(eq + 1).trim();
32
+ if (v.length > 1 && v[0] === '"' && v[v.length - 1] === '"')
33
+ v = v.slice(1, -1);
34
+ out[k] = decode(v);
35
+ }
36
+ return out;
37
+ }
38
+ /** Serialize a cookie into a `Set-Cookie` value. Secure by default. */
39
+ export function serializeCookie(name, value, opts = {}) {
40
+ if (!isValidCookieName(name))
41
+ throw new TypeError(`Invalid cookie name: ${JSON.stringify(name)}`);
42
+ const o = { path: '/', httpOnly: true, secure: true, sameSite: 'lax', ...opts };
43
+ if (o.domain && /[;\s]/.test(o.domain))
44
+ throw new TypeError(`Invalid cookie domain: ${o.domain}`);
45
+ if (/[;\s]/.test(o.path))
46
+ throw new TypeError(`Invalid cookie path: ${o.path}`);
47
+ // Browsers drop SameSite=None without Secure.
48
+ const secure = o.secure || o.sameSite === 'none';
49
+ let s = `${name}=${encodeURIComponent(value)}`;
50
+ if (o.maxAge != null)
51
+ s += `; Max-Age=${Math.floor(o.maxAge)}`;
52
+ if (o.expires)
53
+ s += `; Expires=${o.expires.toUTCString()}`;
54
+ if (o.domain)
55
+ s += `; Domain=${o.domain}`;
56
+ s += `; Path=${o.path}`;
57
+ if (o.httpOnly)
58
+ s += '; HttpOnly';
59
+ if (secure)
60
+ s += '; Secure';
61
+ s += `; SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`;
62
+ return s;
63
+ }
64
+ /** A `Set-Cookie` string that deletes a cookie. Path and domain must match the original. */
65
+ export function deleteCookie(name, opts = {}) {
66
+ return serializeCookie(name, '', { ...opts, maxAge: 0, expires: new Date(0) });
67
+ }
@@ -0,0 +1,51 @@
1
+ // src/lib/cookie/codec.ts
2
+ var NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
3
+ function isValidCookieName(name) {
4
+ return NAME.test(name);
5
+ }
6
+ function decode(value) {
7
+ try {
8
+ return decodeURIComponent(value);
9
+ } catch {
10
+ return value;
11
+ }
12
+ }
13
+ function parseCookies(header) {
14
+ const out = {};
15
+ if (!header) return out;
16
+ for (const part of header.split(";")) {
17
+ const eq = part.indexOf("=");
18
+ if (eq < 0) continue;
19
+ const k = part.slice(0, eq).trim();
20
+ if (!k || k in out) continue;
21
+ let v = part.slice(eq + 1).trim();
22
+ if (v.length > 1 && v[0] === '"' && v[v.length - 1] === '"') v = v.slice(1, -1);
23
+ out[k] = decode(v);
24
+ }
25
+ return out;
26
+ }
27
+ function serializeCookie(name, value, opts = {}) {
28
+ if (!isValidCookieName(name)) throw new TypeError(`Invalid cookie name: ${JSON.stringify(name)}`);
29
+ const o = { path: "/", httpOnly: true, secure: true, sameSite: "lax", ...opts };
30
+ if (o.domain && /[;\s]/.test(o.domain)) throw new TypeError(`Invalid cookie domain: ${o.domain}`);
31
+ if (/[;\s]/.test(o.path)) throw new TypeError(`Invalid cookie path: ${o.path}`);
32
+ const secure = o.secure || o.sameSite === "none";
33
+ let s = `${name}=${encodeURIComponent(value)}`;
34
+ if (o.maxAge != null) s += `; Max-Age=${Math.floor(o.maxAge)}`;
35
+ if (o.expires) s += `; Expires=${o.expires.toUTCString()}`;
36
+ if (o.domain) s += `; Domain=${o.domain}`;
37
+ s += `; Path=${o.path}`;
38
+ if (o.httpOnly) s += "; HttpOnly";
39
+ if (secure) s += "; Secure";
40
+ s += `; SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`;
41
+ return s;
42
+ }
43
+ function deleteCookie(name, opts = {}) {
44
+ return serializeCookie(name, "", { ...opts, maxAge: 0, expires: /* @__PURE__ */ new Date(0) });
45
+ }
46
+ export {
47
+ deleteCookie,
48
+ isValidCookieName,
49
+ parseCookies,
50
+ serializeCookie
51
+ };
@@ -0,0 +1,75 @@
1
+ /*! @fluixi/utils v1.0.0-alpha.100 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/lib/cookie/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ deleteCookie: () => deleteCookie,
25
+ isValidCookieName: () => isValidCookieName,
26
+ parseCookies: () => parseCookies,
27
+ serializeCookie: () => serializeCookie
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+
31
+ // src/lib/cookie/codec.ts
32
+ var NAME = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
33
+ function isValidCookieName(name) {
34
+ return NAME.test(name);
35
+ }
36
+ function decode(value) {
37
+ try {
38
+ return decodeURIComponent(value);
39
+ } catch {
40
+ return value;
41
+ }
42
+ }
43
+ function parseCookies(header) {
44
+ const out = {};
45
+ if (!header) return out;
46
+ for (const part of header.split(";")) {
47
+ const eq = part.indexOf("=");
48
+ if (eq < 0) continue;
49
+ const k = part.slice(0, eq).trim();
50
+ if (!k || k in out) continue;
51
+ let v = part.slice(eq + 1).trim();
52
+ if (v.length > 1 && v[0] === '"' && v[v.length - 1] === '"') v = v.slice(1, -1);
53
+ out[k] = decode(v);
54
+ }
55
+ return out;
56
+ }
57
+ function serializeCookie(name, value, opts = {}) {
58
+ if (!isValidCookieName(name)) throw new TypeError(`Invalid cookie name: ${JSON.stringify(name)}`);
59
+ const o = { path: "/", httpOnly: true, secure: true, sameSite: "lax", ...opts };
60
+ if (o.domain && /[;\s]/.test(o.domain)) throw new TypeError(`Invalid cookie domain: ${o.domain}`);
61
+ if (/[;\s]/.test(o.path)) throw new TypeError(`Invalid cookie path: ${o.path}`);
62
+ const secure = o.secure || o.sameSite === "none";
63
+ let s = `${name}=${encodeURIComponent(value)}`;
64
+ if (o.maxAge != null) s += `; Max-Age=${Math.floor(o.maxAge)}`;
65
+ if (o.expires) s += `; Expires=${o.expires.toUTCString()}`;
66
+ if (o.domain) s += `; Domain=${o.domain}`;
67
+ s += `; Path=${o.path}`;
68
+ if (o.httpOnly) s += "; HttpOnly";
69
+ if (secure) s += "; Secure";
70
+ s += `; SameSite=${o.sameSite[0].toUpperCase()}${o.sameSite.slice(1)}`;
71
+ return s;
72
+ }
73
+ function deleteCookie(name, opts = {}) {
74
+ return serializeCookie(name, "", { ...opts, maxAge: 0, expires: /* @__PURE__ */ new Date(0) });
75
+ }
@@ -0,0 +1,2 @@
1
+ export * from './codec.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/cookie/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './codec.js';