@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,10 +0,0 @@
1
- function parseJSON(value, defaultValue = {}) {
2
- try {
3
- return JSON.parse(value);
4
- } catch (e) {
5
- return defaultValue;
6
- }
7
- }
8
- export {
9
- parseJSON
10
- };
@@ -1,14 +0,0 @@
1
- function objectForEach(object, callback) {
2
- Object.entries(object).forEach(([key, value]) => {
3
- callback({ key, value });
4
- });
5
- }
6
- function objectMap(object, callback) {
7
- return Object.entries(object).map(([key, value]) => {
8
- return callback({ key, value });
9
- });
10
- }
11
- export {
12
- objectForEach,
13
- objectMap
14
- };
@@ -1,88 +0,0 @@
1
- const DEFAULT_OPTIONS = { array: "replace" };
2
- const mix = createMix();
3
- const concatMix = createMix({ array: "concat" });
4
- function createMix(userOptions = {}) {
5
- const options = { ...DEFAULT_OPTIONS, ...userOptions };
6
- function _mix(...sources) {
7
- const result = {};
8
- for (const source of sources) {
9
- if (source == null) continue;
10
- merge(result, source, options);
11
- }
12
- return result;
13
- }
14
- return _mix;
15
- }
16
- function merge(output, input, options) {
17
- const props = Object.keys(input);
18
- for (const prop of props) {
19
- if (prop === "__proto__") continue;
20
- const descriptor = Object.getOwnPropertyDescriptor(input, prop);
21
- const value = descriptor.value;
22
- if (value) descriptor.value = cloneDescriptorValue(value);
23
- if (!output[prop]) {
24
- Object.defineProperty(output, prop, descriptor);
25
- continue;
26
- }
27
- if (typeof output[prop] !== "object") {
28
- Object.defineProperty(output, prop, descriptor);
29
- continue;
30
- }
31
- if (descriptor.value == null || typeof descriptor.value !== "object") {
32
- Object.defineProperty(output, prop, descriptor);
33
- continue;
34
- }
35
- if (objectType(descriptor.value) === "[object Array]") {
36
- output[prop] = options.array === "replace" ? descriptor.value.slice() : output[prop].concat(descriptor.value);
37
- continue;
38
- }
39
- merge(output[prop], descriptor.value, options);
40
- }
41
- }
42
- function cloneDescriptorValue(value) {
43
- if (objectType(value) === "[object Array]") {
44
- const array = [];
45
- for (let v of value) {
46
- v = cloneDescriptorValue(v);
47
- array.push(v);
48
- }
49
- return array;
50
- }
51
- if (objectType(value) === "[object Object]") {
52
- const obj = {};
53
- const props = Object.keys(value);
54
- for (const prop of props) {
55
- const descriptor = Object.getOwnPropertyDescriptor(value, prop);
56
- if (descriptor.value)
57
- descriptor.value = cloneDescriptorValue(descriptor.value);
58
- Object.defineProperty(obj, prop, descriptor);
59
- }
60
- return obj;
61
- }
62
- if (objectType(value) === "[object Date]") {
63
- return new Date(value.getTime());
64
- }
65
- if (objectType(value) === "[object Map]") {
66
- const map = /* @__PURE__ */ new Map();
67
- for (const entry of value) {
68
- map.set(entry[0], cloneDescriptorValue(entry[1]));
69
- }
70
- return map;
71
- }
72
- if (objectType(value) === "[object Set]") {
73
- const set = /* @__PURE__ */ new Set();
74
- for (const entry of value.entries()) {
75
- set.add(cloneDescriptorValue(entry[0]));
76
- }
77
- return set;
78
- }
79
- return value;
80
- }
81
- function objectType(value) {
82
- return Object.prototype.toString.call(value);
83
- }
84
- export {
85
- concatMix,
86
- createMix,
87
- mix
88
- };
@@ -1,18 +0,0 @@
1
- function getNestedProperty(object, pathArr) {
2
- return pathArr.reduce(
3
- (nestedObject, key) => nestedObject && nestedObject[key] !== "undefined" ? nestedObject[key] : void 0,
4
- object
5
- );
6
- }
7
- function getNestedProperty2(object, path) {
8
- const pathArray = path.split(".");
9
- return getNestedProperty(object, pathArray);
10
- }
11
- function getNestedValue(object, path) {
12
- return path.split(".").reduce((acc, part) => acc?.[part], object);
13
- }
14
- export {
15
- getNestedProperty,
16
- getNestedProperty2,
17
- getNestedValue
18
- };
@@ -1,9 +0,0 @@
1
- import { pipe } from "../functions/functional.js";
2
- import { camelCaseKeys } from "./camelcase-keys.js";
3
- import { omitEmpty } from "./omit-empty.js";
4
- function normalizeObject(object) {
5
- return pipe(omitEmpty, camelCaseKeys)(object);
6
- }
7
- export {
8
- normalizeObject
9
- };
@@ -1,15 +0,0 @@
1
- function omitEmpty(obj, shallow = false) {
2
- if (typeof obj !== "object" || obj === null) return obj;
3
- if (obj instanceof Date) return obj;
4
- const result = Array.isArray(obj) ? [] : {};
5
- for (const [key, value] of Object.entries(obj)) {
6
- if (value === null || value === void 0 || value === "" || typeof value === "object" && !(value instanceof Date) && Object.keys(value).length === 0) {
7
- continue;
8
- }
9
- result[key] = shallow ? value : omitEmpty(value);
10
- }
11
- return result;
12
- }
13
- export {
14
- omitEmpty
15
- };
@@ -1,38 +0,0 @@
1
- function sizeOf(obj) {
2
- let bytes = 0;
3
- function size(obj2) {
4
- if (obj2 !== null && obj2 !== void 0) {
5
- switch (typeof obj2) {
6
- case "number":
7
- bytes += 8;
8
- break;
9
- case "string":
10
- bytes += obj2.length * 2;
11
- break;
12
- case "boolean":
13
- bytes += 4;
14
- break;
15
- case "object":
16
- const objClass = Object.prototype.toString.call(obj2).slice(8, -1);
17
- if (objClass === "Object" || objClass === "Array") {
18
- for (const key in obj2) {
19
- if (!obj2.hasOwnProperty(key)) continue;
20
- size(obj2[key]);
21
- }
22
- } else bytes += obj2.toString().length * 2;
23
- break;
24
- }
25
- }
26
- return bytes;
27
- }
28
- function formatByteSize(bytes2) {
29
- if (bytes2 < 1024) return bytes2 + " bytes";
30
- else if (bytes2 < 1048576) return (bytes2 / 1024).toFixed(3) + " KiB";
31
- else if (bytes2 < 1073741824) return (bytes2 / 1048576).toFixed(3) + " MiB";
32
- else return (bytes2 / 1073741824).toFixed(3) + " GiB";
33
- }
34
- return formatByteSize(size(obj));
35
- }
36
- export {
37
- sizeOf
38
- };
@@ -1,14 +0,0 @@
1
- function splitObject(obj, keys) {
2
- const picked = {};
3
- const omitted = { ...obj };
4
- keys.forEach((key) => {
5
- if (key in obj) {
6
- picked[key] = obj[key];
7
- delete omitted[key];
8
- }
9
- });
10
- return { picked, omitted, p: picked, o: omitted };
11
- }
12
- export {
13
- splitObject
14
- };
@@ -1 +0,0 @@
1
- export * from "./reject.js";
@@ -1,17 +0,0 @@
1
- import statuses from "statuses";
2
- import { omitEmpty } from "../objects/omit-empty.js";
3
- function reject(props, { includeStack = true } = {}) {
4
- const { status, statusText, body, message } = props;
5
- const e = new Error();
6
- const err = {
7
- status,
8
- statusText: statusText || status && statuses(status),
9
- body,
10
- message,
11
- stack: includeStack && e.stack
12
- };
13
- return Promise.reject(omitEmpty(err));
14
- }
15
- export {
16
- reject
17
- };
@@ -1,50 +0,0 @@
1
- import { parseJSON } from "./objects/json.js";
2
- import { omitEmpty } from "./objects/omit-empty.js";
3
- function createSSE({ event, data, id, retry }) {
4
- const eventString = event ? `event: ${event}
5
- ` : "";
6
- const idString = id ? `id: ${id}
7
- ` : "";
8
- const retryString = retry ? `retry: ${retry}
9
- ` : "";
10
- if (typeof data === "object") data = JSON.stringify(data);
11
- const dataString = data ? `data: ${data}
12
- ` : "";
13
- return `${eventString}${dataString}${idString}${retryString}
14
- `;
15
- }
16
- function parseSSE(message) {
17
- const lines = message.split("\n");
18
- const result = {
19
- event: "message",
20
- // Default event type
21
- data: "",
22
- id: null,
23
- retry: null
24
- };
25
- for (const line of lines) {
26
- if (line.startsWith("data:")) {
27
- const data = line.slice(5).trim();
28
- result.data = parseJSON(data);
29
- continue;
30
- }
31
- if (line.startsWith("event:")) {
32
- result.event = line.slice(6).trim();
33
- continue;
34
- }
35
- if (line.startsWith("id:")) {
36
- result.id = line.slice(3).trim();
37
- continue;
38
- }
39
- if (line.startsWith("retry:")) {
40
- result.retry = parseInt(line.slice(6).trim(), 10);
41
- continue;
42
- }
43
- }
44
- const ret = omitEmpty(result);
45
- return ret.data ? ret : null;
46
- }
47
- export {
48
- createSSE,
49
- parseSSE
50
- };
@@ -1,64 +0,0 @@
1
- function toKebab(string) {
2
- if (!string) return "";
3
- return string.split("").map((letter, index) => {
4
- const previousLetter = string[index - 1] || "";
5
- const currentLetter = letter;
6
- if (isDigit(currentLetter) && !isDigit(previousLetter)) {
7
- return `-${currentLetter}`;
8
- }
9
- if (!isCaps(currentLetter)) return currentLetter;
10
- if (previousLetter === "") {
11
- return `${currentLetter.toLowerCase()}`;
12
- }
13
- if (isCaps(previousLetter)) {
14
- return `${currentLetter.toLowerCase()}`;
15
- }
16
- return `-${currentLetter.toLowerCase()}`;
17
- }).join("").trim().replace(/[-_\s]+/g, "-");
18
- }
19
- function toCamel(string) {
20
- return toKebab(string).split("-").map((word, index) => {
21
- if (index === 0) return word;
22
- return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase();
23
- }).join("");
24
- }
25
- function toPascal(string) {
26
- const camel = toCamel(string);
27
- return camel.slice(0, 1).toUpperCase() + camel.slice(1);
28
- }
29
- function toTitle(string) {
30
- return toKebab(string).split("-").map((word) => {
31
- return word.slice(0, 1).toUpperCase() + word.slice(1);
32
- }).join(" ");
33
- }
34
- function toSlug(string) {
35
- return toKebab(string);
36
- }
37
- function toSentence(string) {
38
- const interim = toKebab(string).replace(/-/g, " ");
39
- return interim.slice(0, 1).toUpperCase() + interim.slice(1);
40
- }
41
- function toUpper(string) {
42
- const interim = toKebab(string).replace(/-/g, " ");
43
- return interim.toUpperCase();
44
- }
45
- function toLower(string) {
46
- const interim = toKebab(string).replace(/-/g, " ");
47
- return interim.toLowerCase();
48
- }
49
- function isCaps(char) {
50
- return /\p{Lu}/u.test(char);
51
- }
52
- function isDigit(char) {
53
- return /[0-9]/.test(char);
54
- }
55
- export {
56
- toCamel,
57
- toKebab,
58
- toLower,
59
- toPascal,
60
- toSentence,
61
- toSlug,
62
- toTitle,
63
- toUpper
64
- };
@@ -1,5 +0,0 @@
1
- export * from "./convert-case/convert-case.js";
2
- export * from "./markdown.js";
3
- export * from "./name.js";
4
- export * from "./pluralize.js";
5
- export * from "./query-string.js";
@@ -1,40 +0,0 @@
1
- import markdownit from "markdown-it";
2
- import anchor from "markdown-it-anchor";
3
- const md = markdownit({
4
- html: true,
5
- linkify: true,
6
- typographer: true
7
- });
8
- md.use(anchor, {
9
- permalink: false,
10
- slugify: (s) => s.toLowerCase().replace(/\s+/g, "-").replace(/[^\w-]/g, "")
11
- });
12
- function markdown(content, options = {}) {
13
- const defaultOptions = { inline: false };
14
- const opts = { ...defaultOptions, ...options };
15
- const { content: treated } = treatMarkdownWhitespace(content, opts);
16
- if (opts.inline) return md.renderInline(treated);
17
- return md.render(treated);
18
- }
19
- function treatMarkdownWhitespace(content, { inline } = {}) {
20
- if (!content) return { content: "", inline };
21
- const lines = content.split("\n");
22
- if (lines[0] !== "" && inline) return { content, inline: true };
23
- const firstLineWithLeadingSpacesIndex = lines.findIndex(
24
- (line) => line.match(/^\s+/)
25
- );
26
- const firstLineWithLeadingSpaces = lines[firstLineWithLeadingSpacesIndex];
27
- const indentation = firstLineWithLeadingSpaces?.match(/^\s+/)?.[0]?.length ?? 0;
28
- const retContent = lines.map((line, index) => {
29
- if (index < firstLineWithLeadingSpacesIndex) return line + "\n";
30
- return line.slice(indentation) + "\n";
31
- }).join("");
32
- return {
33
- content: retContent,
34
- inline
35
- };
36
- }
37
- export {
38
- markdown,
39
- treatMarkdownWhitespace
40
- };
@@ -1,21 +0,0 @@
1
- function parseFullName(name) {
2
- const parts = name.trim().split(/\s+/);
3
- if (parts.length === 1) {
4
- return { firstName: parts[0], middleName: "", lastName: "" };
5
- }
6
- if (parts.length === 2) {
7
- return { firstName: parts[0], middleName: "", lastName: parts[1] };
8
- }
9
- if (parts.length === 3) {
10
- const firstName2 = parts.slice(0, 2).join(" ");
11
- const lastName2 = parts[2];
12
- return { firstName: firstName2, middleName: "", lastName: lastName2 };
13
- }
14
- const firstName = parts.slice(0, 2).join(" ");
15
- const lastName = parts[parts.length - 1];
16
- const middleName = parts.slice(2, -1).join(" ");
17
- return { firstName, middleName, lastName };
18
- }
19
- export {
20
- parseFullName
21
- };
@@ -1,5 +0,0 @@
1
- import pluralizeLib from "pluralize";
2
- const pluralize = pluralizeLib;
3
- export {
4
- pluralize
5
- };
@@ -1,16 +0,0 @@
1
- function toQueryString(object) {
2
- const searchParams = new URLSearchParams(object);
3
- return searchParams.toString();
4
- }
5
- function plural(count, noun, suffix = "s") {
6
- console.warn("plural is deprecated. Use pluralize instead");
7
- return `${count} ${noun}${count !== 1 ? suffix : ""}`;
8
- }
9
- function stripNumbers(string) {
10
- return string.replace(/\d*/, "");
11
- }
12
- export {
13
- plural,
14
- stripNumbers,
15
- toQueryString
16
- };
@@ -1,12 +0,0 @@
1
- import { toKebab } from "../strings/convert-case/convert-case.js";
2
- function toStyleString(style) {
3
- if (!style) return null;
4
- if (typeof style === "string") return style;
5
- return Object.entries(style).map(([k, v]) => {
6
- if (k.startsWith("--")) return `${k}:${v}`;
7
- else return `${toKebab(k)}:${v}`;
8
- }).join("; ").concat(";");
9
- }
10
- export {
11
- toStyleString
12
- };
@@ -1 +0,0 @@
1
- export * from "./symbols.js";
@@ -1,12 +0,0 @@
1
- function getSymbol(object, description) {
2
- return Object.getOwnPropertySymbols(object).find(
3
- (s) => s.description === description
4
- );
5
- }
6
- function getSymbolValue(object, description) {
7
- return object[getSymbol(object, description)];
8
- }
9
- export {
10
- getSymbol,
11
- getSymbolValue
12
- };
@@ -1,13 +0,0 @@
1
- import path from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- function __dirname(url) {
4
- if (!url) throw Error("Please provide 'import.meta.url' to dirname");
5
- return path.dirname(fileURLToPath(url));
6
- }
7
- function dirname(url) {
8
- return __dirname(url);
9
- }
10
- export {
11
- __dirname,
12
- dirname
13
- };
@@ -1,121 +0,0 @@
1
- import fs from "fs/promises";
2
- import { glob } from "glob";
3
- import path from "node:path";
4
- import { sort } from "../lib/arrays/index.js";
5
- function resolveDirPath(dirPath) {
6
- return path.isAbsolute(dirPath) ? dirPath : path.join(process.cwd(), dirPath);
7
- }
8
- async function createCache(dir) {
9
- const absDirpath = resolveDirPath(dir);
10
- await fs.mkdir(absDirpath, { recursive: true });
11
- return {
12
- async cacheAt(file) {
13
- if (file) {
14
- const absFilepath = path.join(absDirpath, file);
15
- try {
16
- const stat = await fs.stat(absFilepath);
17
- return stat.mtimeMs;
18
- } catch (error) {
19
- return 0;
20
- }
21
- } else {
22
- return getLastModifiedTime(absDirpath + "/**/*");
23
- }
24
- },
25
- getAbsPath(file) {
26
- return path.join(absDirpath, file);
27
- },
28
- async hasFile(file) {
29
- const absFilepath = path.join(absDirpath, file);
30
- try {
31
- await fs.stat(absFilepath);
32
- return true;
33
- } catch (e) {
34
- return false;
35
- }
36
- },
37
- async loadFile(file) {
38
- try {
39
- const absFilepath = path.join(absDirpath, file);
40
- return fs.readFile(absFilepath);
41
- } catch (error) {
42
- console.warn(`File not found: ${file}`);
43
- }
44
- },
45
- async saveFile(file, data) {
46
- const absfilepath = path.join(absDirpath, file);
47
- await fs.writeFile(absfilepath, data);
48
- },
49
- async loadJSON(file) {
50
- const data = await this.loadFile(file);
51
- try {
52
- return JSON.parse(data.toString());
53
- } catch (err) {
54
- console.warn(`Error parsing JSON: ${file}`);
55
- return {};
56
- }
57
- },
58
- async saveJSON(file, data) {
59
- await this.saveFile(file, JSON.stringify(data));
60
- }
61
- };
62
- }
63
- async function fileCache({ dir, file }) {
64
- const absDirpath = resolveDirPath(dir);
65
- await fs.mkdir(absDirpath, { recursive: true });
66
- const cachePath = path.join(absDirpath, `${file}`);
67
- let modifiedAt = 0;
68
- try {
69
- const stat = await fs.stat(cachePath);
70
- modifiedAt = stat.mtimeMs;
71
- } catch (error) {
72
- }
73
- return {
74
- modifiedAt,
75
- async load() {
76
- return fs.readFile(cachePath);
77
- },
78
- async save(data) {
79
- await fs.writeFile(cachePath, data);
80
- },
81
- async loadJSON() {
82
- const data = await fs.readFile(cachePath);
83
- return JSON.parse(data.toString());
84
- },
85
- async saveJSON(data) {
86
- await fs.writeFile(cachePath, JSON.stringify(data));
87
- }
88
- };
89
- }
90
- async function getLastModifiedTime(globPath) {
91
- let files;
92
- if (typeof globPath === "string") {
93
- files = await glob(removeFirstSlash(globPath));
94
- }
95
- if (Array.isArray(globPath)) {
96
- const a = await Promise.all(
97
- globPath.map((path2) => glob(removeFirstSlash(path2)))
98
- );
99
- files = a.flat();
100
- }
101
- const stats = await Promise.all(files.map((file) => fs.stat(file)));
102
- const timestamps = stats.map((stat) => Number(stat.mtimeMs));
103
- const sorted = sort(timestamps, { props: "mtimeMs", reverse: true });
104
- return sorted[0] || 0;
105
- }
106
- async function getLatestModifiedTime(globPath) {
107
- console.warn(
108
- "`getLatestModifiedTime` has been renamed to `getLastModifiedTime` and will be deprecated in future versions. Please use `getLastModifiedTime` instead."
109
- );
110
- return getLastModifiedTime(globPath);
111
- }
112
- function removeFirstSlash(x) {
113
- return x.startsWith("/") ? x.slice(1) : x;
114
- }
115
- export {
116
- createCache,
117
- fileCache,
118
- getLastModifiedTime,
119
- getLatestModifiedTime,
120
- removeFirstSlash
121
- };
@@ -1,14 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- async function mkdir(path2) {
4
- return fs.mkdir(path2, { recursive: true });
5
- }
6
- async function copyFile(from, to) {
7
- const dir = path.dirname(to);
8
- await mkdir(dir);
9
- await fs.copyFile(from, to);
10
- }
11
- export {
12
- copyFile,
13
- mkdir
14
- };
@@ -1,7 +0,0 @@
1
- import crypto from "node:crypto";
2
- function sha256Hash(string) {
3
- return crypto.createHash("sha256").update(string).digest("hex");
4
- }
5
- export {
6
- sha256Hash
7
- };
@@ -1,7 +0,0 @@
1
- export * from "./dirname.js";
2
- export * from "./file-cache.js";
3
- export * from "./hash.js";
4
- export * from "./pkce.js";
5
- export * from "./random-string.js";
6
- export * from "./sanitize.js";
7
- export * from "./uuid.js";
@@ -1,19 +0,0 @@
1
- import crypto from "node:crypto";
2
- import { randomString } from "./random-string.js";
3
- async function PKCE() {
4
- const codeVerifier = await randomString();
5
- const codeChallenge = await getCodeChallenge(codeVerifier);
6
- return {
7
- state: await randomString(),
8
- code_verifier: codeVerifier,
9
- code_challenge: codeChallenge,
10
- code_challenge_method: "S256"
11
- };
12
- }
13
- async function getCodeChallenge(verifier) {
14
- const hash = crypto.createHash("sha256").update(verifier).digest();
15
- return hash.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
16
- }
17
- export {
18
- PKCE
19
- };
@@ -1,8 +0,0 @@
1
- import crypto from "node:crypto";
2
- function randomString(length = 32) {
3
- const bytesNeeded = Math.ceil(length * 3 / 4) + 3;
4
- return crypto.randomBytes(bytesNeeded).toString("base64").slice(0, length);
5
- }
6
- export {
7
- randomString
8
- };