@fluixi/utils 1.0.0-alpha.53

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 (354) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/index.cjs +1 -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 +1 -0
  8. package/dist/lib/array/advanced.cjs +1 -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 +1 -0
  13. package/dist/lib/array/array.cjs +1 -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 +1 -0
  18. package/dist/lib/array/index.cjs +1 -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 +1 -0
  23. package/dist/lib/array/utils.cjs +1 -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 +1 -0
  28. package/dist/lib/color/color.cjs +1 -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 +1 -0
  33. package/dist/lib/color/constants.cjs +1 -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 +1 -0
  38. package/dist/lib/color/conversions.cjs +1 -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 +1 -0
  43. package/dist/lib/color/helpers.cjs +1 -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 +1 -0
  48. package/dist/lib/color/index.cjs +1 -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 +1 -0
  53. package/dist/lib/color/types.cjs +1 -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 +1 -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 +1 -0
  63. package/dist/lib/compare/comparators.cjs +1 -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 +1 -0
  68. package/dist/lib/compare/index.cjs +1 -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 +1 -0
  73. package/dist/lib/crypto/hash.cjs +1 -0
  74. package/dist/lib/crypto/hash.d.ts +6 -0
  75. package/dist/lib/crypto/hash.d.ts.map +1 -0
  76. package/dist/lib/crypto/hash.js +53 -0
  77. package/dist/lib/crypto/hash.mjs +1 -0
  78. package/dist/lib/crypto/index.cjs +1 -0
  79. package/dist/lib/crypto/index.d.ts +2 -0
  80. package/dist/lib/crypto/index.d.ts.map +1 -0
  81. package/dist/lib/crypto/index.js +1 -0
  82. package/dist/lib/crypto/index.mjs +1 -0
  83. package/dist/lib/dom/events.cjs +1 -0
  84. package/dist/lib/dom/events.d.ts +159 -0
  85. package/dist/lib/dom/events.d.ts.map +1 -0
  86. package/dist/lib/dom/events.js +50 -0
  87. package/dist/lib/dom/events.mjs +1 -0
  88. package/dist/lib/dom/index.cjs +1 -0
  89. package/dist/lib/dom/index.d.ts +3 -0
  90. package/dist/lib/dom/index.d.ts.map +1 -0
  91. package/dist/lib/dom/index.js +2 -0
  92. package/dist/lib/dom/index.mjs +1 -0
  93. package/dist/lib/dom/utils.cjs +1 -0
  94. package/dist/lib/dom/utils.d.ts +6 -0
  95. package/dist/lib/dom/utils.d.ts.map +1 -0
  96. package/dist/lib/dom/utils.js +37 -0
  97. package/dist/lib/dom/utils.mjs +1 -0
  98. package/dist/lib/functions/functions.cjs +1 -0
  99. package/dist/lib/functions/functions.d.ts +329 -0
  100. package/dist/lib/functions/functions.d.ts.map +1 -0
  101. package/dist/lib/functions/functions.js +585 -0
  102. package/dist/lib/functions/functions.mjs +1 -0
  103. package/dist/lib/functions/index.cjs +1 -0
  104. package/dist/lib/functions/index.d.ts +3 -0
  105. package/dist/lib/functions/index.d.ts.map +1 -0
  106. package/dist/lib/functions/index.js +1 -0
  107. package/dist/lib/functions/index.mjs +1 -0
  108. package/dist/lib/functions/types.cjs +1 -0
  109. package/dist/lib/functions/types.d.ts +2 -0
  110. package/dist/lib/functions/types.d.ts.map +1 -0
  111. package/dist/lib/functions/types.js +1 -0
  112. package/dist/lib/functions/types.mjs +0 -0
  113. package/dist/lib/helpers.cjs +1 -0
  114. package/dist/lib/helpers.d.ts +13 -0
  115. package/dist/lib/helpers.d.ts.map +1 -0
  116. package/dist/lib/helpers.js +66 -0
  117. package/dist/lib/helpers.mjs +1 -0
  118. package/dist/lib/index.cjs +1 -0
  119. package/dist/lib/index.d.ts +6 -0
  120. package/dist/lib/index.d.ts.map +1 -0
  121. package/dist/lib/index.js +8 -0
  122. package/dist/lib/index.mjs +1 -0
  123. package/dist/lib/maths/constants.cjs +1 -0
  124. package/dist/lib/maths/constants.d.ts +84 -0
  125. package/dist/lib/maths/constants.d.ts.map +1 -0
  126. package/dist/lib/maths/constants.js +79 -0
  127. package/dist/lib/maths/constants.mjs +1 -0
  128. package/dist/lib/maths/fn/advanced.cjs +1 -0
  129. package/dist/lib/maths/fn/advanced.d.ts +149 -0
  130. package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
  131. package/dist/lib/maths/fn/advanced.js +264 -0
  132. package/dist/lib/maths/fn/advanced.mjs +1 -0
  133. package/dist/lib/maths/fn/basic.cjs +1 -0
  134. package/dist/lib/maths/fn/basic.d.ts +182 -0
  135. package/dist/lib/maths/fn/basic.d.ts.map +1 -0
  136. package/dist/lib/maths/fn/basic.js +343 -0
  137. package/dist/lib/maths/fn/basic.mjs +1 -0
  138. package/dist/lib/maths/fn/complex.cjs +1 -0
  139. package/dist/lib/maths/fn/complex.d.ts +153 -0
  140. package/dist/lib/maths/fn/complex.d.ts.map +1 -0
  141. package/dist/lib/maths/fn/complex.js +383 -0
  142. package/dist/lib/maths/fn/complex.mjs +1 -0
  143. package/dist/lib/maths/fn/index.cjs +1 -0
  144. package/dist/lib/maths/fn/index.d.ts +10 -0
  145. package/dist/lib/maths/fn/index.d.ts.map +1 -0
  146. package/dist/lib/maths/fn/index.js +9 -0
  147. package/dist/lib/maths/fn/index.mjs +1 -0
  148. package/dist/lib/maths/fn/trigo.cjs +1 -0
  149. package/dist/lib/maths/fn/trigo.d.ts +147 -0
  150. package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
  151. package/dist/lib/maths/fn/trigo.js +227 -0
  152. package/dist/lib/maths/fn/trigo.mjs +1 -0
  153. package/dist/lib/maths/fn/vector.cjs +1 -0
  154. package/dist/lib/maths/fn/vector.d.ts +512 -0
  155. package/dist/lib/maths/fn/vector.d.ts.map +1 -0
  156. package/dist/lib/maths/fn/vector.js +1136 -0
  157. package/dist/lib/maths/fn/vector.mjs +1 -0
  158. package/dist/lib/maths/formatter.cjs +1 -0
  159. package/dist/lib/maths/formatter.d.ts +35 -0
  160. package/dist/lib/maths/formatter.d.ts.map +1 -0
  161. package/dist/lib/maths/formatter.js +56 -0
  162. package/dist/lib/maths/formatter.mjs +1 -0
  163. package/dist/lib/maths/guards.cjs +1 -0
  164. package/dist/lib/maths/guards.d.ts +166 -0
  165. package/dist/lib/maths/guards.d.ts.map +1 -0
  166. package/dist/lib/maths/guards.js +315 -0
  167. package/dist/lib/maths/guards.mjs +1 -0
  168. package/dist/lib/maths/index.cjs +1 -0
  169. package/dist/lib/maths/index.d.ts +24 -0
  170. package/dist/lib/maths/index.d.ts.map +1 -0
  171. package/dist/lib/maths/index.js +29 -0
  172. package/dist/lib/maths/index.mjs +1 -0
  173. package/dist/lib/maths/parser.cjs +1 -0
  174. package/dist/lib/maths/parser.d.ts +20 -0
  175. package/dist/lib/maths/parser.d.ts.map +1 -0
  176. package/dist/lib/maths/parser.js +78 -0
  177. package/dist/lib/maths/parser.mjs +1 -0
  178. package/dist/lib/maths/random.cjs +1 -0
  179. package/dist/lib/maths/random.d.ts +27 -0
  180. package/dist/lib/maths/random.d.ts.map +1 -0
  181. package/dist/lib/maths/random.js +49 -0
  182. package/dist/lib/maths/random.mjs +1 -0
  183. package/dist/lib/maths/types/advanced.cjs +1 -0
  184. package/dist/lib/maths/types/advanced.d.ts +357 -0
  185. package/dist/lib/maths/types/advanced.d.ts.map +1 -0
  186. package/dist/lib/maths/types/advanced.js +5 -0
  187. package/dist/lib/maths/types/advanced.mjs +0 -0
  188. package/dist/lib/maths/types/basic.cjs +1 -0
  189. package/dist/lib/maths/types/basic.d.ts +95 -0
  190. package/dist/lib/maths/types/basic.d.ts.map +1 -0
  191. package/dist/lib/maths/types/basic.js +5 -0
  192. package/dist/lib/maths/types/basic.mjs +0 -0
  193. package/dist/lib/maths/types/index.cjs +1 -0
  194. package/dist/lib/maths/types/index.d.ts +4 -0
  195. package/dist/lib/maths/types/index.d.ts.map +1 -0
  196. package/dist/lib/maths/types/index.js +3 -0
  197. package/dist/lib/maths/types/index.mjs +0 -0
  198. package/dist/lib/maths/types/negative.cjs +1 -0
  199. package/dist/lib/maths/types/negative.d.ts +51 -0
  200. package/dist/lib/maths/types/negative.d.ts.map +1 -0
  201. package/dist/lib/maths/types/negative.js +5 -0
  202. package/dist/lib/maths/types/negative.mjs +0 -0
  203. package/dist/lib/maths/types/operations.cjs +1 -0
  204. package/dist/lib/maths/types/operations.d.ts +188 -0
  205. package/dist/lib/maths/types/operations.d.ts.map +1 -0
  206. package/dist/lib/maths/types/operations.js +6 -0
  207. package/dist/lib/maths/types/operations.mjs +0 -0
  208. package/dist/lib/object/clone.cjs +1 -0
  209. package/dist/lib/object/clone.d.ts +46 -0
  210. package/dist/lib/object/clone.d.ts.map +1 -0
  211. package/dist/lib/object/clone.js +104 -0
  212. package/dist/lib/object/clone.mjs +1 -0
  213. package/dist/lib/object/diff.cjs +1 -0
  214. package/dist/lib/object/diff.d.ts +203 -0
  215. package/dist/lib/object/diff.d.ts.map +1 -0
  216. package/dist/lib/object/diff.js +805 -0
  217. package/dist/lib/object/diff.mjs +1 -0
  218. package/dist/lib/object/getter-setter.cjs +1 -0
  219. package/dist/lib/object/getter-setter.d.ts +361 -0
  220. package/dist/lib/object/getter-setter.d.ts.map +1 -0
  221. package/dist/lib/object/getter-setter.js +1771 -0
  222. package/dist/lib/object/getter-setter.mjs +1 -0
  223. package/dist/lib/object/index.cjs +6 -0
  224. package/dist/lib/object/index.d.ts +13 -0
  225. package/dist/lib/object/index.d.ts.map +1 -0
  226. package/dist/lib/object/index.js +12 -0
  227. package/dist/lib/object/index.mjs +6 -0
  228. package/dist/lib/object/merge.cjs +1 -0
  229. package/dist/lib/object/merge.d.ts +93 -0
  230. package/dist/lib/object/merge.d.ts.map +1 -0
  231. package/dist/lib/object/merge.js +474 -0
  232. package/dist/lib/object/merge.mjs +1 -0
  233. package/dist/lib/object/object.cjs +1 -0
  234. package/dist/lib/object/object.d.ts +128 -0
  235. package/dist/lib/object/object.d.ts.map +1 -0
  236. package/dist/lib/object/object.js +432 -0
  237. package/dist/lib/object/object.mjs +1 -0
  238. package/dist/lib/object/omit.cjs +1 -0
  239. package/dist/lib/object/omit.d.ts +351 -0
  240. package/dist/lib/object/omit.d.ts.map +1 -0
  241. package/dist/lib/object/omit.js +656 -0
  242. package/dist/lib/object/omit.mjs +1 -0
  243. package/dist/lib/object/reconcile.cjs +1 -0
  244. package/dist/lib/object/reconcile.d.ts +7 -0
  245. package/dist/lib/object/reconcile.d.ts.map +1 -0
  246. package/dist/lib/object/reconcile.js +122 -0
  247. package/dist/lib/object/reconcile.mjs +1 -0
  248. package/dist/lib/object/selector.cjs +1 -0
  249. package/dist/lib/object/selector.d.ts +50 -0
  250. package/dist/lib/object/selector.d.ts.map +1 -0
  251. package/dist/lib/object/selector.js +371 -0
  252. package/dist/lib/object/selector.mjs +1 -0
  253. package/dist/lib/object/sort.cjs +1 -0
  254. package/dist/lib/object/sort.d.ts +149 -0
  255. package/dist/lib/object/sort.d.ts.map +1 -0
  256. package/dist/lib/object/sort.js +298 -0
  257. package/dist/lib/object/sort.mjs +1 -0
  258. package/dist/lib/object/transform.cjs +1 -0
  259. package/dist/lib/object/transform.d.ts +620 -0
  260. package/dist/lib/object/transform.d.ts.map +1 -0
  261. package/dist/lib/object/transform.js +1058 -0
  262. package/dist/lib/object/transform.mjs +1 -0
  263. package/dist/lib/object/types.cjs +1 -0
  264. package/dist/lib/object/types.d.ts +250 -0
  265. package/dist/lib/object/types.d.ts.map +1 -0
  266. package/dist/lib/object/types.js +1 -0
  267. package/dist/lib/object/types.mjs +0 -0
  268. package/dist/lib/object/utils.cjs +6 -0
  269. package/dist/lib/object/utils.d.ts +165 -0
  270. package/dist/lib/object/utils.d.ts.map +1 -0
  271. package/dist/lib/object/utils.js +444 -0
  272. package/dist/lib/object/utils.mjs +6 -0
  273. package/dist/lib/primitive/boolean/boolean.cjs +1 -0
  274. package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
  275. package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
  276. package/dist/lib/primitive/boolean/boolean.js +615 -0
  277. package/dist/lib/primitive/boolean/boolean.mjs +1 -0
  278. package/dist/lib/primitive/boolean/index.cjs +1 -0
  279. package/dist/lib/primitive/boolean/index.d.ts +3 -0
  280. package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
  281. package/dist/lib/primitive/boolean/index.js +2 -0
  282. package/dist/lib/primitive/boolean/index.mjs +1 -0
  283. package/dist/lib/primitive/boolean/types.cjs +1 -0
  284. package/dist/lib/primitive/boolean/types.d.ts +14 -0
  285. package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
  286. package/dist/lib/primitive/boolean/types.js +1 -0
  287. package/dist/lib/primitive/boolean/types.mjs +0 -0
  288. package/dist/lib/primitive/date/date.cjs +1 -0
  289. package/dist/lib/primitive/date/date.d.ts +641 -0
  290. package/dist/lib/primitive/date/date.d.ts.map +1 -0
  291. package/dist/lib/primitive/date/date.js +1998 -0
  292. package/dist/lib/primitive/date/date.mjs +1 -0
  293. package/dist/lib/primitive/date/index.cjs +1 -0
  294. package/dist/lib/primitive/date/index.d.ts +3 -0
  295. package/dist/lib/primitive/date/index.d.ts.map +1 -0
  296. package/dist/lib/primitive/date/index.js +2 -0
  297. package/dist/lib/primitive/date/index.mjs +1 -0
  298. package/dist/lib/primitive/date/types.cjs +1 -0
  299. package/dist/lib/primitive/date/types.d.ts +205 -0
  300. package/dist/lib/primitive/date/types.d.ts.map +1 -0
  301. package/dist/lib/primitive/date/types.js +7 -0
  302. package/dist/lib/primitive/date/types.mjs +0 -0
  303. package/dist/lib/primitive/index.cjs +5 -0
  304. package/dist/lib/primitive/index.d.ts +5 -0
  305. package/dist/lib/primitive/index.d.ts.map +1 -0
  306. package/dist/lib/primitive/index.js +4 -0
  307. package/dist/lib/primitive/index.mjs +5 -0
  308. package/dist/lib/primitive/string/index.cjs +5 -0
  309. package/dist/lib/primitive/string/index.d.ts +3 -0
  310. package/dist/lib/primitive/string/index.d.ts.map +1 -0
  311. package/dist/lib/primitive/string/index.js +2 -0
  312. package/dist/lib/primitive/string/index.mjs +5 -0
  313. package/dist/lib/primitive/string/parser-2.cjs +8 -0
  314. package/dist/lib/primitive/string/parser-2.d.ts +17 -0
  315. package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
  316. package/dist/lib/primitive/string/parser-2.js +656 -0
  317. package/dist/lib/primitive/string/parser-2.mjs +8 -0
  318. package/dist/lib/primitive/string/parser.cjs +3 -0
  319. package/dist/lib/primitive/string/parser.d.ts +9 -0
  320. package/dist/lib/primitive/string/parser.d.ts.map +1 -0
  321. package/dist/lib/primitive/string/parser.js +775 -0
  322. package/dist/lib/primitive/string/parser.mjs +3 -0
  323. package/dist/lib/primitive/string/string.cjs +5 -0
  324. package/dist/lib/primitive/string/string.d.ts +535 -0
  325. package/dist/lib/primitive/string/string.d.ts.map +1 -0
  326. package/dist/lib/primitive/string/string.js +1301 -0
  327. package/dist/lib/primitive/string/string.mjs +5 -0
  328. package/dist/lib/primitive/string/types.cjs +1 -0
  329. package/dist/lib/primitive/string/types.d.ts +318 -0
  330. package/dist/lib/primitive/string/types.d.ts.map +1 -0
  331. package/dist/lib/primitive/string/types.js +5 -0
  332. package/dist/lib/primitive/string/types.mjs +0 -0
  333. package/dist/lib/primitive/types.cjs +1 -0
  334. package/dist/lib/primitive/types.d.ts +27 -0
  335. package/dist/lib/primitive/types.d.ts.map +1 -0
  336. package/dist/lib/primitive/types.js +1 -0
  337. package/dist/lib/primitive/types.mjs +0 -0
  338. package/dist/lib/url/index.cjs +1 -0
  339. package/dist/lib/url/index.d.ts +3 -0
  340. package/dist/lib/url/index.d.ts.map +1 -0
  341. package/dist/lib/url/index.js +2 -0
  342. package/dist/lib/url/index.mjs +1 -0
  343. package/dist/lib/url/parser.cjs +1 -0
  344. package/dist/lib/url/parser.d.ts +216 -0
  345. package/dist/lib/url/parser.d.ts.map +1 -0
  346. package/dist/lib/url/parser.js +488 -0
  347. package/dist/lib/url/parser.mjs +1 -0
  348. package/dist/lib/url/types.cjs +1 -0
  349. package/dist/lib/url/types.d.ts +18 -0
  350. package/dist/lib/url/types.d.ts.map +1 -0
  351. package/dist/lib/url/types.js +1 -0
  352. package/dist/lib/url/types.mjs +0 -0
  353. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  354. package/package.json +150 -0
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Type guard to check if an object is a DOM EventTarget.
3
+ *
4
+ * @param {any} target - The object to check
5
+ * @returns {target is EventTarget} True if the object is a DOM EventTarget
6
+ *
7
+ * @private
8
+ */
9
+ export function isDOMEventTarget(target) {
10
+ return target && typeof target.addEventListener === 'function';
11
+ }
12
+ /**
13
+ * Type guard to check if an object is a Node.js EventEmitter.
14
+ *
15
+ * @param {any} target - The object to check
16
+ * @returns {target is NodeEventEmitter} True if the object is a NodeEventEmitter
17
+ *
18
+ * @private
19
+ */
20
+ export function isNodeEventEmitter(target) {
21
+ return (target &&
22
+ typeof target.addEventListener === 'function' &&
23
+ typeof target.removeEventListener === 'function');
24
+ }
25
+ /**
26
+ * Type guard to check if an object has on/off methods (jQuery-style).
27
+ *
28
+ * @param {any} target - The object to check
29
+ * @returns {target is {on: Function, off: Function}} True if the object has on/off methods
30
+ *
31
+ * @private
32
+ */
33
+ export function isOnOffTarget(target) {
34
+ return (target &&
35
+ typeof target.on === 'function' &&
36
+ typeof target.off === 'function');
37
+ }
38
+ /**
39
+ * Type guard to check if an object has addListener/removeListener methods.
40
+ *
41
+ * @param {any} target - The object to check
42
+ * @returns {target is {addListener: Function, removeListener: Function}} True if the object has addListener/removeListener methods
43
+ *
44
+ * @private
45
+ */
46
+ export function isAddRemoveListenerTarget(target) {
47
+ return (target &&
48
+ typeof target.addListener === 'function' &&
49
+ typeof target.removeListener === 'function');
50
+ }
@@ -0,0 +1 @@
1
+ function n(e){return e&&typeof e.addEventListener=="function"}function t(e){return e&&typeof e.addEventListener=="function"&&typeof e.removeEventListener=="function"}function o(e){return e&&typeof e.on=="function"&&typeof e.off=="function"}function r(e){return e&&typeof e.addListener=="function"&&typeof e.removeListener=="function"}export{r as isAddRemoveListenerTarget,n as isDOMEventTarget,t as isNodeEventEmitter,o as isOnOffTarget};
@@ -0,0 +1 @@
1
+ "use strict";var i=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var E=(e,n)=>{for(var r in n)i(e,r,{get:n[r],enumerable:!0})},f=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of d(n))!u.call(e,o)&&o!==r&&i(e,o,{get:()=>n[o],enumerable:!(t=v(n,o))||t.enumerable});return e};var p=e=>f(i({},"__esModule",{value:!0}),e);var M={};E(M,{aenu:()=>L,btoa:()=>x,isAddRemoveListenerTarget:()=>y,isDOMEventTarget:()=>g,isNodeEventEmitter:()=>c,isOnOffTarget:()=>l,uena:()=>b,updateQueryStringParameter:()=>h,windowObject:()=>m});module.exports=p(M);function g(e){return e&&typeof e.addEventListener=="function"}function c(e){return e&&typeof e.addEventListener=="function"&&typeof e.removeEventListener=="function"}function l(e){return e&&typeof e.on=="function"&&typeof e.off=="function"}function y(e){return e&&typeof e.addListener=="function"&&typeof e.removeListener=="function"}function m(){return typeof globalThis=="object"?globalThis:typeof window=="object"?window:typeof self=="object"?self:typeof global=="object"?global:null}function x(e){return Buffer.from(e).toString("base64")}function b(e){return Buffer.from(e).toString("base64")}function L(e){return decodeURIComponent(Buffer.from(e,"base64").toString("utf-8"))}var h=(e,n,r)=>{let t=r,o=new RegExp("([?&])"+n+"=.*?(&|$)","i"),s=e.includes("?")?"&":"?";n==="country"&&(t=JSON.parse(t).alpha_2),n==="phone"&&(t=t.trim().replace(/\s/g,""));let a=e.match(o);return typeof a<"u"&&a!==null?e.replace(o,"$1"+n+"="+t+"$2"):e+s+n+"="+t};
@@ -0,0 +1,3 @@
1
+ export * from './events.js';
2
+ export * from './utils.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/dom/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './events.js';
2
+ export * from './utils.js';
@@ -0,0 +1 @@
1
+ function s(e){return e&&typeof e.addEventListener=="function"}function v(e){return e&&typeof e.addEventListener=="function"&&typeof e.removeEventListener=="function"}function d(e){return e&&typeof e.on=="function"&&typeof e.off=="function"}function u(e){return e&&typeof e.addListener=="function"&&typeof e.removeListener=="function"}function f(){return typeof globalThis=="object"?globalThis:typeof window=="object"?window:typeof self=="object"?self:typeof global=="object"?global:null}function p(e){return Buffer.from(e).toString("base64")}function g(e){return Buffer.from(e).toString("base64")}function c(e){return decodeURIComponent(Buffer.from(e,"base64").toString("utf-8"))}var l=(e,t,i)=>{let n=i,o=new RegExp("([?&])"+t+"=.*?(&|$)","i"),a=e.includes("?")?"&":"?";t==="country"&&(n=JSON.parse(n).alpha_2),t==="phone"&&(n=n.trim().replace(/\s/g,""));let r=e.match(o);return typeof r<"u"&&r!==null?e.replace(o,"$1"+t+"="+n+"$2"):e+a+t+"="+n};export{c as aenu,p as btoa,u as isAddRemoveListenerTarget,s as isDOMEventTarget,v as isNodeEventEmitter,d as isOnOffTarget,g as uena,l as updateQueryStringParameter,f as windowObject};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},p=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of u(e))!c.call(t,r)&&r!==o&&a(t,r,{get:()=>e[r],enumerable:!(n=i(e,r))||n.enumerable});return t};var g=t=>p(a({},"__esModule",{value:!0}),t);var x={};s(x,{aenu:()=>h,btoa:()=>d,uena:()=>m,updateQueryStringParameter:()=>w,windowObject:()=>b});module.exports=g(x);function b(){return typeof globalThis=="object"?globalThis:typeof window=="object"?window:typeof self=="object"?self:typeof global=="object"?global:null}function d(t){return Buffer.from(t).toString("base64")}function m(t){return Buffer.from(t).toString("base64")}function h(t){return decodeURIComponent(Buffer.from(t,"base64").toString("utf-8"))}var w=(t,e,o)=>{let n=o,r=new RegExp("([?&])"+e+"=.*?(&|$)","i"),l=t.includes("?")?"&":"?";e==="country"&&(n=JSON.parse(n).alpha_2),e==="phone"&&(n=n.trim().replace(/\s/g,""));let f=t.match(r);return typeof f<"u"&&f!==null?t.replace(r,"$1"+e+"="+n+"$2"):t+l+e+"="+n};
@@ -0,0 +1,6 @@
1
+ export declare function windowObject(): typeof globalThis | null;
2
+ export declare function btoa(chn: any): string;
3
+ export declare function uena(chn: any): string | null;
4
+ export declare function aenu(chn: any): string;
5
+ export declare const updateQueryStringParameter: (uri: string, key: string, val: string) => string;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/dom/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,6BAU3B;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,UAE5B;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAErC;AAED,eAAO,MAAM,0BAA0B,GACrC,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAeF,CAAC"}
@@ -0,0 +1,37 @@
1
+ export function windowObject() {
2
+ return typeof globalThis === 'object'
3
+ ? globalThis
4
+ : typeof window === 'object'
5
+ ? window
6
+ : typeof self === 'object'
7
+ ? self
8
+ : typeof global === 'object'
9
+ ? global
10
+ : null;
11
+ }
12
+ export function btoa(chn) {
13
+ return Buffer.from(chn).toString('base64');
14
+ }
15
+ export function uena(chn) {
16
+ return Buffer.from(chn).toString('base64');
17
+ }
18
+ // Ascii encodé en base64 en chaîne ucs-2
19
+ export function aenu(chn) {
20
+ return decodeURIComponent(Buffer.from(chn, 'base64').toString('utf-8'));
21
+ }
22
+ export const updateQueryStringParameter = (uri, key, val) => {
23
+ let value = val;
24
+ const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
25
+ const separator = uri.includes('?') ? '&' : '?';
26
+ if (key === 'country') {
27
+ value = JSON.parse(value).alpha_2;
28
+ }
29
+ if (key === 'phone') {
30
+ value = value.trim().replace(/\s/g, '');
31
+ }
32
+ const match = uri.match(re);
33
+ if (typeof match !== 'undefined' && match !== null) {
34
+ return uri.replace(re, '$1' + key + '=' + value + '$2');
35
+ }
36
+ return uri + separator + key + '=' + value;
37
+ };
@@ -0,0 +1 @@
1
+ function l(){return typeof globalThis=="object"?globalThis:typeof window=="object"?window:typeof self=="object"?self:typeof global=="object"?global:null}function i(t){return Buffer.from(t).toString("base64")}function u(t){return Buffer.from(t).toString("base64")}function c(t){return decodeURIComponent(Buffer.from(t,"base64").toString("utf-8"))}var s=(t,n,a)=>{let e=a,r=new RegExp("([?&])"+n+"=.*?(&|$)","i"),f=t.includes("?")?"&":"?";n==="country"&&(e=JSON.parse(e).alpha_2),n==="phone"&&(e=e.trim().replace(/\s/g,""));let o=t.match(r);return typeof o<"u"&&o!==null?t.replace(r,"$1"+n+"="+e+"$2"):t+f+n+"="+e};export{c as aenu,i as btoa,u as uena,s as updateQueryStringParameter,l as windowObject};
@@ -0,0 +1 @@
1
+ "use strict";var R=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var j=(e,n)=>{for(var t in n)R(e,t,{get:n[t],enumerable:!0})},J=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of z(n))!O.call(e,a)&&a!==t&&R(e,a,{get:()=>n[a],enumerable:!(r=L(n,a))||r.enumerable});return e};var N=e=>J(R({},"__esModule",{value:!0}),e);var pe={};j(pe,{after:()=>ie,ary:()=>ee,before:()=>ue,bind:()=>Y,compose:()=>C,curry:()=>K,debounce:()=>E,defer:()=>te,delay:()=>re,flip:()=>Z,flow:()=>se,flowRight:()=>ye,isAsyncFunction:()=>$,isFunction:()=>A,isPromise:()=>_,memoize:()=>q,memoizeWithTTL:()=>ae,negate:()=>Q,once:()=>G,overArgs:()=>U,partial:()=>V,partialRight:()=>X,pipe:()=>F,rearg:()=>H,retry:()=>Te,throttle:()=>B,tryCatch:()=>oe,unary:()=>ne,withTimeout:()=>ce});module.exports=N(pe);var k=require("@fluixi/utils/object");function A(e){return typeof e=="function"&&!(0,k.isClass)(e)}function _(e){return e instanceof Promise||!!e&&(typeof e=="object"||typeof e=="function")&&"then"in e}function $(e){return A(e)&&e.constructor.name==="AsyncFunction"}function q(e,n){let t=new Map,r=function(...a){let i=n?n(...a):JSON.stringify(a);if(t.has(i))return t.get(i);let o=e.apply(this,a);return t.set(i,o),o};return r.cache=t,r}function E(e,n,t={}){let{leading:r=!1,trailing:a=!0,maxWait:i}=t,o,c,s,y=0,p,f,l;function x(u){let T=p,d=f;return p=f=void 0,y=u,l=e.apply(d,T),l}function m(u,T){return setTimeout(u,T)}function b(u){u!==void 0&&clearTimeout(u)}function I(u){return y=u,o=m(g,n),r?x(u):l}function M(u){let T=u-s,d=u-y,w=n-T;return i!==void 0?Math.min(w,i-d):w}function P(u){let T=u-s,d=u-y;return s===void 0||T>=n||T<0||i!==void 0&&d>=i}function g(){let u=Date.now();if(P(u)){v(u);return}o=m(g,M(u))}function v(u){return o=void 0,a&&p?x(u):(p=f=void 0,l)}function S(){b(o),b(c),y=0,p=s=f=o=c=void 0}function W(){return o===void 0?l:v(Date.now())}function D(){return o!==void 0}function h(...u){let T=Date.now(),d=P(T);if(p=u,f=this,s=T,d){if(o===void 0)return I(s);if(i!==void 0)return o=m(g,n),x(s)}return o===void 0&&(o=m(g,n)),l}return h.cancel=S,h.flush=W,h.pending=D,h}function B(e,n,t={}){let{leading:r=!0,trailing:a=!0}=t;return E(e,n,{leading:r,trailing:a,maxWait:n})}function G(e){let n=!1,t,r=function(...a){return n||(n=!0,t=e.apply(this,a)),t};return Object.defineProperty(r,"called",{get(){return n}}),r}function H(e,...n){return function(...t){let r=n.map(a=>t[a]);return e.apply(this,r)}}function K(e,n=e.length){return function t(...r){return r.length>=n?e.apply(this,r):function(...a){return t.apply(this,[...r,...a])}}}function C(...e){return e.reduceRight((n,t)=>r=>t(n(r)),n=>n)}function F(...e){return e.reduce((n,t)=>r=>t(n(r)),n=>n)}function Q(e){return function(...n){return!e.apply(this,n)}}function U(e,...n){return function(...t){let r=t.map((a,i)=>n[i]?n[i](a):a);return e.apply(this,r)}}function V(e,...n){return function(...t){return e.apply(this,[...n,...t])}}function X(e,...n){return function(...t){return e.apply(this,[...t,...n])}}function Y(e,n,...t){return function(...r){return e.apply(n,[...t,...r])}}function Z(e){return function(...n){return e.apply(this,n.reverse())}}function ee(e,n){return function(...t){return e.apply(this,t.slice(0,n))}}function ne(e){return function(n){return e.call(this,n)}}function te(e,...n){return setTimeout(e,1,...n)}function re(e,n,...t){return setTimeout(e,n,...t)}function ae(e,n,t){let r=new Map,a=function(...i){let o=t?t(...i):JSON.stringify(i),c=Date.now(),s=r.get(o);if(s&&s.expires>c)return s.value;let y=e.apply(this,i);r.set(o,{value:y,expires:c+n});for(let[p,f]of r.entries())f.expires<=c&&r.delete(p);return y};return a.cache=r,a}function ue(e,n){let t,r=0;return function(...a){return++r<n&&(t=e.apply(this,a)),r>=n&&(e=void 0),t}}function ie(e,n){let t=0;return function(...r){if(++t>=n)return e.apply(this,r)}}function oe(e,n){return function(...t){try{return e.apply(this,t)}catch(r){return n(r,...t)}}}function se(...e){return F(...e)}function ye(...e){return C(...e)}function Te(e,n={}){let{retries:t=3,delay:r=1e3,backoff:a=2,onRetry:i}=n;return async function(...o){let c,s=r;for(let y=0;y<=t;y++)try{return await e.apply(this,o)}catch(p){c=p,y<t&&(i&&i(c,y+1),await new Promise(f=>setTimeout(f,s)),s*=a)}throw c}}function ce(e,n,t){return async function(...r){return Promise.race([e.apply(this,r),new Promise((a,i)=>setTimeout(()=>{t&&t(),i(new Error(`Function timed out after ${n}ms`))},n))])}}
@@ -0,0 +1,329 @@
1
+ /**
2
+ * Check if value is a function
3
+ * @param v - The value to check
4
+ * @returns True if the value is a function, false otherwise
5
+ */
6
+ export declare function isFunction<T extends Function = Function>(v: unknown): v is T;
7
+ /**
8
+ * Check if value is a Promise
9
+ * @param v - The value to check
10
+ * @returns True if the value is a Promise, false otherwise
11
+ */
12
+ export declare function isPromise<T = any>(v: unknown): v is Promise<T>;
13
+ /**
14
+ * Check if value is an async function
15
+ * @param v - The value to check
16
+ * @returns True if the value is an async function, false otherwise
17
+ */
18
+ export declare function isAsyncFunction<T extends (...args: any) => Promise<any> = any>(v: unknown): v is T;
19
+ /**
20
+ * Memoizes a function, caching results based on arguments
21
+ * @param fn - Function to memoize
22
+ * @param resolver - Optional function to generate cache key
23
+ * @returns Memoized function with cache property
24
+ * @example
25
+ * const expensive = memoize((n: number) => {
26
+ * return n * n;
27
+ * });
28
+ * expensive(5); // Computed
29
+ * expensive(5); // Cached
30
+ */
31
+ export declare function memoize<T extends (...args: any[]) => any>(fn: T, resolver?: (...args: Parameters<T>) => string): T & {
32
+ cache: Map<string, ReturnType<T>>;
33
+ };
34
+ /**
35
+ * Creates a debounced function that delays invoking func until after wait milliseconds
36
+ * @param fn - Function to debounce
37
+ * @param wait - Milliseconds to wait
38
+ * @param options - Debounce options
39
+ * @returns Debounced function with cancel method
40
+ * @example
41
+ * const debounced = debounce(() => console.log('Search'), 300);
42
+ * debounced(); // Will execute after 300ms of inactivity
43
+ */
44
+ export declare function debounce<T extends (...args: any[]) => any>(fn: T, wait: number, options?: {
45
+ leading?: boolean;
46
+ trailing?: boolean;
47
+ maxWait?: number;
48
+ }): T & {
49
+ cancel: () => void;
50
+ flush: () => void;
51
+ pending: () => boolean;
52
+ };
53
+ /**
54
+ * Creates a throttled function that only invokes func at most once per every wait milliseconds
55
+ * @param fn - Function to throttle
56
+ * @param wait - Milliseconds to wait
57
+ * @param options - Throttle options
58
+ * @returns Throttled function with cancel method
59
+ * @example
60
+ * const throttled = throttle(() => console.log('Scroll'), 100);
61
+ * window.addEventListener('scroll', throttled);
62
+ */
63
+ export declare function throttle<T extends (...args: any[]) => any>(fn: T, wait: number, options?: {
64
+ leading?: boolean;
65
+ trailing?: boolean;
66
+ }): T & {
67
+ cancel: () => void;
68
+ flush: () => void;
69
+ };
70
+ /**
71
+ * Creates a function that is restricted to invoking func once
72
+ * @param fn - Function to restrict
73
+ * @returns Function that invokes func once
74
+ * @example
75
+ * const initialize = once(() => console.log('Initialized'));
76
+ * initialize(); // Logs 'Initialized'
77
+ * initialize(); // Does nothing
78
+ */
79
+ export declare function once<T extends (...args: any[]) => any>(fn: T): T & {
80
+ called: boolean;
81
+ };
82
+ /**
83
+ * Creates a function that invokes func with arguments arranged according to the specified indexes
84
+ * @param fn - Function to rearrange arguments for
85
+ * @param indexes - Argument indexes
86
+ * @returns New function with rearranged arguments
87
+ * @example
88
+ * const rearg = rearg((a, b, c) => [a, b, c], [2, 0, 1]);
89
+ * rearg('a', 'b', 'c'); // ['c', 'a', 'b']
90
+ */
91
+ export declare function rearg<T extends (...args: any[]) => any>(fn: T, ...indexes: number[]): (...args: any[]) => ReturnType<T>;
92
+ /**
93
+ * Curries a function
94
+ * @param fn - Function to curry
95
+ * @param arity - Number of arguments (defaults to fn.length)
96
+ * @returns Curried function
97
+ * @example
98
+ * const add = (a: number, b: number, c: number) => a + b + c;
99
+ * const curried = curry(add);
100
+ * curried(1)(2)(3); // 6
101
+ * curried(1, 2)(3); // 6
102
+ */
103
+ export declare function curry<T extends (...args: any[]) => any>(fn: T, arity?: number): any;
104
+ /**
105
+ * Composes functions from right to left
106
+ * @param fns - Functions to compose
107
+ * @returns Composed function
108
+ * @example
109
+ * const double = (x: number) => x * 2;
110
+ * const addOne = (x: number) => x + 1;
111
+ * const composed = compose(double, addOne);
112
+ * composed(5); // 12 (addOne first, then double)
113
+ */
114
+ export declare function compose<R>(...fns: Array<(arg: any) => any>): (arg: any) => R;
115
+ /**
116
+ * Pipes functions from left to right
117
+ * @param fns - Functions to pipe
118
+ * @returns Piped function
119
+ * @example
120
+ * const double = (x: number) => x * 2;
121
+ * const addOne = (x: number) => x + 1;
122
+ * const piped = pipe(double, addOne);
123
+ * piped(5); // 11 (double first, then addOne)
124
+ */
125
+ export declare function pipe<R>(...fns: Array<(arg: any) => any>): (arg: any) => R;
126
+ /**
127
+ * Creates a function that negates the result of the predicate func
128
+ * @param predicate - Predicate to negate
129
+ * @returns Negated predicate
130
+ * @example
131
+ * const isEven = (n: number) => n % 2 === 0;
132
+ * const isOdd = negate(isEven);
133
+ * isOdd(3); // true
134
+ */
135
+ export declare function negate<T extends (...args: any[]) => boolean>(predicate: T): T;
136
+ /**
137
+ * Creates a function that invokes func with its arguments transformed
138
+ * @param fn - Function to wrap
139
+ * @param transforms - Argument transforms
140
+ * @returns New function with transformed arguments
141
+ * @example
142
+ * const doubled = overArgs((x, y) => [x, y], [x => x * 2, x => x * 3]);
143
+ * doubled(1, 1); // [2, 3]
144
+ */
145
+ export declare function overArgs<T extends (...args: any[]) => any>(fn: T, ...transforms: Array<(arg: any) => any>): (...args: any[]) => ReturnType<T>;
146
+ /**
147
+ * Creates a function that invokes func with partials prepended to the arguments
148
+ * @param fn - Function to partially apply arguments to
149
+ * @param partials - Arguments to be partially applied
150
+ * @returns Partially applied function
151
+ * @example
152
+ * const greet = (greeting: string, name: string) => `${greeting}, ${name}!`;
153
+ * const sayHello = partial(greet, 'Hello');
154
+ * sayHello('World'); // 'Hello, World!'
155
+ */
156
+ export declare function partial<T extends (...args: any[]) => any>(fn: T, ...partials: any[]): (...args: any[]) => ReturnType<T>;
157
+ /**
158
+ * Creates a function that invokes func with partials appended to the arguments
159
+ * @param fn - Function to partially apply arguments to
160
+ * @param partials - Arguments to be partially applied
161
+ * @returns Partially applied function
162
+ * @example
163
+ * const greet = (name: string, greeting: string) => `${greeting}, ${name}!`;
164
+ * const greetWorld = partialRight(greet, 'Hello');
165
+ * greetWorld('World'); // 'Hello, World!'
166
+ */
167
+ export declare function partialRight<T extends (...args: any[]) => any>(fn: T, ...partials: any[]): (...args: any[]) => ReturnType<T>;
168
+ /**
169
+ * Creates a function that invokes func with the this binding of the created function
170
+ * @param fn - Function to bind
171
+ * @param thisArg - The this binding of func
172
+ * @param partials - Arguments to be partially applied
173
+ * @returns Bound function
174
+ * @example
175
+ * const obj = { x: 42 };
176
+ * const getX = bind(function() { return this.x; }, obj);
177
+ * getX(); // 42
178
+ */
179
+ export declare function bind<T extends (...args: any[]) => any>(fn: T, thisArg: any, ...partials: any[]): (...args: any[]) => ReturnType<T>;
180
+ /**
181
+ * Creates a function that invokes func with arguments reversed
182
+ * @param fn - Function to flip arguments for
183
+ * @returns Function with flipped arguments
184
+ * @example
185
+ * const flipped = flip((a, b, c) => [a, b, c]);
186
+ * flipped(1, 2, 3); // [3, 2, 1]
187
+ */
188
+ export declare function flip<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
189
+ /**
190
+ * Creates a function that accepts up to n arguments, ignoring any additional arguments
191
+ * @param fn - Function to cap arguments for
192
+ * @param n - Arity cap
193
+ * @returns Function with capped arity
194
+ * @example
195
+ * const capped = ary((a, b, c) => [a, b, c], 2);
196
+ * capped(1, 2, 3, 4); // [1, 2, undefined]
197
+ */
198
+ export declare function ary<T extends (...args: any[]) => any>(fn: T, n: number): (...args: any[]) => ReturnType<T>;
199
+ /**
200
+ * Creates a function that accepts up to one argument, ignoring any additional arguments
201
+ * @param fn - Function to cap arguments for
202
+ * @returns Unary function
203
+ * @example
204
+ * const unary = unary(parseInt);
205
+ * ['6', '8', '10'].map(unary); // [6, 8, 10] instead of [6, NaN, 2]
206
+ */
207
+ export declare function unary<T extends (arg: any, ...rest: any[]) => any>(fn: T): (arg: Parameters<T>[0]) => ReturnType<T>;
208
+ /**
209
+ * Defers invoking the func until the current call stack has cleared
210
+ * @param fn - Function to defer
211
+ * @param args - Arguments to invoke func with
212
+ * @returns Timer id
213
+ * @example
214
+ * defer(console.log, 'Deferred');
215
+ */
216
+ export declare function defer<T extends (...args: any[]) => any>(fn: T, ...args: Parameters<T>): ReturnType<typeof setTimeout>;
217
+ /**
218
+ * Delays invoking func until after wait milliseconds
219
+ * @param fn - Function to delay
220
+ * @param wait - Milliseconds to delay invocation
221
+ * @param args - Arguments to invoke func with
222
+ * @returns Timer id
223
+ * @example
224
+ * delay(console.log, 1000, 'Delayed');
225
+ */
226
+ export declare function delay<T extends (...args: any[]) => any>(fn: T, wait: number, ...args: Parameters<T>): ReturnType<typeof setTimeout>;
227
+ /**
228
+ * Creates a function that memoizes the result of func with a Time-To-Live (TTL)
229
+ * @param fn - Function to memoize
230
+ * @param ttl - Time to live in milliseconds
231
+ * @param resolver - Optional function to generate cache key
232
+ * @returns Memoized function with TTL
233
+ * @example
234
+ * const expensiveApi = memoizeWithTTL(fetchData, 60000); // Cache for 1 minute
235
+ */
236
+ export declare function memoizeWithTTL<T extends (...args: any[]) => any>(fn: T, ttl: number, resolver?: (...args: Parameters<T>) => string): T & {
237
+ cache: Map<string, {
238
+ value: ReturnType<T>;
239
+ expires: number;
240
+ }>;
241
+ };
242
+ /**
243
+ * Creates a function that invokes func at most n times
244
+ * @param fn - Function to restrict
245
+ * @param n - Number of calls at which to stop executing func
246
+ * @returns Restricted function
247
+ * @example
248
+ * const limited = before((n) => console.log(n), 3);
249
+ * limited(1); // Logs 1
250
+ * limited(2); // Logs 2
251
+ * limited(3); // Does nothing
252
+ */
253
+ export declare function before<T extends (...args: any[]) => any>(fn: T, n: number): T;
254
+ /**
255
+ * Creates a function that invokes func once it's called n or more times
256
+ * @param fn - Function to restrict
257
+ * @param n - Number of calls before func is invoked
258
+ * @returns Restricted function
259
+ * @example
260
+ * const afterThree = after((n) => console.log('Called!'), 3);
261
+ * afterThree(); // Does nothing
262
+ * afterThree(); // Does nothing
263
+ * afterThree(); // Logs 'Called!'
264
+ */
265
+ export declare function after<T extends (...args: any[]) => any>(fn: T, n: number): T;
266
+ /**
267
+ * Wraps a function to catch and handle errors
268
+ * @param fn - Function to wrap
269
+ * @param errorHandler - Error handler function
270
+ * @returns Wrapped function
271
+ * @example
272
+ * const safe = tryCatch(
273
+ * () => JSON.parse('invalid'),
274
+ * (error) => ({ error: error.message })
275
+ * );
276
+ */
277
+ export declare function tryCatch<T extends (...args: any[]) => any>(fn: T, errorHandler: (error: Error, ...args: Parameters<T>) => any): T;
278
+ /**
279
+ * Creates a function that returns the result of invoking the given functions with the this binding of the created function,
280
+ * where each successive invocation is supplied the return value of the previous
281
+ * @param fns - Functions to invoke
282
+ * @returns Flow function
283
+ * @example
284
+ * const calculate = flow(
285
+ * (n: number) => n * 2,
286
+ * (n: number) => n + 1,
287
+ * (n: number) => n * 3
288
+ * );
289
+ * calculate(5); // 33
290
+ */
291
+ export declare function flow<R>(...fns: Array<(arg: any) => any>): (arg: any) => R;
292
+ /**
293
+ * Creates a function that returns the result of invoking the given functions from right to left
294
+ * @param fns - Functions to invoke
295
+ * @returns Flow right function
296
+ * @example
297
+ * const calculate = flowRight(
298
+ * (n: number) => n * 3,
299
+ * (n: number) => n + 1,
300
+ * (n: number) => n * 2
301
+ * );
302
+ * calculate(5); // 33
303
+ */
304
+ export declare function flowRight<R>(...fns: Array<(arg: any) => any>): (arg: any) => R;
305
+ /**
306
+ * Wraps an async function to retry on failure
307
+ * @param fn - Async function to wrap
308
+ * @param options - Retry options
309
+ * @returns Wrapped function with retry logic
310
+ * @example
311
+ * const fetchWithRetry = retry(fetchData, { retries: 3, delay: 1000 });
312
+ */
313
+ export declare function retry<T extends (...args: any[]) => Promise<any>>(fn: T, options?: {
314
+ retries?: number;
315
+ delay?: number;
316
+ backoff?: number;
317
+ onRetry?: (error: Error, attempt: number) => void;
318
+ }): T;
319
+ /**
320
+ * Creates a function that invokes func with a timeout
321
+ * @param fn - Function to wrap with timeout
322
+ * @param timeout - Timeout in milliseconds
323
+ * @param onTimeout - Optional callback when timeout occurs
324
+ * @returns Function with timeout
325
+ * @example
326
+ * const timedFetch = withTimeout(fetchData, 5000);
327
+ */
328
+ export declare function withTimeout<T extends (...args: any[]) => Promise<any>>(fn: T, timeout: number, onTimeout?: () => void): T;
329
+ //# sourceMappingURL=functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/lib/functions/functions.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAE5E;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAK9D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,EAC5E,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,CAAC,CAER;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACvD,EAAE,EAAE,CAAC,EACL,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,GAC5C,CAAC,GAAG;IAAE,KAAK,EAAE,GAAG,CAAC,M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