@splendidlabz/utils 1.5.0 → 1.5.1

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 (156) hide show
  1. package/CHANGELOG.md +71 -1
  2. package/dist/dom/accessibility.d.ts +28 -0
  3. package/dist/dom/actions/index.d.ts +3 -0
  4. package/dist/dom/actions/masonry.d.ts +3 -0
  5. package/dist/dom/actions/prefer-horizontal-scroll.d.ts +3 -0
  6. package/dist/dom/actions/sticky.d.ts +3 -0
  7. package/dist/dom/bounding-box.d.ts +39 -0
  8. package/dist/dom/clipboard.d.ts +5 -0
  9. package/dist/dom/cookie.d.ts +11 -0
  10. package/dist/dom/css-vars.d.ts +4 -0
  11. package/dist/dom/events.d.ts +18 -0
  12. package/dist/dom/focusable.d.ts +76 -0
  13. package/dist/dom/font-size.d.ts +5 -0
  14. package/dist/dom/get-element.d.ts +100 -0
  15. package/dist/dom/hash.d.ts +1 -0
  16. package/dist/dom/index.d.ts +22 -0
  17. package/dist/dom/keyboard.d.ts +30 -0
  18. package/dist/dom/local-store.d.ts +29 -0
  19. package/dist/dom/media.d.ts +3 -0
  20. package/dist/dom/observers/index.d.ts +3 -0
  21. package/dist/dom/observers/intersection-observer.d.ts +8 -0
  22. package/dist/dom/observers/mutation-observer.d.ts +7 -0
  23. package/dist/dom/observers/observer.d.ts +1 -0
  24. package/dist/dom/observers/resize-observer.d.ts +38 -0
  25. package/dist/dom/pkce.d.ts +6 -0
  26. package/dist/dom/query-params.d.ts +4 -0
  27. package/dist/dom/random-string.d.ts +7 -0
  28. package/dist/dom/sanitize.d.ts +8 -0
  29. package/dist/dom/session-store.d.ts +5 -0
  30. package/dist/dom/trap-focus.d.ts +28 -0
  31. package/dist/dom/ui/aria-current.d.ts +5 -0
  32. package/dist/dom/ui/inconsistent-button-fix.d.ts +12 -0
  33. package/dist/dom/ui/index.d.ts +4 -0
  34. package/dist/dom/ui/scroll-container.d.ts +1 -0
  35. package/dist/dom/ui/traverse-and-scramble.d.ts +19 -0
  36. package/dist/lib/arrays/index.d.ts +5 -0
  37. package/dist/lib/arrays/item-position.d.ts +14 -0
  38. package/dist/lib/arrays/join.d.ts +13 -0
  39. package/dist/lib/arrays/shuffle.d.ts +1 -0
  40. package/dist/lib/arrays/sort.d.ts +30 -0
  41. package/dist/lib/arrays/unique.d.ts +1 -0
  42. package/dist/lib/auth/index.d.ts +1 -0
  43. package/dist/lib/auth/route-manager.d.ts +25 -0
  44. package/dist/lib/checks.d.ts +29 -0
  45. package/dist/lib/date/days.d.ts +5 -0
  46. package/dist/lib/date/index.d.ts +3 -0
  47. package/dist/lib/date/months.d.ts +9 -0
  48. package/dist/lib/date/time.d.ts +8 -0
  49. package/dist/lib/form/form-data.d.ts +7 -0
  50. package/dist/lib/form/index.d.ts +2 -0
  51. package/dist/lib/form/sanitize.d.ts +58 -0
  52. package/dist/lib/functions/debounce.d.ts +1 -0
  53. package/dist/lib/functions/env.d.ts +1 -0
  54. package/dist/lib/functions/functional.d.ts +4 -0
  55. package/dist/lib/functions/index.d.ts +5 -0
  56. package/dist/lib/functions/throttle.d.ts +1 -0
  57. package/dist/lib/functions/timeout.d.ts +3 -0
  58. package/dist/lib/index.d.ts +13 -0
  59. package/dist/lib/numbers/index.d.ts +2 -0
  60. package/dist/lib/numbers/math.d.ts +2 -0
  61. package/dist/lib/objects/camelcase-keys.d.ts +1 -0
  62. package/dist/lib/objects/empty.d.ts +2 -0
  63. package/dist/lib/objects/equal.d.ts +2 -0
  64. package/dist/lib/objects/extend.d.ts +4 -0
  65. package/dist/lib/objects/flatten.d.ts +4 -0
  66. package/dist/lib/objects/index.d.ts +13 -0
  67. package/dist/lib/objects/json.d.ts +1 -0
  68. package/dist/lib/objects/loop.d.ts +2 -0
  69. package/dist/lib/objects/mix/mix.d.ts +1 -0
  70. package/dist/lib/objects/nested-property.d.ts +22 -0
  71. package/dist/lib/objects/normalize-object.d.ts +1 -0
  72. package/dist/lib/objects/omit-empty.d.ts +1 -0
  73. package/dist/lib/objects/size.d.ts +1 -0
  74. package/dist/lib/objects/split.d.ts +10 -0
  75. package/dist/lib/promises/index.d.ts +1 -0
  76. package/dist/lib/promises/reject.d.ts +3 -0
  77. package/dist/lib/sse.d.ts +16 -0
  78. package/dist/lib/strings/convert-case/convert-case.d.ts +8 -0
  79. package/dist/lib/strings/index.d.ts +4 -0
  80. package/dist/lib/strings/markdown.d.ts +23 -0
  81. package/dist/lib/strings/pluralize.d.ts +1 -0
  82. package/dist/lib/strings/query-string.d.ts +8 -0
  83. package/dist/lib/style/index.d.ts +1 -0
  84. package/dist/lib/symbols/index.d.ts +1 -0
  85. package/dist/lib/symbols/symbols.d.ts +2 -0
  86. package/dist/node/common.d.ts +1 -0
  87. package/dist/node/dirname.d.ts +7 -0
  88. package/dist/node/file-cache.d.ts +54 -0
  89. package/dist/node/file.d.ts +2 -0
  90. package/dist/node/hash.d.ts +1 -0
  91. package/dist/node/index.d.ts +7 -0
  92. package/dist/node/pkce.d.ts +6 -0
  93. package/dist/node/random-string.d.ts +2 -0
  94. package/dist/node/sanitize.d.ts +8 -0
  95. package/dom/accessibility.js +46 -13
  96. package/{actions → dom/actions}/index.js +0 -2
  97. package/dom/actions/masonry.js +42 -0
  98. package/{actions → dom/actions}/prefer-horizontal-scroll.js +8 -8
  99. package/{actions → dom/actions}/sticky.js +3 -6
  100. package/dom/bounding-box.js +35 -7
  101. package/dom/css-vars.js +8 -0
  102. package/dom/events.js +2 -1
  103. package/dom/focusable.js +119 -10
  104. package/dom/font-size.js +21 -10
  105. package/dom/get-element.js +112 -5
  106. package/dom/index.js +3 -0
  107. package/dom/keyboard.js +13 -8
  108. package/dom/local-store.js +37 -0
  109. package/dom/media.js +1 -0
  110. package/dom/observers/index.js +3 -0
  111. package/dom/observers/intersection-observer.js +43 -0
  112. package/dom/observers/mutation-observer.js +51 -0
  113. package/dom/observers/observer.js +18 -0
  114. package/dom/observers/resize-observer.js +64 -0
  115. package/dom/sanitize.js +16 -0
  116. package/dom/trap-focus.js +18 -3
  117. package/dom/ui/inconsistent-button-fix.js +14 -2
  118. package/dom/ui/traverse-and-scramble.js +29 -8
  119. package/eslint.config.js +2 -0
  120. package/lib/arrays/index.js +5 -62
  121. package/lib/arrays/item-position.js +23 -0
  122. package/lib/arrays/join.js +20 -0
  123. package/lib/arrays/shuffle.js +21 -0
  124. package/lib/arrays/sort.js +88 -0
  125. package/lib/arrays/sort.spec.js +123 -0
  126. package/lib/arrays/unique.js +3 -0
  127. package/lib/checks.js +26 -0
  128. package/lib/date/index.js +2 -1
  129. package/lib/date/time.js +50 -0
  130. package/lib/form/sanitize.js +68 -35
  131. package/lib/form/sanitize.spec.js +126 -0
  132. package/lib/index.js +1 -0
  133. package/lib/numbers/index.js +2 -0
  134. package/lib/numbers/math.js +9 -0
  135. package/lib/objects/equal.js +9 -0
  136. package/lib/objects/index.js +1 -0
  137. package/lib/objects/mix/mix.js +2 -0
  138. package/lib/objects/mix/mix.test.js +16 -0
  139. package/lib/objects/nested-property.js +5 -0
  140. package/lib/sse.js +61 -0
  141. package/lib/strings/markdown.js +29 -10
  142. package/node/dirname.js +1 -1
  143. package/node/file-cache.js +46 -7
  144. package/node/index.js +1 -0
  145. package/node/sanitize.js +13 -0
  146. package/node/sanitize.spec.js +142 -0
  147. package/package.json +38 -13
  148. package/tsconfig.json +23 -0
  149. package/.eslintrc.cjs +0 -3
  150. package/.turbo/turbo-lint.log +0 -10
  151. package/.turbo/turbo-test.log +0 -10
  152. package/actions/intersection-observer.js +0 -37
  153. package/actions/masonry.js +0 -75
  154. package/actions/mutation-observer.js +0 -42
  155. package/actions/resize-observer.js +0 -33
  156. package/lib/index.test.js +0 -9
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Traverses a DOM node and scrambles its text content, excluding specified elements.
3
+ * Useful for creating placeholder/loading states or privacy features.
4
+ *
5
+ * @param {Element|ChildNode} node - The root element or node to start traversal from
6
+ * @param {Object} [options] - Options for traversal
7
+ * @param {string[]} [options.excludes=[]] - Array of CSS selectors to exclude from scrambling
8
+ * @example
9
+ * // Scramble all text in a container
10
+ * traverseAndScramble(document.querySelector('.container'))
11
+ *
12
+ * // Scramble text but exclude certain elements
13
+ * traverseAndScramble(document.body, {
14
+ * excludes: ['.no-scramble', '[data-no-scramble]']
15
+ * })
16
+ */
17
+ export function traverseAndScramble(node: Element | ChildNode, { excludes }?: {
18
+ excludes?: string[];
19
+ }): void;
@@ -0,0 +1,5 @@
1
+ export * from "./item-position.js";
2
+ export * from "./join.js";
3
+ export * from "./shuffle.js";
4
+ export * from "./sort.js";
5
+ export * from "./unique.js";
@@ -0,0 +1,14 @@
1
+ export function last(array: any, index: any): boolean;
2
+ /**
3
+ * Checks if the given index is the last item in the array
4
+ * @param {Array} array - The array to check
5
+ * @param {number} index - The index to check
6
+ * @returns {boolean} True if the index is the last item, false otherwise
7
+ */
8
+ export function isLastItem(array: any[], index: number): boolean;
9
+ /**
10
+ * Returns the last item in the array
11
+ * @param {Array} array - The array to get the last item from
12
+ * @returns {*} The last item in the array
13
+ */
14
+ export function lastArrayItem(array: any[]): any;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Joins an array with a conjunction (and/or)
3
+ * @param {Array<string>} array - Array of strings to join
4
+ * @param {Object} [options] - Options for joining
5
+ * @param {string} [options.conjunction='and'] - Conjunction to use ('and' or 'or')
6
+ * @returns {string} Joined string
7
+ * @example
8
+ * joinWithConjunction(['a', 'b', 'c']) // 'a, b, and c'
9
+ * joinWithConjunction(['a', 'b'], { conjunction: 'or' }) // 'a or b'
10
+ */
11
+ export function joinWithConjunction(array: Array<string>, { conjunction }?: {
12
+ conjunction?: string;
13
+ }): string;
@@ -0,0 +1 @@
1
+ export function shuffle(array: any): any;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Sorts an array of objects, numbers, or strings without mutating the original array.
3
+ * Supports nested properties, multiple sort keys, and various data types.
4
+ *
5
+ * @template T
6
+ * @param {T[]} array - Array to sort
7
+ * @param {Object} [options] - Sort options
8
+ * @param {string|string[]|null} [options.props=null] - Property or array of properties to sort by. If null, sorts simple arrays
9
+ * @param {boolean} [options.reverse=false] - Whether to sort in reverse order
10
+ * @returns {T[]} New sorted array
11
+ * @example
12
+ * // Sort simple array
13
+ * sort([3, 1, 2]) // [1, 2, 3]
14
+ *
15
+ * // Sort objects by single property
16
+ * sort(users, { props: 'name' })
17
+ *
18
+ * // Sort objects by multiple properties
19
+ * sort(users, { props: ['age', 'name'] })
20
+ *
21
+ * // Sort in reverse order
22
+ * sort(users, { props: 'age', reverse: true })
23
+ *
24
+ * // Sort by nested property
25
+ * sort(users, { props: 'address.city' })
26
+ */
27
+ export function sort<T>(array: T[], { props, reverse }?: {
28
+ props?: string | string[] | null;
29
+ reverse?: boolean;
30
+ }): T[];
@@ -0,0 +1 @@
1
+ export function uniqueArray(array: any): any[];
@@ -0,0 +1 @@
1
+ export * from "./route-manager.js";
@@ -0,0 +1,25 @@
1
+ /**
2
+ // Usage ... Probably should use either protected or bypass, not both.
3
+ @example
4
+ const config = {
5
+ routeConfig: {
6
+ startsWith: ['/dashboard']
7
+ }
8
+ bypassRoutes: {
9
+ is: ['/'],
10
+ startsWith: ['/fonts', '/auth', '/favicon', '/images'],
11
+ includes: ['/meh'],
12
+ }
13
+ }
14
+ const {isProtectedRoute, isBypassRoute} = AuthManager(config)
15
+ if (!isProtectedRoute(context.url.pathname)) return next() // Handle only protected routes
16
+ if (isBypassRoute(context.url.pathname)) return next() // Bypass all non protected routes
17
+ */
18
+ export function RouteManager(config: any): {
19
+ isProtectedRoute(pathname: any): any;
20
+ isBypassRoute(pathname: any): any;
21
+ };
22
+ export function AuthManager(config: any): {
23
+ isProtectedRoute(pathname: any): any;
24
+ isBypassRoute(pathname: any): any;
25
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Checks if a value is a plain object (not an array or null)
3
+ * @param {unknown} x - The value to check
4
+ * @returns {boolean} True if the value is a plain object
5
+ * @example
6
+ * isObject({}) // true
7
+ * isObject([]) // false
8
+ * isObject(null) // false
9
+ */
10
+ export function isObject(x: unknown): boolean;
11
+ /**
12
+ * Checks if a value is an array
13
+ * @param {unknown} x - The value to check
14
+ * @returns {boolean} True if the value is an array
15
+ * @example
16
+ * isArray([]) // true
17
+ * isArray({}) // false
18
+ */
19
+ export function isArray(x: unknown): boolean;
20
+ /**
21
+ * Checks if a value is not a plain object
22
+ * @param {unknown} x - The value to check
23
+ * @returns {boolean} True if the value is not a plain object
24
+ * @example
25
+ * notObject([]) // true
26
+ * notObject(null) // true
27
+ * notObject({}) // false
28
+ */
29
+ export function notObject(x: unknown): boolean;
@@ -0,0 +1,5 @@
1
+ export const DAYS: {
2
+ short: string;
3
+ long: string;
4
+ numeric: number;
5
+ }[];
@@ -0,0 +1,3 @@
1
+ export * from "./days.js";
2
+ export * from "./months.js";
3
+ export * from "./time.js";
@@ -0,0 +1,9 @@
1
+ export const MONTHS: {
2
+ long: string;
3
+ short: string;
4
+ numeric: number;
5
+ lastDay: {
6
+ default: number;
7
+ leapYear: number;
8
+ };
9
+ }[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Convert a time string to milliseconds
3
+ * @param {string} arg - The time string to convert
4
+ * @returns {number}
5
+ */
6
+ export function ms(arg: string): number;
7
+ export function seconds(arg: any): number;
8
+ export function getTimeInMs(value: any, unit?: string): any;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts Form Data into an object
3
+ * @param {FormData} formData
4
+ * @returns Object
5
+ */
6
+ export function formDataToObject(formData: FormData): {};
7
+ export function flattenArrayFields(inputObject: any): {};
@@ -0,0 +1,2 @@
1
+ export * from "./form-data.js";
2
+ export * from "./sanitize.js";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @typedef {Object} SanitizeOptions
3
+ * @property {Function} [sanitizer] - Function to sanitize strings
4
+ * @property {*} [additional] - Any additional properties are passed through to the sanitizer function
5
+ */
6
+ /**
7
+ * Core sanitization function that handles different value types.
8
+ * Throws if no sanitizer function is provided.
9
+ * Any additional properties in options are passed through to the sanitizer function.
10
+ *
11
+ * @param {*} value - The value to sanitize
12
+ * @param {SanitizeOptions} [options={}] - Sanitization options
13
+ * @throws {Error} If sanitizer function is not provided
14
+ * @returns {*} Sanitized value
15
+ * @example
16
+ * // Basic sanitization
17
+ * sanitize('hello', { sanitizer: str => str.trim() })
18
+ *
19
+ * // With additional options passed to sanitizer
20
+ * sanitize('hello', {
21
+ * sanitizer: (str, length, char) => str.padEnd(length, char),
22
+ * length: 10,
23
+ * char: '-'
24
+ * })
25
+ */
26
+ export function sanitize(value: any, options?: SanitizeOptions): any;
27
+ export type SanitizeOptions = {
28
+ /**
29
+ * - Function to sanitize strings
30
+ */
31
+ sanitizer?: Function;
32
+ /**
33
+ * - Any additional properties are passed through to the sanitizer function
34
+ */
35
+ additional?: any;
36
+ };
37
+ /**
38
+ * Sanitizes an array by recursively sanitizing each element.
39
+ * Throws if no sanitizer function is provided.
40
+ * Any additional properties in options are passed through to the sanitizer function.
41
+ *
42
+ * @param {Array} arr - Array to sanitize
43
+ * @param {SanitizeOptions} options - Sanitization options
44
+ * @throws {Error} If sanitizer function is not provided
45
+ * @returns {Array} New array with sanitized values
46
+ */
47
+ export function sanitizeArray(arr: any[], { sanitizer, ...rest }: SanitizeOptions): any[];
48
+ /**
49
+ * Sanitizes all string values in an object recursively.
50
+ * Throws if no sanitizer function is not provided.
51
+ * Any additional properties in options are passed through to the sanitizer function.
52
+ *
53
+ * @param {Object} obj - Object to sanitize
54
+ * @param {SanitizeOptions} [options={}] - Sanitization options
55
+ * @throws {Error} If sanitizer function is not provided
56
+ * @returns {Object} New object with sanitized values
57
+ */
58
+ export function sanitizeObject(obj: any, { sanitizer, ...options }?: SanitizeOptions): any;
@@ -0,0 +1 @@
1
+ export function debounce(callback: any, wait: any, immediate?: boolean): () => void;
@@ -0,0 +1 @@
1
+ export function getEnv(): "browser" | "node";
@@ -0,0 +1,4 @@
1
+ export function curry(fn: any): (...args: any[]) => any;
2
+ export function compose(...fns: any[]): (value: any) => any;
3
+ export function pipe(...fns: any[]): (value: any) => any;
4
+ export function times(fn: any, n: any): any[];
@@ -0,0 +1,5 @@
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";
@@ -0,0 +1 @@
1
+ export function throttle(callback: any, wait: any): (...args: any[]) => void;
@@ -0,0 +1,3 @@
1
+ export function timeout(wait: any, callback: any): void;
2
+ export function delay(ms: any): Promise<any>;
3
+ export function wait(ms: any): Promise<any>;
@@ -0,0 +1,13 @@
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 "./numbers/index.js";
8
+ export * from "./objects/index.js";
9
+ export * from "./promises/index.js";
10
+ export * from "./sse.js";
11
+ export * from "./strings/index.js";
12
+ export * from "./style/index.js";
13
+ export * from "./symbols/index.js";
@@ -0,0 +1,2 @@
1
+ export function splitUnit(string: any): any[];
2
+ export * from "./math.js";
@@ -0,0 +1,2 @@
1
+ export function toDegrees(angle: any): number;
2
+ export function toRadians(angle: any): number;
@@ -0,0 +1 @@
1
+ export function camelCaseKeys(obj: any): any;
@@ -0,0 +1,2 @@
1
+ export function isEmpty(obj: any): boolean;
2
+ export function notEmpty(obj: any): boolean;
@@ -0,0 +1,2 @@
1
+ export function isEqual(a: any, b: any): any;
2
+ export function notEqual(a: any, b: any): boolean;
@@ -0,0 +1,4 @@
1
+ export function extendObject(object: any): {
2
+ orig: any;
3
+ extended: {};
4
+ };
@@ -0,0 +1,4 @@
1
+ export function flattenObject(obj: any, { separator, prefix }: {
2
+ separator: any;
3
+ prefix?: string;
4
+ }): {};
@@ -0,0 +1,13 @@
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";
@@ -0,0 +1 @@
1
+ export function parseJSON(value: any, defaultValue?: {}): any;
@@ -0,0 +1,2 @@
1
+ export function objectForEach(object: any, callback: any): void;
2
+ export function objectMap(object: any, callback: any): any[];
@@ -0,0 +1 @@
1
+ export function mix(...sources: any[]): {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Returns the value at the given path in the object.
3
+ * If the path does not exist, it returns undefined.
4
+ *
5
+ * @param {Object} object - The object to get the nested property from.
6
+ * @param {Array} pathArr - The array representing the path to the property.
7
+ * @return {*} The value at the given path in the object or undefined if the path does not exist.
8
+ *
9
+ * @example
10
+ * let object = {
11
+ * one: {
12
+ * two: {
13
+ * three: "value"
14
+ * }
15
+ * }
16
+ * };
17
+ * let path = ['one', 'two', 'three'];
18
+ * console.log(getNestedProperty(object, path)); // Outputs: "value"
19
+ */
20
+ export function getNestedProperty(object: any, pathArr: any[]): any;
21
+ export function getNestedProperty2(object: any, path: any): any;
22
+ export function getNestedValue(object: any, path: any): any;
@@ -0,0 +1 @@
1
+ export function normalizeObject(object: any): any;
@@ -0,0 +1 @@
1
+ export function omitEmpty(obj: any, shallow?: boolean): any;
@@ -0,0 +1 @@
1
+ export function sizeOf(obj: any): string;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Split on object up based on the keys provided.
3
+ * @param {Object} obj
4
+ * @param {Array} keys
5
+ * @returns
6
+ */
7
+ export function splitObject(obj: any, keys: any[]): {
8
+ picked: {};
9
+ omitted: any;
10
+ };
@@ -0,0 +1 @@
1
+ export * from "./reject.js";
@@ -0,0 +1,3 @@
1
+ export function reject(props: any, { includeStack }?: {
2
+ includeStack?: boolean;
3
+ }): Promise<never>;
@@ -0,0 +1,16 @@
1
+ export function createSSE({ event, data, id, retry }: {
2
+ event: any;
3
+ data: any;
4
+ id: any;
5
+ retry: any;
6
+ }): string;
7
+ /**
8
+ * Parses a single SSE message into a structured object
9
+ * @param {string} message - The raw SSE message
10
+ * @returns {Object|null} The parsed message or null if invalid
11
+ * @property {string} [event] - The event type if specified
12
+ * @property {string|Object} data - The message data (parsed as JSON if possible)
13
+ * @property {string} [id] - The message ID if specified
14
+ * @property {number} [retry] - The retry interval if specified
15
+ */
16
+ export function parseSSE(message: string): any | null;
@@ -0,0 +1,8 @@
1
+ export function toKebab(string: any): any;
2
+ export function toCamel(string: any): any;
3
+ export function toPascal(string: any): any;
4
+ export function toTitle(string: any): any;
5
+ export function toSlug(string: any): any;
6
+ export function toSentence(string: any): any;
7
+ export function toUpper(string: any): any;
8
+ export function toLower(string: any): any;
@@ -0,0 +1,4 @@
1
+ export * from "./convert-case/convert-case.js";
2
+ export * from "./markdown.js";
3
+ export * from "./pluralize.js";
4
+ export * from "./query-string.js";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Converts markdown content to HTML with whitespace handling
3
+ * @param {string} content - Markdown content to convert
4
+ * @param {Object} [options={}] - Conversion options
5
+ * @param {boolean} [options.inline=false] - Whether content should be treated as inline markdown
6
+ * @returns {string|Promise<string>} HTML string or Promise that resolves to HTML string
7
+ */
8
+ export function markdown(content: string, options?: {
9
+ inline?: boolean;
10
+ }): string | Promise<string>;
11
+ /**
12
+ * Handles whitespace in markdown content to ensure proper rendering
13
+ * @param {string} content - Markdown content to process
14
+ * @param {Object} [options={}] - Processing options
15
+ * @param {boolean} [options.inline=false] - Whether content is inline markdown
16
+ * @returns {{ content: string, inline: boolean }} Processed content and inline status
17
+ */
18
+ export function treatMarkdownWhitespace(content: string, { inline }?: {
19
+ inline?: boolean;
20
+ }): {
21
+ content: string;
22
+ inline: boolean;
23
+ };
@@ -0,0 +1 @@
1
+ export { pluralize };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts object into a query string
3
+ * @param {Object} object
4
+ * @returns
5
+ */
6
+ export function toQueryString(object: any): string;
7
+ export function plural(count: any, noun: any, suffix?: string): string;
8
+ export function stripNumbers(string: any): any;
@@ -0,0 +1 @@
1
+ export function toStyleString(style: any): string;
@@ -0,0 +1 @@
1
+ export * from "./symbols.js";
@@ -0,0 +1,2 @@
1
+ export function getSymbol(object: any, description: any): symbol;
2
+ export function getSymbolValue(object: any, description: any): any;
@@ -0,0 +1 @@
1
+ export function uuid(): `${string}-${string}-${string}-${string}-${string}`;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Returns __dirname
3
+ * @param url — import.meta.url
4
+ * @returns
5
+ */
6
+ export function __dirname(url: any): string;
7
+ export function dirname(url: any): string;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Creates a file cache instance for managing cached files in a directory
3
+ * @param {string} dir - Relative path to cache directory
4
+ * @returns {Promise<object>} Cache instance
5
+ * @property {function(string): Promise<number>} cacheAt - Returns the cached file's modified timestamp, or directory's last modified time if no file specified
6
+ * @property {function(string): string} getAbsPath - Returns absolute path for a file in cache
7
+ * @property {function(string): Promise<boolean>} hasFile - Checks if a file exists in cache
8
+ * @property {function(string): Promise<Buffer|undefined>} loadFile - Loads file contents from cache
9
+ * @property {function(string, string|Buffer): Promise<void>} saveFile - Saves data to cache file
10
+ * @property {function(string): Promise<object>} loadJSON - Loads and parses JSON from cache file
11
+ * @property {function(string, object): Promise<void>} saveJSON - Saves object as JSON to cache file
12
+ */
13
+ export function createCache(dir: string): Promise<object>;
14
+ /**
15
+ * Legacy file cache API for managing a single cached file
16
+ * @param {Object} options
17
+ * @param {string} options.dir - Relative path to cache directory
18
+ * @param {string} options.file - Filename to cache
19
+ * @returns {Promise<{
20
+ * modifiedAt: number,
21
+ * load: () => Promise<Buffer>,
22
+ * save: (data: string|Buffer) => Promise<void>,
23
+ * loadJSON: () => Promise<object>,
24
+ * saveJSON: (data: object) => Promise<void>
25
+ * }>}
26
+ */
27
+ export function fileCache({ dir, file }: {
28
+ dir: string;
29
+ file: string;
30
+ }): Promise<{
31
+ modifiedAt: number;
32
+ load: () => Promise<Buffer>;
33
+ save: (data: string | Buffer) => Promise<void>;
34
+ loadJSON: () => Promise<object>;
35
+ saveJSON: (data: object) => Promise<void>;
36
+ }>;
37
+ /**
38
+ * Gets the most recent modification time of files matching the glob pattern
39
+ * @param {string|string[]} globPath - Glob pattern(s) to match files
40
+ * @returns {Promise<number>} Timestamp of most recently modified file, or 0 if no files found
41
+ */
42
+ export function getLastModifiedTime(globPath: string | string[]): Promise<number>;
43
+ /**
44
+ * @deprecated Use getLastModifiedTime instead
45
+ * @param {string|string[]} globPath - Glob pattern(s) to match files
46
+ * @returns {Promise<number>} Timestamp of most recently modified file, or 0 if no files found
47
+ */
48
+ export function getLatestModifiedTime(globPath: string | string[]): Promise<number>;
49
+ /**
50
+ * Removes leading slash from a path string
51
+ * @param {string} x - Path string to process
52
+ * @returns {string} Path without leading slash
53
+ */
54
+ export function removeFirstSlash(x: string): string;
@@ -0,0 +1,2 @@
1
+ export function mkdir(path: any): Promise<string>;
2
+ export function copyFile(from: any, to: any): Promise<void>;
@@ -0,0 +1 @@
1
+ export function sha256Hash(string: any): string;
@@ -0,0 +1,7 @@
1
+ export * from "./common.js";
2
+ export * from "./dirname.js";
3
+ export * from "./file-cache.js";
4
+ export * from "./hash.js";
5
+ export * from "./pkce.js";
6
+ export * from "./random-string.js";
7
+ export * from "./sanitize.js";
@@ -0,0 +1,6 @@
1
+ export function PKCE(): Promise<{
2
+ state: string;
3
+ code_verifier: string;
4
+ code_challenge: string;
5
+ code_challenge_method: string;
6
+ }>;
@@ -0,0 +1,2 @@
1
+ export function randomString(length?: number): Promise<string>;
2
+ export function randomStringSync(length?: number): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Sanitizes values using sanitize-html
3
+ * @param {*} value - Value to sanitize (string, array, or object)
4
+ * @param {Object} [options={}] - sanitize-html options
5
+ * @returns {*} Sanitized value
6
+ * @throws {Error} If input is a string but sanitize-html fails
7
+ */
8
+ export function sanitize(value: any, options?: any): any;