@splendidlabz/utils 1.11.2 → 1.11.3

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 (305) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +2 -2
  3. package/src/lib/objects/omit-empty.js +1 -1
  4. package/src/lib/strings/markdown.spec.js +73 -0
  5. package/src/node/context.js +0 -0
  6. package/src/node/file-cache.js +1 -1
  7. package/src/node/pkce.js +1 -1
  8. package/tsup.config.mjs +19 -1
  9. package/dist/cjs/dom/accessibility.cjs +0 -51
  10. package/dist/cjs/dom/actions/index.cjs +0 -25
  11. package/dist/cjs/dom/actions/masonry.cjs +0 -61
  12. package/dist/cjs/dom/actions/prefer-horizontal-scroll.cjs +0 -113
  13. package/dist/cjs/dom/actions/sticky.cjs +0 -93
  14. package/dist/cjs/dom/bounding-box.cjs +0 -68
  15. package/dist/cjs/dom/clipboard.cjs +0 -35
  16. package/dist/cjs/dom/cookie.cjs +0 -55
  17. package/dist/cjs/dom/css-vars.cjs +0 -47
  18. package/dist/cjs/dom/events.cjs +0 -57
  19. package/dist/cjs/dom/focusable.cjs +0 -141
  20. package/dist/cjs/dom/font-size.cjs +0 -68
  21. package/dist/cjs/dom/get-element.cjs +0 -96
  22. package/dist/cjs/dom/hash.cjs +0 -33
  23. package/dist/cjs/dom/index.cjs +0 -65
  24. package/dist/cjs/dom/keyboard.cjs +0 -49
  25. package/dist/cjs/dom/local-store.cjs +0 -77
  26. package/dist/cjs/dom/media.cjs +0 -57
  27. package/dist/cjs/dom/observers/index.cjs +0 -27
  28. package/dist/cjs/dom/observers/intersection-observer.cjs +0 -59
  29. package/dist/cjs/dom/observers/mutation-observer.cjs +0 -63
  30. package/dist/cjs/dom/observers/observer.cjs +0 -38
  31. package/dist/cjs/dom/observers/resize-observer.cjs +0 -52
  32. package/dist/cjs/dom/observers/scroll-observer.cjs +0 -118
  33. package/dist/cjs/dom/pkce.cjs +0 -43
  34. package/dist/cjs/dom/query-params.cjs +0 -36
  35. package/dist/cjs/dom/random-string.cjs +0 -36
  36. package/dist/cjs/dom/sanitize.cjs +0 -41
  37. package/dist/cjs/dom/session-store.cjs +0 -47
  38. package/dist/cjs/dom/spam-prevention.cjs +0 -48
  39. package/dist/cjs/dom/trap-focus.cjs +0 -75
  40. package/dist/cjs/dom/ui/aria-current.cjs +0 -41
  41. package/dist/cjs/dom/ui/inconsistent-button-fix.cjs +0 -33
  42. package/dist/cjs/dom/ui/index.cjs +0 -27
  43. package/dist/cjs/dom/ui/scroll-container.cjs +0 -45
  44. package/dist/cjs/dom/ui/traverse-and-scramble.cjs +0 -48
  45. package/dist/cjs/lib/arrays/index.cjs +0 -31
  46. package/dist/cjs/lib/arrays/item-position.cjs +0 -40
  47. package/dist/cjs/lib/arrays/join.cjs +0 -35
  48. package/dist/cjs/lib/arrays/shuffle.cjs +0 -40
  49. package/dist/cjs/lib/arrays/sort.cjs +0 -59
  50. package/dist/cjs/lib/arrays/split-array.cjs +0 -39
  51. package/dist/cjs/lib/arrays/unique.cjs +0 -29
  52. package/dist/cjs/lib/auth/index.cjs +0 -21
  53. package/dist/cjs/lib/auth/route-manager.cjs +0 -49
  54. package/dist/cjs/lib/checks.cjs +0 -61
  55. package/dist/cjs/lib/date/days.cjs +0 -35
  56. package/dist/cjs/lib/date/index.cjs +0 -25
  57. package/dist/cjs/lib/date/months.cjs +0 -100
  58. package/dist/cjs/lib/date/time.cjs +0 -105
  59. package/dist/cjs/lib/form/form-data.cjs +0 -81
  60. package/dist/cjs/lib/form/index.cjs +0 -23
  61. package/dist/cjs/lib/form/sanitize.cjs +0 -59
  62. package/dist/cjs/lib/functions/callback.cjs +0 -29
  63. package/dist/cjs/lib/functions/debounce.cjs +0 -41
  64. package/dist/cjs/lib/functions/env.cjs +0 -30
  65. package/dist/cjs/lib/functions/functional.cjs +0 -80
  66. package/dist/cjs/lib/functions/index.cjs +0 -29
  67. package/dist/cjs/lib/functions/throttle.cjs +0 -36
  68. package/dist/cjs/lib/functions/timeout.cjs +0 -39
  69. package/dist/cjs/lib/hash.cjs +0 -41
  70. package/dist/cjs/lib/index.cjs +0 -47
  71. package/dist/cjs/lib/numbers/index.cjs +0 -36
  72. package/dist/cjs/lib/numbers/math.cjs +0 -34
  73. package/dist/cjs/lib/objects/camelcase-keys.cjs +0 -39
  74. package/dist/cjs/lib/objects/empty.cjs +0 -37
  75. package/dist/cjs/lib/objects/equal.cjs +0 -45
  76. package/dist/cjs/lib/objects/extend.cjs +0 -36
  77. package/dist/cjs/lib/objects/flatten.cjs +0 -40
  78. package/dist/cjs/lib/objects/index.cjs +0 -45
  79. package/dist/cjs/lib/objects/json.cjs +0 -33
  80. package/dist/cjs/lib/objects/loop.cjs +0 -38
  81. package/dist/cjs/lib/objects/mix/mix.cjs +0 -113
  82. package/dist/cjs/lib/objects/nested-property.cjs +0 -43
  83. package/dist/cjs/lib/objects/normalize-object.cjs +0 -32
  84. package/dist/cjs/lib/objects/omit-empty.cjs +0 -38
  85. package/dist/cjs/lib/objects/size.cjs +0 -61
  86. package/dist/cjs/lib/objects/split.cjs +0 -37
  87. package/dist/cjs/lib/promises/index.cjs +0 -21
  88. package/dist/cjs/lib/promises/reject.cjs +0 -50
  89. package/dist/cjs/lib/sse.cjs +0 -74
  90. package/dist/cjs/lib/strings/convert-case/convert-case.cjs +0 -94
  91. package/dist/cjs/lib/strings/index.cjs +0 -29
  92. package/dist/cjs/lib/strings/markdown.cjs +0 -74
  93. package/dist/cjs/lib/strings/name.cjs +0 -44
  94. package/dist/cjs/lib/strings/pluralize.cjs +0 -38
  95. package/dist/cjs/lib/strings/query-string.cjs +0 -41
  96. package/dist/cjs/lib/style/index.cjs +0 -35
  97. package/dist/cjs/lib/symbols/index.cjs +0 -21
  98. package/dist/cjs/lib/symbols/symbols.cjs +0 -36
  99. package/dist/cjs/node/dirname.cjs +0 -47
  100. package/dist/cjs/node/file-cache.cjs +0 -158
  101. package/dist/cjs/node/file.cjs +0 -48
  102. package/dist/cjs/node/hash.cjs +0 -40
  103. package/dist/cjs/node/index.cjs +0 -33
  104. package/dist/cjs/node/pkce.cjs +0 -52
  105. package/dist/cjs/node/random-string.cjs +0 -41
  106. package/dist/cjs/node/sanitize.cjs +0 -41
  107. package/dist/cjs/node/uuid.cjs +0 -40
  108. package/dist/esm/dom/accessibility.js +0 -26
  109. package/dist/esm/dom/actions/index.js +0 -3
  110. package/dist/esm/dom/actions/masonry.js +0 -38
  111. package/dist/esm/dom/actions/prefer-horizontal-scroll.js +0 -90
  112. package/dist/esm/dom/actions/sticky.js +0 -70
  113. package/dist/esm/dom/bounding-box.js +0 -44
  114. package/dist/esm/dom/clipboard.js +0 -12
  115. package/dist/esm/dom/cookie.js +0 -31
  116. package/dist/esm/dom/css-vars.js +0 -21
  117. package/dist/esm/dom/events.js +0 -31
  118. package/dist/esm/dom/focusable.js +0 -117
  119. package/dist/esm/dom/font-size.js +0 -40
  120. package/dist/esm/dom/get-element.js +0 -66
  121. package/dist/esm/dom/hash.js +0 -10
  122. package/dist/esm/dom/index.js +0 -23
  123. package/dist/esm/dom/keyboard.js +0 -22
  124. package/dist/esm/dom/local-store.js +0 -54
  125. package/dist/esm/dom/media.js +0 -32
  126. package/dist/esm/dom/observers/index.js +0 -4
  127. package/dist/esm/dom/observers/intersection-observer.js +0 -36
  128. package/dist/esm/dom/observers/mutation-observer.js +0 -40
  129. package/dist/esm/dom/observers/observer.js +0 -15
  130. package/dist/esm/dom/observers/resize-observer.js +0 -29
  131. package/dist/esm/dom/observers/scroll-observer.js +0 -95
  132. package/dist/esm/dom/pkce.js +0 -20
  133. package/dist/esm/dom/query-params.js +0 -13
  134. package/dist/esm/dom/random-string.js +0 -12
  135. package/dist/esm/dom/sanitize.js +0 -8
  136. package/dist/esm/dom/session-store.js +0 -24
  137. package/dist/esm/dom/spam-prevention.js +0 -25
  138. package/dist/esm/dom/trap-focus.js +0 -51
  139. package/dist/esm/dom/ui/aria-current.js +0 -17
  140. package/dist/esm/dom/ui/inconsistent-button-fix.js +0 -10
  141. package/dist/esm/dom/ui/index.js +0 -4
  142. package/dist/esm/dom/ui/scroll-container.js +0 -22
  143. package/dist/esm/dom/ui/traverse-and-scramble.js +0 -25
  144. package/dist/esm/lib/arrays/index.js +0 -6
  145. package/dist/esm/lib/arrays/item-position.js +0 -15
  146. package/dist/esm/lib/arrays/join.js +0 -12
  147. package/dist/esm/lib/arrays/shuffle.js +0 -17
  148. package/dist/esm/lib/arrays/sort.js +0 -36
  149. package/dist/esm/lib/arrays/split-array.js +0 -16
  150. package/dist/esm/lib/arrays/unique.js +0 -6
  151. package/dist/esm/lib/auth/index.js +0 -1
  152. package/dist/esm/lib/auth/route-manager.js +0 -25
  153. package/dist/esm/lib/checks.js +0 -34
  154. package/dist/esm/lib/date/days.js +0 -12
  155. package/dist/esm/lib/date/index.js +0 -3
  156. package/dist/esm/lib/date/months.js +0 -77
  157. package/dist/esm/lib/date/time.js +0 -75
  158. package/dist/esm/lib/form/form-data.js +0 -57
  159. package/dist/esm/lib/form/index.js +0 -2
  160. package/dist/esm/lib/form/sanitize.js +0 -34
  161. package/dist/esm/lib/functions/callback.js +0 -6
  162. package/dist/esm/lib/functions/debounce.js +0 -18
  163. package/dist/esm/lib/functions/env.js +0 -7
  164. package/dist/esm/lib/functions/functional.js +0 -52
  165. package/dist/esm/lib/functions/index.js +0 -5
  166. package/dist/esm/lib/functions/throttle.js +0 -13
  167. package/dist/esm/lib/functions/timeout.js +0 -14
  168. package/dist/esm/lib/hash.js +0 -18
  169. package/dist/esm/lib/index.js +0 -14
  170. package/dist/esm/lib/numbers/index.js +0 -11
  171. package/dist/esm/lib/numbers/math.js +0 -10
  172. package/dist/esm/lib/objects/camelcase-keys.js +0 -16
  173. package/dist/esm/lib/objects/empty.js +0 -13
  174. package/dist/esm/lib/objects/equal.js +0 -11
  175. package/dist/esm/lib/objects/extend.js +0 -13
  176. package/dist/esm/lib/objects/flatten.js +0 -17
  177. package/dist/esm/lib/objects/index.js +0 -13
  178. package/dist/esm/lib/objects/json.js +0 -10
  179. package/dist/esm/lib/objects/loop.js +0 -14
  180. package/dist/esm/lib/objects/mix/mix.js +0 -88
  181. package/dist/esm/lib/objects/nested-property.js +0 -18
  182. package/dist/esm/lib/objects/normalize-object.js +0 -9
  183. package/dist/esm/lib/objects/omit-empty.js +0 -15
  184. package/dist/esm/lib/objects/size.js +0 -38
  185. package/dist/esm/lib/objects/split.js +0 -14
  186. package/dist/esm/lib/promises/index.js +0 -1
  187. package/dist/esm/lib/promises/reject.js +0 -17
  188. package/dist/esm/lib/sse.js +0 -50
  189. package/dist/esm/lib/strings/convert-case/convert-case.js +0 -64
  190. package/dist/esm/lib/strings/index.js +0 -5
  191. package/dist/esm/lib/strings/markdown.js +0 -40
  192. package/dist/esm/lib/strings/name.js +0 -21
  193. package/dist/esm/lib/strings/pluralize.js +0 -5
  194. package/dist/esm/lib/strings/query-string.js +0 -16
  195. package/dist/esm/lib/style/index.js +0 -12
  196. package/dist/esm/lib/symbols/index.js +0 -1
  197. package/dist/esm/lib/symbols/symbols.js +0 -12
  198. package/dist/esm/node/dirname.js +0 -13
  199. package/dist/esm/node/file-cache.js +0 -121
  200. package/dist/esm/node/file.js +0 -14
  201. package/dist/esm/node/hash.js +0 -7
  202. package/dist/esm/node/index.js +0 -7
  203. package/dist/esm/node/pkce.js +0 -19
  204. package/dist/esm/node/random-string.js +0 -8
  205. package/dist/esm/node/sanitize.js +0 -8
  206. package/dist/esm/node/uuid.js +0 -7
  207. package/dist/types/dom/accessibility.d.cts +0 -30
  208. package/dist/types/dom/actions/index.d.cts +0 -3
  209. package/dist/types/dom/actions/masonry.d.cts +0 -5
  210. package/dist/types/dom/actions/prefer-horizontal-scroll.d.cts +0 -5
  211. package/dist/types/dom/actions/sticky.d.cts +0 -5
  212. package/dist/types/dom/bounding-box.d.cts +0 -41
  213. package/dist/types/dom/clipboard.d.cts +0 -7
  214. package/dist/types/dom/cookie.d.cts +0 -7
  215. package/dist/types/dom/css-vars.d.cts +0 -6
  216. package/dist/types/dom/events.d.cts +0 -92
  217. package/dist/types/dom/focusable.d.cts +0 -78
  218. package/dist/types/dom/font-size.d.cts +0 -8
  219. package/dist/types/dom/get-element.d.cts +0 -102
  220. package/dist/types/dom/hash.d.cts +0 -3
  221. package/dist/types/dom/index.d.cts +0 -31
  222. package/dist/types/dom/keyboard.d.cts +0 -32
  223. package/dist/types/dom/local-store.d.cts +0 -31
  224. package/dist/types/dom/media.d.cts +0 -5
  225. package/dist/types/dom/observers/index.d.cts +0 -4
  226. package/dist/types/dom/observers/intersection-observer.d.cts +0 -10
  227. package/dist/types/dom/observers/mutation-observer.d.cts +0 -9
  228. package/dist/types/dom/observers/observer.d.cts +0 -3
  229. package/dist/types/dom/observers/resize-observer.d.cts +0 -40
  230. package/dist/types/dom/observers/scroll-observer.d.cts +0 -40
  231. package/dist/types/dom/pkce.d.cts +0 -8
  232. package/dist/types/dom/query-params.d.cts +0 -6
  233. package/dist/types/dom/random-string.d.cts +0 -9
  234. package/dist/types/dom/sanitize.d.cts +0 -10
  235. package/dist/types/dom/session-store.d.cts +0 -7
  236. package/dist/types/dom/spam-prevention.d.cts +0 -14
  237. package/dist/types/dom/trap-focus.d.cts +0 -32
  238. package/dist/types/dom/ui/aria-current.d.cts +0 -7
  239. package/dist/types/dom/ui/inconsistent-button-fix.d.cts +0 -14
  240. package/dist/types/dom/ui/index.d.cts +0 -4
  241. package/dist/types/dom/ui/scroll-container.d.cts +0 -3
  242. package/dist/types/dom/ui/traverse-and-scramble.d.cts +0 -21
  243. package/dist/types/lib/arrays/index.d.cts +0 -6
  244. package/dist/types/lib/arrays/item-position.d.cts +0 -16
  245. package/dist/types/lib/arrays/join.d.cts +0 -15
  246. package/dist/types/lib/arrays/shuffle.d.cts +0 -3
  247. package/dist/types/lib/arrays/sort.d.cts +0 -32
  248. package/dist/types/lib/arrays/split-array.d.cts +0 -6
  249. package/dist/types/lib/arrays/unique.d.cts +0 -3
  250. package/dist/types/lib/auth/index.d.cts +0 -1
  251. package/dist/types/lib/auth/route-manager.d.cts +0 -28
  252. package/dist/types/lib/checks.d.cts +0 -33
  253. package/dist/types/lib/date/days.d.cts +0 -7
  254. package/dist/types/lib/date/index.d.cts +0 -3
  255. package/dist/types/lib/date/months.d.cts +0 -11
  256. package/dist/types/lib/date/time.d.cts +0 -21
  257. package/dist/types/lib/form/form-data.d.cts +0 -9
  258. package/dist/types/lib/form/index.d.cts +0 -2
  259. package/dist/types/lib/form/sanitize.d.cts +0 -60
  260. package/dist/types/lib/functions/callback.d.cts +0 -8
  261. package/dist/types/lib/functions/debounce.d.cts +0 -3
  262. package/dist/types/lib/functions/env.d.cts +0 -3
  263. package/dist/types/lib/functions/functional.d.cts +0 -72
  264. package/dist/types/lib/functions/index.d.cts +0 -5
  265. package/dist/types/lib/functions/throttle.d.cts +0 -3
  266. package/dist/types/lib/functions/timeout.d.cts +0 -5
  267. package/dist/types/lib/hash.d.cts +0 -3
  268. package/dist/types/lib/index.d.cts +0 -43
  269. package/dist/types/lib/numbers/index.d.cts +0 -5
  270. package/dist/types/lib/numbers/math.d.cts +0 -4
  271. package/dist/types/lib/objects/camelcase-keys.d.cts +0 -3
  272. package/dist/types/lib/objects/empty.d.cts +0 -4
  273. package/dist/types/lib/objects/equal.d.cts +0 -4
  274. package/dist/types/lib/objects/extend.d.cts +0 -6
  275. package/dist/types/lib/objects/flatten.d.cts +0 -6
  276. package/dist/types/lib/objects/index.d.cts +0 -13
  277. package/dist/types/lib/objects/json.d.cts +0 -3
  278. package/dist/types/lib/objects/loop.d.cts +0 -4
  279. package/dist/types/lib/objects/mix/mix.d.cts +0 -44
  280. package/dist/types/lib/objects/nested-property.d.cts +0 -24
  281. package/dist/types/lib/objects/normalize-object.d.cts +0 -3
  282. package/dist/types/lib/objects/omit-empty.d.cts +0 -3
  283. package/dist/types/lib/objects/size.d.cts +0 -3
  284. package/dist/types/lib/objects/split.d.cts +0 -14
  285. package/dist/types/lib/promises/index.d.cts +0 -1
  286. package/dist/types/lib/promises/reject.d.cts +0 -5
  287. package/dist/types/lib/sse.d.cts +0 -18
  288. package/dist/types/lib/strings/convert-case/convert-case.d.cts +0 -10
  289. package/dist/types/lib/strings/index.d.cts +0 -5
  290. package/dist/types/lib/strings/markdown.d.cts +0 -25
  291. package/dist/types/lib/strings/name.d.cts +0 -7
  292. package/dist/types/lib/strings/pluralize.d.cts +0 -3
  293. package/dist/types/lib/strings/query-string.d.cts +0 -10
  294. package/dist/types/lib/style/index.d.cts +0 -3
  295. package/dist/types/lib/symbols/index.d.cts +0 -1
  296. package/dist/types/lib/symbols/symbols.d.cts +0 -4
  297. package/dist/types/node/dirname.d.cts +0 -9
  298. package/dist/types/node/file-cache.d.cts +0 -56
  299. package/dist/types/node/file.d.cts +0 -4
  300. package/dist/types/node/hash.d.cts +0 -3
  301. package/dist/types/node/index.d.cts +0 -7
  302. package/dist/types/node/pkce.d.cts +0 -8
  303. package/dist/types/node/random-string.d.cts +0 -3
  304. package/dist/types/node/sanitize.d.cts +0 -10
  305. package/dist/types/node/uuid.d.cts +0 -3
@@ -1,36 +0,0 @@
1
- import { getNestedValue } from "../objects/nested-property.js";
2
- function sort(array, { props = null, reverse = false } = {}) {
3
- const clone = array.slice();
4
- if (props === null) {
5
- return clone.sort((a, b) => {
6
- const comparison = compareValues(a, b);
7
- return reverse ? -comparison : comparison;
8
- });
9
- }
10
- const properties = Array.isArray(props) ? props : [props];
11
- return clone.sort((a, b) => {
12
- for (const property of properties) {
13
- const aValue = getNestedValue(a, property);
14
- const bValue = getNestedValue(b, property);
15
- if (aValue === bValue) continue;
16
- if (aValue == null) return 1;
17
- if (bValue == null) return -1;
18
- const comparison = compareValues(aValue, bValue);
19
- return reverse ? -comparison : comparison;
20
- }
21
- return 0;
22
- });
23
- }
24
- function compareValues(a, b) {
25
- if (typeof a === "number" && typeof b === "number") return a - b;
26
- if (typeof a === "string" && typeof b === "string") return a.localeCompare(b);
27
- const aDate = new Date(a);
28
- const bDate = new Date(b);
29
- const aTime = aDate.getTime();
30
- const bTime = bDate.getTime();
31
- if (!isNaN(aTime) && !isNaN(bTime)) return aTime - bTime;
32
- return String(a).localeCompare(String(b));
33
- }
34
- export {
35
- sort
36
- };
@@ -1,16 +0,0 @@
1
- function splitArray(array, predicate) {
2
- const ret = {
3
- picked: [],
4
- omitted: []
5
- };
6
- array.forEach((item, index, arr) => {
7
- if (predicate(item, index, arr)) ret.picked.push(item);
8
- else ret.omitted.push(item);
9
- });
10
- ret.p = ret.picked;
11
- ret.o = ret.omitted;
12
- return ret;
13
- }
14
- export {
15
- splitArray
16
- };
@@ -1,6 +0,0 @@
1
- function uniqueArray(array) {
2
- return Array.from(new Set(array));
3
- }
4
- export {
5
- uniqueArray
6
- };
@@ -1 +0,0 @@
1
- export * from "./route-manager.js";
@@ -1,25 +0,0 @@
1
- function RouteManager(config) {
2
- const { protectedRoutes, bypassRoutes } = config;
3
- return {
4
- isProtectedRoute(pathname) {
5
- return isMatch(protectedRoutes, pathname);
6
- },
7
- isBypassRoute(pathname) {
8
- return isMatch(bypassRoutes, pathname);
9
- }
10
- };
11
- }
12
- function AuthManager(config) {
13
- return RouteManager(config);
14
- }
15
- function isMatch(routeConfig, pathname) {
16
- const { is, startsWith, includes } = routeConfig;
17
- const isExactMatch = is && is.some((u) => pathname === u);
18
- const startsWithMatch = startsWith && startsWith.some((u) => pathname.startsWith(u));
19
- const includesMatch = includes && includes.some((u) => pathname.includes(u));
20
- return isExactMatch || startsWithMatch || includesMatch;
21
- }
22
- export {
23
- AuthManager,
24
- RouteManager
25
- };
@@ -1,34 +0,0 @@
1
- function isObject(x) {
2
- return typeof x === "object" && !Array.isArray(x) && x !== null;
3
- }
4
- function isArray(x) {
5
- return Array.isArray(x);
6
- }
7
- function notObject(x) {
8
- return !isObject(x);
9
- }
10
- function getType(x) {
11
- if (typeof x === "string") return "string";
12
- if (typeof x === "number") {
13
- if (Number.isInteger(x)) return "integer";
14
- return "float";
15
- }
16
- if (typeof x === "boolean") return "boolean";
17
- if (typeof x === "function") return "function";
18
- if (typeof x === "undefined") return "undefined";
19
- if (typeof x === "symbol") return "symbol";
20
- if (typeof x === "bigint") return "bigint";
21
- if (Array.isArray(x)) return "array";
22
- if (typeof x === "object") return "object";
23
- return "unknown";
24
- }
25
- function isFunction(x) {
26
- return typeof x === "function";
27
- }
28
- export {
29
- getType,
30
- isArray,
31
- isFunction,
32
- isObject,
33
- notObject
34
- };
@@ -1,12 +0,0 @@
1
- const DAYS = [
2
- { short: "Sun", long: "Sunday", numeric: 1 },
3
- { short: "Mon", long: "Monday", numeric: 2 },
4
- { short: "Tue", long: "Tuesday", numeric: 3 },
5
- { short: "Wed", long: "Wednesday", numeric: 4 },
6
- { short: "Thu", long: "Thursday", numeric: 5 },
7
- { short: "Fri", long: "Friday", numeric: 6 },
8
- { short: "Sat", long: "Saturday", numeric: 7 }
9
- ];
10
- export {
11
- DAYS
12
- };
@@ -1,3 +0,0 @@
1
- export * from "./days.js";
2
- export * from "./months.js";
3
- export * from "./time.js";
@@ -1,77 +0,0 @@
1
- const MONTHS = [
2
- {
3
- long: "January",
4
- short: "jan",
5
- numeric: 1,
6
- lastDay: { default: 31, leapYear: 31 }
7
- },
8
- {
9
- long: "February",
10
- short: "feb",
11
- numeric: 2,
12
- lastDay: { default: 28, leapYear: 29 }
13
- },
14
- {
15
- long: "March",
16
- short: "mar",
17
- numeric: 3,
18
- lastDay: { default: 31, leapYear: 31 }
19
- },
20
- {
21
- long: "April",
22
- short: "apr",
23
- numeric: 4,
24
- lastDay: { default: 30, leapYear: 30 }
25
- },
26
- {
27
- long: "May",
28
- short: "may",
29
- numeric: 5,
30
- lastDay: { default: 31, leapYear: 31 }
31
- },
32
- {
33
- long: "June",
34
- short: "jun",
35
- numeric: 6,
36
- lastDay: { default: 30, leapYear: 30 }
37
- },
38
- {
39
- long: "July",
40
- short: "jul",
41
- numeric: 7,
42
- lastDay: { default: 31, leapYear: 31 }
43
- },
44
- {
45
- long: "August",
46
- short: "aug",
47
- numeric: 8,
48
- lastDay: { default: 31, leapYear: 31 }
49
- },
50
- {
51
- long: "September",
52
- short: "sep",
53
- numeric: 9,
54
- lastDay: { default: 30, leapYear: 30 }
55
- },
56
- {
57
- long: "October",
58
- short: "oct",
59
- numeric: 10,
60
- lastDay: { default: 31, leapYear: 31 }
61
- },
62
- {
63
- long: "November",
64
- short: "nov",
65
- numeric: 11,
66
- lastDay: { default: 30, leapYear: 30 }
67
- },
68
- {
69
- long: "December",
70
- short: "dec",
71
- numeric: 12,
72
- lastDay: { default: 31, leapYear: 31 }
73
- }
74
- ];
75
- export {
76
- MONTHS
77
- };
@@ -1,75 +0,0 @@
1
- import { splitUnit } from "../numbers/index.js";
2
- function ms(arg) {
3
- const [value, unit] = splitUnit(arg);
4
- if (unit === "d") return getTimeInMs(value, "days");
5
- if (unit === "day") return getTimeInMs(value, "days");
6
- if (unit === "days") return getTimeInMs(value, "days");
7
- if (unit === "h") return getTimeInMs(value, "hours");
8
- if (unit === "hr") return getTimeInMs(value, "hours");
9
- if (unit === "hour") return getTimeInMs(value, "hours");
10
- if (unit === "hours") return getTimeInMs(value, "hours");
11
- if (unit === "m") return getTimeInMs(value, "minutes");
12
- if (unit === "min") return getTimeInMs(value, "minutes");
13
- if (unit === "mins") return getTimeInMs(value, "minutes");
14
- if (unit === "minute") return getTimeInMs(value, "minutes");
15
- if (unit === "minutes") return getTimeInMs(value, "minutes");
16
- if (unit === "s") return getTimeInMs(value, "seconds");
17
- if (unit === "sec") return getTimeInMs(value, "seconds");
18
- if (unit === "secs") return getTimeInMs(value, "seconds");
19
- if (unit === "second") return getTimeInMs(value, "seconds");
20
- if (unit === "seconds") return getTimeInMs(value, "seconds");
21
- return value;
22
- }
23
- function getTimeInMs(value, unit = "ms") {
24
- switch (unit) {
25
- case "ms":
26
- return value;
27
- case "seconds":
28
- return value * 1e3;
29
- case "minutes":
30
- return value * 1e3 * 60;
31
- case "hours":
32
- return value * 1e3 * 60 * 60;
33
- case "days":
34
- return value * 1e3 * 60 * 60 * 24;
35
- case "weeks":
36
- return value * 1e3 * 60 * 60 * 24 * 7;
37
- }
38
- }
39
- function toWeeks(ms2) {
40
- return ms2 / 1e3 / 60 / 60 / 24 / 7;
41
- }
42
- function toDays(ms2) {
43
- return ms2 / 1e3 / 60 / 60 / 24;
44
- }
45
- function toHours(ms2) {
46
- return ms2 / 1e3 / 60 / 60;
47
- }
48
- function toMinutes(ms2) {
49
- return ms2 / 1e3 / 60;
50
- }
51
- function toSeconds(ms2) {
52
- return ms2 / 1e3;
53
- }
54
- function toReadableTime(ms2) {
55
- const weekMs = 1e3 * 60 * 60 * 24 * 7;
56
- const dayMs = 1e3 * 60 * 60 * 24;
57
- const hourMs = 1e3 * 60 * 60;
58
- const minuteMs = 1e3 * 60;
59
- const weeks = Math.floor(ms2 / weekMs);
60
- const days = Math.floor(ms2 % weekMs / dayMs);
61
- const hours = Math.floor(ms2 % dayMs / hourMs);
62
- const minutes = Math.floor(ms2 % hourMs / minuteMs);
63
- const seconds = Math.floor(ms2 % minuteMs / 1e3);
64
- return { weeks, days, hours, minutes, seconds };
65
- }
66
- export {
67
- getTimeInMs,
68
- ms,
69
- toDays,
70
- toHours,
71
- toMinutes,
72
- toReadableTime,
73
- toSeconds,
74
- toWeeks
75
- };
@@ -1,57 +0,0 @@
1
- function formDataToObject(formData) {
2
- const obj = {};
3
- for (let [key, value] of formData) {
4
- if (typeof value === "string") value = value.trim();
5
- if (key.includes("[]")) {
6
- const arrayKey = key.replace("[]", "");
7
- if (!obj[arrayKey]) obj[arrayKey] = [];
8
- obj[arrayKey].push(value);
9
- } else {
10
- obj[key] = value;
11
- }
12
- }
13
- return obj;
14
- }
15
- function flattenArrayFields(inputObject) {
16
- const result = {};
17
- for (const [key, value] of Object.entries(inputObject)) {
18
- const match = key.match(/^(\w+)(?:\[(\d+)\])?(?:\[(\w+)\])?$/);
19
- if (match) {
20
- const [, baseKey, index, property] = match;
21
- if (index !== void 0) {
22
- if (!result[baseKey]) result[baseKey] = [];
23
- const arrayIndex = parseInt(index);
24
- if (!result[baseKey][arrayIndex]) result[baseKey][arrayIndex] = {};
25
- if (property) {
26
- result[baseKey][arrayIndex][property] = value;
27
- } else {
28
- result[baseKey][arrayIndex] = value;
29
- }
30
- } else if (property) {
31
- if (!result[baseKey]) result[baseKey] = {};
32
- result[baseKey][property] = value;
33
- } else {
34
- result[key] = value;
35
- }
36
- } else {
37
- result[key] = value;
38
- }
39
- }
40
- for (const key in result) {
41
- if (typeof result[key] === "object" && result[key] !== null) {
42
- if (Object.keys(result[key]).every((k) => !isNaN(parseInt(k)))) {
43
- result[key] = Object.values(result[key]).filter((item) => {
44
- if (typeof item === "object") {
45
- return Object.values(item).some((v) => v !== "");
46
- }
47
- return item !== "";
48
- });
49
- }
50
- }
51
- }
52
- return result;
53
- }
54
- export {
55
- flattenArrayFields,
56
- formDataToObject
57
- };
@@ -1,2 +0,0 @@
1
- export * from "./form-data.js";
2
- export * from "./sanitize.js";
@@ -1,34 +0,0 @@
1
- function sanitize(value, options = {}) {
2
- const { sanitizer, ...rest } = options;
3
- if (!sanitizer) throw new Error("sanitizer function is required");
4
- if (typeof value === "string") return sanitizer(value, rest);
5
- if (Array.isArray(value)) return sanitizeArray(value, { sanitizer, ...rest });
6
- if (value && typeof value === "object") {
7
- return Object.fromEntries(
8
- Object.entries(value).map(([key, val]) => [
9
- key,
10
- sanitize(val, { sanitizer, ...rest })
11
- ])
12
- );
13
- }
14
- return value;
15
- }
16
- function sanitizeArray(arr, { sanitizer, ...rest }) {
17
- if (!sanitizer) throw new Error("sanitizer function is required");
18
- return arr.map((item) => sanitize(item, { sanitizer, ...rest }));
19
- }
20
- function sanitizeObject(obj, { sanitizer, ...options } = {}) {
21
- if (!sanitizer) throw new Error("sanitizer function is required");
22
- if (Array.isArray(obj)) return sanitizeArray(obj, { sanitizer, ...options });
23
- return Object.fromEntries(
24
- Object.entries(obj).map(([key, value]) => [
25
- key,
26
- sanitize(value, { sanitizer, ...options })
27
- ])
28
- );
29
- }
30
- export {
31
- sanitize,
32
- sanitizeArray,
33
- sanitizeObject
34
- };
@@ -1,6 +0,0 @@
1
- function runCallback(fn, ...data) {
2
- if (typeof fn === "function") fn(data);
3
- }
4
- export {
5
- runCallback
6
- };
@@ -1,18 +0,0 @@
1
- function debounce(callback, wait, immediate = false) {
2
- let timeout;
3
- return function() {
4
- const context = this;
5
- const args = arguments;
6
- const callNow = immediate && !timeout;
7
- clearTimeout(timeout);
8
- timeout = setTimeout(later, wait);
9
- if (callNow) callback.apply(context, args);
10
- function later() {
11
- timeout = null;
12
- if (!immediate) callback.apply(context, args);
13
- }
14
- };
15
- }
16
- export {
17
- debounce
18
- };
@@ -1,7 +0,0 @@
1
- function getEnv() {
2
- if (typeof window === "object") return "browser";
3
- if (typeof global === "object") return "node";
4
- }
5
- export {
6
- getEnv
7
- };
@@ -1,52 +0,0 @@
1
- function curry(fn) {
2
- return function curried(...args) {
3
- if (args.length >= fn.length) {
4
- return fn.apply(this, args);
5
- } else {
6
- return function(...moreArgs) {
7
- return curried.apply(this, args.concat(moreArgs));
8
- };
9
- }
10
- };
11
- }
12
- function compose(...fns) {
13
- return function(value) {
14
- return fns.reduceRight((acc, fn) => fn(acc), value);
15
- };
16
- }
17
- function composeAsync(...fns) {
18
- return async function(value) {
19
- return fns.reduceRight(async (acc, fn) => {
20
- const result = await acc;
21
- return await fn(result);
22
- }, value);
23
- };
24
- }
25
- function pipe(...fns) {
26
- return function(value) {
27
- return fns.reduce((acc, fn) => fn(acc), value);
28
- };
29
- }
30
- function pipeAsync(...fns) {
31
- return async function(value) {
32
- return fns.reduce(async (acc, fn) => {
33
- const result = await acc;
34
- return await fn(result);
35
- }, value);
36
- };
37
- }
38
- function times(fn, n) {
39
- const result = [];
40
- for (let i = 0; i < n; i++) {
41
- result.push(fn(i));
42
- }
43
- return result;
44
- }
45
- export {
46
- compose,
47
- composeAsync,
48
- curry,
49
- pipe,
50
- pipeAsync,
51
- times
52
- };
@@ -1,5 +0,0 @@
1
- export * from "./debounce.js";
2
- export * from "./env.js";
3
- export * from "./functional.js";
4
- export * from "./throttle.js";
5
- export * from "./timeout.js";
@@ -1,13 +0,0 @@
1
- function throttle(callback, wait) {
2
- let lastCall = 0;
3
- return function(...args) {
4
- const now = (/* @__PURE__ */ new Date()).getTime();
5
- if (now - lastCall >= wait) {
6
- callback(...args);
7
- lastCall = now;
8
- }
9
- };
10
- }
11
- export {
12
- throttle
13
- };
@@ -1,14 +0,0 @@
1
- function timeout(wait2, callback) {
2
- setTimeout(callback, wait2);
3
- }
4
- function delay(ms) {
5
- return new Promise((resolve) => setTimeout(resolve, ms));
6
- }
7
- function wait(ms) {
8
- return delay(ms);
9
- }
10
- export {
11
- delay,
12
- timeout,
13
- wait
14
- };
@@ -1,18 +0,0 @@
1
- function isHashedValue(value, type = "sha256") {
2
- if (typeof value !== "string") return null;
3
- value = value.trim();
4
- type = type.toLowerCase();
5
- if (type === "sha256") {
6
- return value.length === 64 && /^[a-fA-F0-9]{64}$/.test(value);
7
- }
8
- if (type === "sha1") {
9
- return value.length === 40 && /^[a-fA-F0-9]{40}$/.test(value);
10
- }
11
- if (type === "md5") {
12
- return value.length === 32 && /^[a-fA-F0-9]{32}$/.test(value);
13
- }
14
- return null;
15
- }
16
- export {
17
- isHashedValue
18
- };
@@ -1,14 +0,0 @@
1
- export * from "./arrays/index.js";
2
- export * from "./auth/index.js";
3
- export * from "./checks.js";
4
- export * from "./date/index.js";
5
- export * from "./form/index.js";
6
- export * from "./functions/index.js";
7
- export * from "./hash.js";
8
- export * from "./numbers/index.js";
9
- export * from "./objects/index.js";
10
- export * from "./promises/index.js";
11
- export * from "./sse.js";
12
- export * from "./strings/index.js";
13
- export * from "./style/index.js";
14
- export * from "./symbols/index.js";
@@ -1,11 +0,0 @@
1
- export * from "./math.js";
2
- function splitUnit(string) {
3
- if (typeof string === "number") return [string, null];
4
- const regex = /(-?\d*\.?\d+)\s*([a-z]+)/i;
5
- const match = string.match(regex);
6
- if (match) return [parseFloat(match[1]), match[2]];
7
- return [parseFloat(string), null];
8
- }
9
- export {
10
- splitUnit
11
- };
@@ -1,10 +0,0 @@
1
- function toDegrees(angle) {
2
- return angle * (180 / Math.PI);
3
- }
4
- function toRadians(angle) {
5
- return angle * (Math.PI / 180);
6
- }
7
- export {
8
- toDegrees,
9
- toRadians
10
- };
@@ -1,16 +0,0 @@
1
- import { objectForEach } from "./loop.js";
2
- import { toCamel } from "../strings/convert-case/convert-case.js";
3
- function camelCaseKeys(obj) {
4
- if (typeof obj !== "object" || obj === null) {
5
- return obj;
6
- }
7
- const result = {};
8
- objectForEach(obj, ({ key, value }) => {
9
- const camelCaseKey = toCamel(key);
10
- result[camelCaseKey] = camelCaseKeys(value);
11
- });
12
- return result;
13
- }
14
- export {
15
- camelCaseKeys
16
- };
@@ -1,13 +0,0 @@
1
- function isEmpty(obj) {
2
- if (typeof obj === "undefined") return true;
3
- if (obj === null) return true;
4
- if (Array.isArray(obj)) return obj.length === 0;
5
- return Object.keys(obj).length === 0;
6
- }
7
- function notEmpty(obj) {
8
- return !isEmpty(obj);
9
- }
10
- export {
11
- isEmpty,
12
- notEmpty
13
- };
@@ -1,11 +0,0 @@
1
- import deepEqual from "deep-eql";
2
- function isEqual(a, b) {
3
- return deepEqual(a, b);
4
- }
5
- function notEqual(a, b) {
6
- return !isEqual(a, b);
7
- }
8
- export {
9
- isEqual,
10
- notEqual
11
- };
@@ -1,13 +0,0 @@
1
- import { objectForEach, objectMap } from "./loop.js";
2
- import { curry } from "../functions/functional.js";
3
- import { mix } from "./mix/mix.js";
4
- function extendObject(object) {
5
- const orig = object;
6
- const extended = mix({}, object);
7
- extended.forEach = curry(objectForEach)(orig);
8
- extended.map = curry(objectMap)(orig);
9
- return { orig, extended };
10
- }
11
- export {
12
- extendObject
13
- };
@@ -1,17 +0,0 @@
1
- import { isObject } from "../checks.js";
2
- function flattenObject(obj, { separator, prefix = "" }) {
3
- return Object.entries(obj).reduce((acc, [key, value]) => {
4
- const newKey = prefix ? `${prefix}${separator}${key}` : key;
5
- const isAnObject = isObject(value);
6
- const hasNestedObject = isAnObject && Object.values(value).some(isObject);
7
- if (hasNestedObject) {
8
- Object.assign(acc, flattenObject(value, { separator, prefix: newKey }));
9
- } else {
10
- acc[newKey] = value;
11
- }
12
- return acc;
13
- }, {});
14
- }
15
- export {
16
- flattenObject
17
- };
@@ -1,13 +0,0 @@
1
- export * from "./camelcase-keys.js";
2
- export * from "./empty.js";
3
- export * from "./equal.js";
4
- export * from "./extend.js";
5
- export * from "./flatten.js";
6
- export * from "./json.js";
7
- export * from "./loop.js";
8
- export * from "./mix/mix.js";
9
- export * from "./nested-property.js";
10
- export * from "./normalize-object.js";
11
- export * from "./omit-empty.js";
12
- export * from "./size.js";
13
- export * from "./split.js";