solid-tiny-utils 0.12.0 → 0.12.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 (46) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +9 -9
  3. package/dist/color/hex-rgb.d.mts +0 -1
  4. package/dist/color/hex-rgb.mjs +1 -3
  5. package/dist/color/oklch-rgb.d.mts +3 -3
  6. package/dist/color/oklch-rgb.mjs +1 -3
  7. package/dist/color/validation.d.mts +0 -1
  8. package/dist/color/validation.mjs +1 -3
  9. package/dist/dom/animation.mjs +1 -2
  10. package/dist/dom/attrs.mjs +1 -2
  11. package/dist/dom/css.d.mts +1 -2
  12. package/dist/dom/css.mjs +4 -5
  13. package/dist/dom/index.d.mts +3 -0
  14. package/dist/index.d.mts +0 -2
  15. package/dist/index.mjs +2 -3
  16. package/dist/solidjs/create-click-outside.d.mts +0 -2
  17. package/dist/solidjs/create-click-outside.mjs +2 -6
  18. package/dist/solidjs/create-debounce-watch.d.mts +0 -1
  19. package/dist/solidjs/create-debounce-watch.mjs +1 -3
  20. package/dist/solidjs/create-debounce.d.mts +0 -2
  21. package/dist/solidjs/create-debounce.mjs +1 -3
  22. package/dist/solidjs/create-event-listener.d.mts +0 -1
  23. package/dist/solidjs/create-event-listener.mjs +1 -3
  24. package/dist/solidjs/create-intersection-observer.d.mts +0 -2
  25. package/dist/solidjs/create-intersection-observer.mjs +1 -3
  26. package/dist/solidjs/create-list.mjs +2 -6
  27. package/dist/solidjs/create-loop-exec.d.mts +0 -1
  28. package/dist/solidjs/create-loop-exec.mjs +1 -3
  29. package/dist/solidjs/create-presence.d.mts +0 -1
  30. package/dist/solidjs/create-presence.mjs +1 -3
  31. package/dist/solidjs/create-throttle.d.mts +0 -2
  32. package/dist/solidjs/create-throttle.mjs +1 -3
  33. package/dist/solidjs/create-visibility-observer.d.mts +0 -1
  34. package/dist/solidjs/create-visibility-observer.mjs +1 -3
  35. package/dist/solidjs/create-watch.mjs +1 -3
  36. package/dist/solidjs/make-event-listener.d.mts +0 -2
  37. package/dist/solidjs/make-event-listener.mjs +1 -3
  38. package/dist/solidjs/utils.mjs +1 -3
  39. package/dist/utils/array.mjs +2 -6
  40. package/dist/utils/async.mjs +6 -11
  41. package/dist/utils/constant.mjs +1 -2
  42. package/dist/utils/is.mjs +9 -27
  43. package/dist/utils/number.mjs +1 -2
  44. package/dist/utils/random.mjs +7 -15
  45. package/dist/utils/str.mjs +6 -17
  46. package/package.json +38 -38
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 g-mero
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 g-mero
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # solid-tiny-utils
2
-
3
- Tiny utilities for SolidJS applications.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add solid-tiny-utils
9
- ```
1
+ # solid-tiny-utils
2
+
3
+ Tiny utilities for SolidJS applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add solid-tiny-utils
9
+ ```
@@ -1,7 +1,6 @@
1
1
  import { RGB } from "./oklch-rgb.mjs";
2
2
 
3
3
  //#region src/color/hex-rgb.d.ts
4
-
5
4
  /**
6
5
  * Converts a hex color string to RGB color values.
7
6
  *
@@ -1,6 +1,5 @@
1
1
  import { isArray } from "../utils/is.mjs";
2
2
  import { clamp, toHex } from "../utils/number.mjs";
3
-
4
3
  //#region src/color/hex-rgb.ts
5
4
  const HEX_PREFIX_REGEX = /^#/;
6
5
  const HEX_VALIDATION_REGEX = /^[0-9a-fA-F]{6}$/;
@@ -57,6 +56,5 @@ function rgbToHex(rgb) {
57
56
  const b = c(rgb_[2]);
58
57
  return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
59
58
  }
60
-
61
59
  //#endregion
62
- export { hexToRgb, rgbToHex };
60
+ export { hexToRgb, rgbToHex };
@@ -1,13 +1,13 @@
1
1
  //#region src/color/oklch-rgb.d.ts
2
2
  interface RGB {
3
- r: number;
4
- g: number;
5
3
  b: number;
4
+ g: number;
5
+ r: number;
6
6
  }
7
7
  interface OKLCH {
8
- l: number;
9
8
  c: number;
10
9
  h: number;
10
+ l: number;
11
11
  }
12
12
  /**
13
13
  * Converts OKLCH color to RGB color space.
@@ -1,5 +1,4 @@
1
1
  import { clamp, max } from "../utils/number.mjs";
2
-
3
2
  //#region src/color/oklch-rgb.ts
4
3
  const PI_180 = Math.PI / 180;
5
4
  const INV_PI_180 = 180 / Math.PI;
@@ -96,6 +95,5 @@ function rgbToOklch(rgb) {
96
95
  h
97
96
  };
98
97
  }
99
-
100
98
  //#endregion
101
- export { oklchToRgb, rgbToOklch };
99
+ export { oklchToRgb, rgbToOklch };
@@ -1,7 +1,6 @@
1
1
  import { OKLCH, RGB } from "./oklch-rgb.mjs";
2
2
 
3
3
  //#region src/color/validation.d.ts
4
-
5
4
  /**
6
5
  * Checks if RGB values are in valid range (0-255)
7
6
  */
@@ -1,6 +1,5 @@
1
1
  import { inRange } from "../utils/number.mjs";
2
2
  import { hexToRgb } from "./hex-rgb.mjs";
3
-
4
3
  //#region src/color/validation.ts
5
4
  /**
6
5
  * Checks if RGB values are in valid range (0-255)
@@ -30,6 +29,5 @@ function isValidOKLCH(oklch) {
30
29
  function isValidHex(hex) {
31
30
  return hexToRgb(hex) !== null;
32
31
  }
33
-
34
32
  //#endregion
35
- export { isValidHex, isValidOKLCH, isValidRGB };
33
+ export { isValidHex, isValidOKLCH, isValidRGB };
@@ -3,6 +3,5 @@ function hasAnimation(element) {
3
3
  const styles = getComputedStyle(element);
4
4
  return Number.parseFloat(styles.animationDuration || "0") > 0;
5
5
  }
6
-
7
6
  //#endregion
8
- export { hasAnimation };
7
+ export { hasAnimation };
@@ -21,6 +21,5 @@
21
21
  function dataIf(show) {
22
22
  return show ? "" : void 0;
23
23
  }
24
-
25
24
  //#endregion
26
- export { dataIf };
25
+ export { dataIf };
@@ -1,7 +1,6 @@
1
1
  import { JSX } from "solid-js/jsx-runtime";
2
2
 
3
3
  //#region src/dom/css.d.ts
4
-
5
4
  /**
6
5
  * Mounts a style element to the document head.
7
6
  * If the style element with the given id already exists, it updates its content.
@@ -12,7 +11,7 @@ import { JSX } from "solid-js/jsx-runtime";
12
11
  * @param id - The id of the style element.
13
12
  * @param refresh - Whether to refresh the style if it already exists. Defaults to **false**.
14
13
  */
15
- declare function mountStyle(style: string, id: string, refresh?: boolean): void;
14
+ declare function mountStyle(style: string | (() => string), id: string, refresh?: boolean): void;
16
15
  declare function stringStyleToObject(style: string): JSX.CSSProperties;
17
16
  declare function combineStyle(a: JSX.CSSProperties, b: JSX.CSSProperties | string | undefined): JSX.CSSProperties | string;
18
17
  declare function combineClass(defaultClass: string, ...otherClass: (string | undefined | null)[]): string;
package/dist/dom/css.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isClient } from "../utils/is.mjs";
2
-
2
+ import { access } from "../solidjs/utils.mjs";
3
3
  //#region src/dom/css.ts
4
4
  const alreadyInjected = [];
5
5
  /**
@@ -17,12 +17,12 @@ function mountStyle(style, id, refresh = false) {
17
17
  if (alreadyInjected.includes(id) && !refresh) return;
18
18
  let styleElement = document.querySelector(`style#${id}`);
19
19
  if (styleElement) {
20
- styleElement.innerHTML = style;
20
+ styleElement.textContent = access(style);
21
21
  return;
22
22
  }
23
23
  styleElement = document.createElement("style");
24
24
  styleElement.id = id;
25
- styleElement.innerHTML = style;
25
+ styleElement.textContent = access(style);
26
26
  document.head.appendChild(styleElement);
27
27
  alreadyInjected.push(id);
28
28
  }
@@ -46,6 +46,5 @@ function combineStyle(a, b) {
46
46
  function combineClass(defaultClass, ...otherClass) {
47
47
  return [defaultClass, ...otherClass].filter(Boolean).join(" ");
48
48
  }
49
-
50
49
  //#endregion
51
- export { combineClass, combineStyle, mountStyle, stringStyleToObject };
50
+ export { combineClass, combineStyle, mountStyle, stringStyleToObject };
@@ -0,0 +1,3 @@
1
+ import { hasAnimation } from "./animation.mjs";
2
+ import { dataIf } from "./attrs.mjs";
3
+ import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./css.mjs";
package/dist/index.d.mts CHANGED
@@ -6,7 +6,6 @@ import { dataIf } from "./dom/attrs.mjs";
6
6
  import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
7
7
  import { AnyFn, Fn } from "./types/fn.mjs";
8
8
  import { MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise } from "./types/maybe.mjs";
9
- import "./types/index.mjs";
10
9
  import { createClickOutside } from "./solidjs/create-click-outside.mjs";
11
10
  import { createDebounce } from "./solidjs/create-debounce.mjs";
12
11
  import { createDebouncedWatch } from "./solidjs/create-debounce-watch.mjs";
@@ -20,7 +19,6 @@ import { createThrottle } from "./solidjs/create-throttle.mjs";
20
19
  import { CreateVisibilityObserverOption, EntryCallback, UseVisibilityObserverFn, createVisibilityObserver } from "./solidjs/create-visibility-observer.mjs";
21
20
  import { createWatch } from "./solidjs/create-watch.mjs";
22
21
  import { MaybeCallableChild, access, callMaybeCallableChild, runSolidEventHandler } from "./solidjs/utils.mjs";
23
- import "./solidjs/index.mjs";
24
22
  import { clearArray, iterate, list, range } from "./utils/array.mjs";
25
23
  import { runAtNextAnimationFrame, sleep } from "./utils/async.mjs";
26
24
  import { noop } from "./utils/constant.mjs";
package/dist/index.mjs CHANGED
@@ -10,7 +10,6 @@ import { oklchToRgb, rgbToOklch } from "./color/oklch-rgb.mjs";
10
10
  import { isValidHex, isValidOKLCH, isValidRGB } from "./color/validation.mjs";
11
11
  import { hasAnimation } from "./dom/animation.mjs";
12
12
  import { dataIf } from "./dom/attrs.mjs";
13
- import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
14
13
  import { makeEventListener } from "./solidjs/make-event-listener.mjs";
15
14
  import { access, callMaybeCallableChild, runSolidEventHandler } from "./solidjs/utils.mjs";
16
15
  import { createClickOutside } from "./solidjs/create-click-outside.mjs";
@@ -24,5 +23,5 @@ import { createLoopExec } from "./solidjs/create-loop-exec.mjs";
24
23
  import { createPresence } from "./solidjs/create-presence.mjs";
25
24
  import { createThrottle } from "./solidjs/create-throttle.mjs";
26
25
  import { createVisibilityObserver } from "./solidjs/create-visibility-observer.mjs";
27
-
28
- export { access, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createList, createLoopExec, createPresence, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hasAnimation, hexToRgb, inRange, isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
26
+ import { combineClass, combineStyle, mountStyle, stringStyleToObject } from "./dom/css.mjs";
27
+ export { access, callMaybeCallableChild, camel, capitalize, clamp, clearArray, combineClass, combineStyle, createClickOutside, createDebounce, createDebouncedWatch, createEventListener, createIntersectionObserver, createList, createLoopExec, createPresence, createThrottle, createVisibilityObserver, createWatch, dash, dataIf, draw, hasAnimation, hexToRgb, inRange, isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined, isValidHex, isValidOKLCH, isValidRGB, iterate, list, makeEventListener, max, min, mountStyle, noop, oklchToRgb, pascal, random, range, rgbToHex, rgbToOklch, runAtNextAnimationFrame, runSolidEventHandler, shuffle, sleep, snake, stringStyleToObject, template, title, toHex, trim, uid };
@@ -1,6 +1,4 @@
1
1
  import { MaybeAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
-
4
2
  //#region src/solidjs/create-click-outside.d.ts
5
3
  declare function createClickOutside(target: MaybeAccessor<HTMLElement | null | undefined>, handler: (event: PointerEvent) => void, options?: {
6
4
  ignore?: MaybeAccessor<HTMLElement | null | undefined>[];
@@ -1,13 +1,10 @@
1
1
  import { makeEventListener } from "./make-event-listener.mjs";
2
2
  import { access } from "./utils.mjs";
3
-
4
3
  //#region src/solidjs/create-click-outside.ts
5
4
  function createClickOutside(target, handler, options) {
6
5
  let shouldListen = false;
7
6
  const shouldIgnore = (event) => {
8
- return (options?.ignore ? options.ignore : []).map(access).some((el) => {
9
- return el && (event.target === el || event.composedPath().includes(el));
10
- });
7
+ return (options?.ignore ? options.ignore : []).map(access).some((el) => el && (event.target === el || event.composedPath().includes(el)));
11
8
  };
12
9
  const listener = (e) => {
13
10
  const el = access(target);
@@ -28,6 +25,5 @@ function createClickOutside(target, handler, options) {
28
25
  };
29
26
  return stop;
30
27
  }
31
-
32
28
  //#endregion
33
- export { createClickOutside };
29
+ export { createClickOutside };
@@ -1,7 +1,6 @@
1
1
  import { Accessor, AccessorArray, OnOptions } from "solid-js";
2
2
 
3
3
  //#region src/solidjs/create-debounce-watch.d.ts
4
-
5
4
  /**
6
5
  * Creates a debounced watch effect.
7
6
  *
@@ -1,6 +1,5 @@
1
1
  import { createDebounce } from "./create-debounce.mjs";
2
2
  import { createWatch } from "./create-watch.mjs";
3
-
4
3
  //#region src/solidjs/create-debounce-watch.ts
5
4
  /**
6
5
  * Creates a debounced watch effect.
@@ -10,6 +9,5 @@ import { createWatch } from "./create-watch.mjs";
10
9
  function createDebouncedWatch(targets, fn, opt) {
11
10
  createWatch(targets, createDebounce(fn, opt?.delay ?? 10), opt);
12
11
  }
13
-
14
12
  //#endregion
15
- export { createDebouncedWatch };
13
+ export { createDebouncedWatch };
@@ -1,6 +1,4 @@
1
1
  import { MaybeAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
-
4
2
  //#region src/solidjs/create-debounce.d.ts
5
3
  declare function createDebounce<Args extends unknown[]>(callback: (...args: Args) => void, delay: MaybeAccessor<number>): (...args: Args) => void;
6
4
  //#endregion
@@ -1,6 +1,5 @@
1
1
  import { access } from "./utils.mjs";
2
2
  import { onCleanup } from "solid-js";
3
-
4
3
  //#region src/solidjs/create-debounce.ts
5
4
  function createDebounce(callback, delay) {
6
5
  let timeoutId;
@@ -15,6 +14,5 @@ function createDebounce(callback, delay) {
15
14
  };
16
15
  return run;
17
16
  }
18
-
19
17
  //#endregion
20
- export { createDebounce };
18
+ export { createDebounce };
@@ -1,6 +1,5 @@
1
1
  import { Fn } from "../types/fn.mjs";
2
2
  import { MaybeAccessor, MaybeArray } from "../types/maybe.mjs";
3
- import "../types/index.mjs";
4
3
  import { DocumentEventName, GeneralEventListener, WindowEventName } from "./make-event-listener.mjs";
5
4
 
6
5
  //#region src/solidjs/create-event-listener.d.ts
@@ -4,7 +4,6 @@ import { noop } from "../utils/constant.mjs";
4
4
  import { makeEventListener } from "./make-event-listener.mjs";
5
5
  import { access } from "./utils.mjs";
6
6
  import { createWatch } from "./create-watch.mjs";
7
-
8
7
  //#region src/solidjs/create-event-listener.ts
9
8
  function createEventListener(...args) {
10
9
  const target = args[0];
@@ -28,6 +27,5 @@ function createEventListener(...args) {
28
27
  });
29
28
  return cleanup;
30
29
  }
31
-
32
30
  //#endregion
33
- export { createEventListener };
31
+ export { createEventListener };
@@ -1,6 +1,4 @@
1
1
  import { MaybeAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
-
4
2
  //#region src/solidjs/create-intersection-observer.d.ts
5
3
  declare function createIntersectionObserver(targets: MaybeAccessor<HTMLElement | null | undefined>[], callback: IntersectionObserverCallback, options?: IntersectionObserverInit): () => void;
6
4
  //#endregion
@@ -4,7 +4,6 @@ import { access } from "./utils.mjs";
4
4
  import { createWatch } from "./create-watch.mjs";
5
5
  import { isServer } from "solid-js/web";
6
6
  import { onCleanup } from "solid-js";
7
-
8
7
  //#region src/solidjs/create-intersection-observer.ts
9
8
  function createIntersectionObserver(targets, callback, options = {}) {
10
9
  if (isServer) return noop;
@@ -24,6 +23,5 @@ function createIntersectionObserver(targets, callback, options = {}) {
24
23
  });
25
24
  return () => io.disconnect();
26
25
  }
27
-
28
26
  //#endregion
29
- export { createIntersectionObserver };
27
+ export { createIntersectionObserver };
@@ -1,6 +1,5 @@
1
1
  import { inRange } from "../utils/number.mjs";
2
2
  import { createStore, unwrap } from "solid-js/store";
3
-
4
3
  //#region src/solidjs/create-list.ts
5
4
  function createInsertHelper(setList) {
6
5
  return (item, at) => {
@@ -67,11 +66,8 @@ function createList(initialValue) {
67
66
  swap: createSwapHelper(setList),
68
67
  move: createMoveHelper(setList),
69
68
  sort: createSortHelper(setList),
70
- isSortedBy: (compareFn) => {
71
- return createIsSortedHelper(list, compareFn);
72
- }
69
+ isSortedBy: (compareFn) => createIsSortedHelper(list, compareFn)
73
70
  }];
74
71
  }
75
-
76
72
  //#endregion
77
- export { createList };
73
+ export { createList };
@@ -1,7 +1,6 @@
1
1
  import { MaybeAccessor, MaybePromise } from "../types/maybe.mjs";
2
2
 
3
3
  //#region src/solidjs/create-loop-exec.d.ts
4
-
5
4
  /**
6
5
  * Repeatedly executes an asynchronous function with a specified delay between each execution.
7
6
  * The loop continues until the surrounding SolidJS effect is cleaned up.
@@ -2,7 +2,6 @@ import { isNumber } from "../utils/is.mjs";
2
2
  import { access } from "./utils.mjs";
3
3
  import { createWatch } from "./create-watch.mjs";
4
4
  import { onCleanup } from "solid-js";
5
-
6
5
  //#region src/solidjs/create-loop-exec.ts
7
6
  /**
8
7
  * Repeatedly executes an asynchronous function with a specified delay between each execution.
@@ -54,6 +53,5 @@ function createLoopExec(fn, delay) {
54
53
  start
55
54
  };
56
55
  }
57
-
58
56
  //#endregion
59
- export { createLoopExec };
57
+ export { createLoopExec };
@@ -1,5 +1,4 @@
1
1
  import { MaybeAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
2
  import { Accessor } from "solid-js";
4
3
 
5
4
  //#region src/solidjs/create-presence.d.ts
@@ -4,7 +4,6 @@ import { noop } from "../utils/constant.mjs";
4
4
  import { access } from "./utils.mjs";
5
5
  import { createWatch } from "./create-watch.mjs";
6
6
  import { createEffect, createMemo, createSignal, onCleanup, untrack } from "solid-js";
7
-
8
7
  //#region src/solidjs/create-presence.ts
9
8
  function makeTimeout(ms, fn) {
10
9
  if (ms() <= 0) {
@@ -84,6 +83,5 @@ function createPresence(item, options) {
84
83
  mountedItem
85
84
  };
86
85
  }
87
-
88
86
  //#endregion
89
- export { createPresence };
87
+ export { createPresence };
@@ -1,6 +1,4 @@
1
1
  import { MaybeAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
-
4
2
  //#region src/solidjs/create-throttle.d.ts
5
3
  declare function createThrottle<Args extends unknown[]>(callback: (...args: Args) => void, delay: MaybeAccessor<number>): (...args: Args) => void;
6
4
  //#endregion
@@ -1,6 +1,5 @@
1
1
  import { access } from "./utils.mjs";
2
2
  import { onCleanup } from "solid-js";
3
-
4
3
  //#region src/solidjs/create-throttle.ts
5
4
  function createThrottle(callback, delay) {
6
5
  let timeoutId;
@@ -16,6 +15,5 @@ function createThrottle(callback, delay) {
16
15
  };
17
16
  return run;
18
17
  }
19
-
20
18
  //#endregion
21
- export { createThrottle };
19
+ export { createThrottle };
@@ -1,5 +1,4 @@
1
1
  import { MaybeNullableAccessor } from "../types/maybe.mjs";
2
- import "../types/index.mjs";
3
2
  import { Accessor } from "solid-js";
4
3
 
5
4
  //#region src/solidjs/create-visibility-observer.d.ts
@@ -2,7 +2,6 @@ import { isObject } from "../utils/is.mjs";
2
2
  import { access } from "./utils.mjs";
3
3
  import { createWatch } from "./create-watch.mjs";
4
4
  import { createSignal, onCleanup } from "solid-js";
5
-
6
5
  //#region src/solidjs/create-visibility-observer.ts
7
6
  function createVisibilityObserver(arg1, arg2) {
8
7
  let target;
@@ -41,6 +40,5 @@ function createVisibilityObserver(arg1, arg2) {
41
40
  if (target) return useVisibilityObserverFn(target);
42
41
  return useVisibilityObserverFn;
43
42
  }
44
-
45
43
  //#endregion
46
- export { createVisibilityObserver };
44
+ export { createVisibilityObserver };
@@ -1,9 +1,7 @@
1
1
  import { createEffect, on } from "solid-js";
2
-
3
2
  //#region src/solidjs/create-watch.ts
4
3
  function createWatch(targets, fn, opt) {
5
4
  createEffect(on(targets, fn, opt));
6
5
  }
7
-
8
6
  //#endregion
9
- export { createWatch };
7
+ export { createWatch };
@@ -1,7 +1,5 @@
1
1
  import { Fn } from "../types/fn.mjs";
2
2
  import { MaybeArray } from "../types/maybe.mjs";
3
- import "../types/index.mjs";
4
-
5
3
  //#region src/solidjs/make-event-listener.d.ts
6
4
  interface InferEventTarget<Events> {
7
5
  addEventListener: (event: Events, fn?: any, options?: any) => any;
@@ -2,7 +2,6 @@ import { isArray } from "../utils/is.mjs";
2
2
  import { clearArray } from "../utils/array.mjs";
3
3
  import { noop } from "../utils/constant.mjs";
4
4
  import { onCleanup } from "solid-js";
5
-
6
5
  //#region src/solidjs/make-event-listener.ts
7
6
  /** biome-ignore-all lint/suspicious/noExplicitAny: I need any */
8
7
  function makeEventListener(...args) {
@@ -30,6 +29,5 @@ function makeEventListener(...args) {
30
29
  onCleanup(cleanup);
31
30
  return cleanup;
32
31
  }
33
-
34
32
  //#endregion
35
- export { makeEventListener };
33
+ export { makeEventListener };
@@ -1,5 +1,4 @@
1
1
  import { isArray, isFn } from "../utils/is.mjs";
2
-
3
2
  //#region src/solidjs/utils.ts
4
3
  function access(value) {
5
4
  return isFn(value) ? value() : value;
@@ -18,6 +17,5 @@ function runSolidEventHandler(event, handler) {
18
17
  function callMaybeCallableChild(children, ...args) {
19
18
  return isFn(children) ? children(...args) : children;
20
19
  }
21
-
22
20
  //#endregion
23
- export { access, callMaybeCallableChild, runSolidEventHandler };
21
+ export { access, callMaybeCallableChild, runSolidEventHandler };
@@ -1,5 +1,4 @@
1
1
  import { isFn } from "./is.mjs";
2
-
3
2
  //#region src/utils/array.ts
4
3
  /**
5
4
  * Like a reduce but does not require an array.
@@ -52,15 +51,12 @@ function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
52
51
  * list(0, 3, obj) // obj, obj, obj, obj
53
52
  * list(0, 6, i => i, 2) // 0, 2, 4, 6
54
53
  */
55
- const list = (startOrLength, end, valueOrMapper, step) => {
56
- return Array.from(range(startOrLength, end, valueOrMapper, step));
57
- };
54
+ const list = (startOrLength, end, valueOrMapper, step) => Array.from(range(startOrLength, end, valueOrMapper, step));
58
55
  /**
59
56
  * set arr.length to 0
60
57
  */
61
58
  function clearArray(arr) {
62
59
  arr.length = 0;
63
60
  }
64
-
65
61
  //#endregion
66
- export { clearArray, iterate, list, range };
62
+ export { clearArray, iterate, list, range };
@@ -2,16 +2,11 @@
2
2
  /**
3
3
  * Async wait
4
4
  */
5
- const sleep = (milliseconds) => {
6
- return new Promise((res) => setTimeout(res, milliseconds));
7
- };
8
- const runAtNextAnimationFrame = (cb) => {
9
- return requestAnimationFrame(() => {
10
- requestAnimationFrame(() => {
11
- cb();
12
- });
5
+ const sleep = (milliseconds) => new Promise((res) => setTimeout(res, milliseconds));
6
+ const runAtNextAnimationFrame = (cb) => requestAnimationFrame(() => {
7
+ requestAnimationFrame(() => {
8
+ cb();
13
9
  });
14
- };
15
-
10
+ });
16
11
  //#endregion
17
- export { runAtNextAnimationFrame, sleep };
12
+ export { runAtNextAnimationFrame, sleep };
@@ -1,5 +1,4 @@
1
1
  //#region src/utils/constant.ts
2
2
  const noop = () => {};
3
-
4
3
  //#endregion
5
- export { noop };
4
+ export { noop };
package/dist/utils/is.mjs CHANGED
@@ -1,14 +1,9 @@
1
1
  import { isServer } from "solid-js/web";
2
-
3
2
  //#region src/utils/is.ts
4
3
  /** biome-ignore-all lint/suspicious/noExplicitAny: need any */
5
- const isSymbol = (value) => {
6
- return !!value && value.constructor === Symbol;
7
- };
4
+ const isSymbol = (value) => !!value && value.constructor === Symbol;
8
5
  const isArray = Array.isArray;
9
- const isObject = (value) => {
10
- return !!value && value.constructor === Object;
11
- };
6
+ const isObject = (value) => !!value && value.constructor === Object;
12
7
  /**
13
8
  * Checks if the given value is primitive.
14
9
  *
@@ -17,21 +12,11 @@ const isObject = (value) => {
17
12
  * @param {*} value value to check
18
13
  * @returns {boolean} result
19
14
  */
20
- const isPrimitive = (value) => {
21
- return value === void 0 || value === null || typeof value !== "object" && typeof value !== "function";
22
- };
23
- const isFn = (value) => {
24
- return typeof value === "function";
25
- };
26
- const isString = (value) => {
27
- return typeof value === "string" || value instanceof String;
28
- };
29
- const isInt = (value) => {
30
- return isNumber(value) && value % 1 === 0;
31
- };
32
- const isFloat = (value) => {
33
- return isNumber(value) && value % 1 !== 0;
34
- };
15
+ const isPrimitive = (value) => value === void 0 || value === null || typeof value !== "object" && typeof value !== "function";
16
+ const isFn = (value) => typeof value === "function";
17
+ const isString = (value) => typeof value === "string" || value instanceof String;
18
+ const isInt = (value) => isNumber(value) && value % 1 === 0;
19
+ const isFloat = (value) => isNumber(value) && value % 1 !== 0;
35
20
  const isNumber = (value) => {
36
21
  try {
37
22
  return Number(value) === value;
@@ -39,9 +24,7 @@ const isNumber = (value) => {
39
24
  return false;
40
25
  }
41
26
  };
42
- const isDate = (value) => {
43
- return Object.prototype.toString.call(value) === "[object Date]";
44
- };
27
+ const isDate = (value) => Object.prototype.toString.call(value) === "[object Date]";
45
28
  /**
46
29
  * This is really a _best guess_ promise checking. You
47
30
  * should probably use Promise.resolve(value) to be 100%
@@ -73,6 +56,5 @@ function isUndefined(value) {
73
56
  function isDefined(value) {
74
57
  return !isUndefined(value);
75
58
  }
76
-
77
59
  //#endregion
78
- export { isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined };
60
+ export { isArray, isClient, isDate, isDefined, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, isUndefined };
@@ -122,6 +122,5 @@ function inRange(x, minimum = 0, maximum = 1, inclusivity = "[]") {
122
122
  function toHex(x, pad = 2) {
123
123
  return x.toString(16).padStart(pad, "0");
124
124
  }
125
-
126
125
  //#endregion
127
- export { clamp, inRange, max, min, toHex };
126
+ export { clamp, inRange, max, min, toHex };
@@ -1,12 +1,9 @@
1
1
  import { iterate } from "./array.mjs";
2
-
3
2
  //#region src/utils/random.ts
4
3
  /**
5
4
  * Generates a random number between min and max
6
5
  */
7
- const random = (min, max) => {
8
- return Math.floor(Math.random() * (max - min + 1) + min);
9
- };
6
+ const random = (min, max) => Math.floor(Math.random() * (max - min + 1) + min);
10
7
  /**
11
8
  * Draw a random item from a list. Returns
12
9
  * null if the list is empty
@@ -16,18 +13,13 @@ const draw = (array) => {
16
13
  if (max === 0) return null;
17
14
  return array[random(0, max - 1)];
18
15
  };
19
- const shuffle = (array) => {
20
- return array.map((a) => ({
21
- rand: Math.random(),
22
- value: a
23
- })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
24
- };
16
+ const shuffle = (array) => array.map((a) => ({
17
+ rand: Math.random(),
18
+ value: a
19
+ })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
25
20
  const uid = (length, specials = "") => {
26
21
  const characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789${specials}`;
27
- return iterate(length, (acc) => {
28
- return acc + characters.charAt(random(0, characters.length - 1));
29
- }, "");
22
+ return iterate(length, (acc) => acc + characters.charAt(random(0, characters.length - 1)), "");
30
23
  };
31
-
32
24
  //#endregion
33
- export { draw, random, shuffle, uid };
25
+ export { draw, random, shuffle, uid };
@@ -8,7 +8,7 @@
8
8
  const capitalize = (str) => {
9
9
  if (!str || str.length === 0) return "";
10
10
  const lower = str.toLowerCase();
11
- return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
11
+ return lower.slice(0, 1).toUpperCase() + lower.slice(1, lower.length);
12
12
  };
13
13
  const splitRegexp = /(?=[A-Z])|[.\-\s_]/;
14
14
  /**
@@ -22,9 +22,7 @@ const camel = (str) => {
22
22
  const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
23
23
  if (parts.length === 0) return "";
24
24
  if (parts.length === 1) return parts[0];
25
- return parts.reduce((acc, part) => {
26
- return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
27
- });
25
+ return parts.reduce((acc, part) => `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`);
28
26
  };
29
27
  const splitOnNumberRegexp = /([A-Za-z]{1}[0-9]{1})/;
30
28
  /**
@@ -40,9 +38,7 @@ const snake = (str, options) => {
40
38
  const parts = str?.replace(/([A-Z])+/g, capitalize).split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
41
39
  if (parts.length === 0) return "";
42
40
  if (parts.length === 1) return parts[0];
43
- const result = parts.reduce((acc, part) => {
44
- return `${acc}_${part.toLowerCase()}`;
45
- });
41
+ const result = parts.reduce((acc, part) => `${acc}_${part.toLowerCase()}`);
46
42
  return options?.splitOnNumber === false ? result : result.replace(splitOnNumberRegexp, (val) => `${val[0]}_${val[1]}`);
47
43
  };
48
44
  /**
@@ -56,9 +52,7 @@ const dash = (str) => {
56
52
  const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
57
53
  if (parts.length === 0) return "";
58
54
  if (parts.length === 1) return parts[0];
59
- return parts.reduce((acc, part) => {
60
- return `${acc}-${part.toLowerCase()}`;
61
- });
55
+ return parts.reduce((acc, part) => `${acc}-${part.toLowerCase()}`);
62
56
  };
63
57
  const pascalSplitRegexp = /[.\-\s_]/;
64
58
  /**
@@ -91,11 +85,7 @@ const title = (str) => {
91
85
  * Ex. template('Hello, {{name}}', { name: 'ray' })
92
86
  * Ex. template('Hello, <name>', { name: 'ray' }, /<(.+?)>/g)
93
87
  */
94
- const template = (str, data, regex = /\{\{(.+?)\}\}/g) => {
95
- return Array.from(str.matchAll(regex)).reduce((acc, match) => {
96
- return acc.replace(match[0], data[match[1]]);
97
- }, str);
98
- };
88
+ const template = (str, data, regex = /\{\{(.+?)\}\}/g) => Array.from(str.matchAll(regex)).reduce((acc, match) => acc.replace(match[0], data[match[1]]), str);
99
89
  /**
100
90
  * Trims all prefix and suffix characters from the given
101
91
  * string. Like the builtin trim function but accepts
@@ -115,6 +105,5 @@ const trim = (str, charsToTrim = " ") => {
115
105
  const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
116
106
  return str.replace(regex, "");
117
107
  };
118
-
119
108
  //#endregion
120
- export { camel, capitalize, dash, pascal, snake, template, title, trim };
109
+ export { camel, capitalize, dash, pascal, snake, template, title, trim };
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
1
  {
2
+ "devDependencies": {
3
+ "@biomejs/biome": "2.4.15",
4
+ "@formkit/auto-animate": "^0.9.0",
5
+ "@solidjs/router": "^0.16.1",
6
+ "@solidjs/testing-library": "^0.8.10",
7
+ "@testing-library/jest-dom": "^6.9.1",
8
+ "@testing-library/user-event": "^14.6.1",
9
+ "@types/culori": "^4.0.0",
10
+ "@types/node": "^25.0.3",
11
+ "@typescript/native-preview": "7.0.0-dev.20260421.2",
12
+ "@vitest/ui": "^4.0.16",
13
+ "bumpp": "^11.1.0",
14
+ "culori": "^4.0.2",
15
+ "jsdom": "^29.1.1",
16
+ "solid-tiny-context": "0.3.1",
17
+ "tsdown": "^0.22.0",
18
+ "ultracite": "7.7.0",
19
+ "unocss": "^66.7.0",
20
+ "vite": "^8.0.14",
21
+ "vite-plugin-solid": "^2.11.12",
22
+ "vite-plugin-solid-pages": "^0.4.3",
23
+ "vitest": "^4.0.16"
24
+ },
2
25
  "name": "solid-tiny-utils",
3
- "version": "0.12.0",
26
+ "peerDependencies": {
27
+ "solid-js": "^1.9.7"
28
+ },
29
+ "type": "module",
30
+ "version": "0.12.1",
4
31
  "description": "A collection of tiny utilities for SolidJS applications",
5
32
  "author": "solid tiny",
6
33
  "license": "MIT",
7
- "homepage": "https://github.com/solid-tiny/solid-tiny-utils#readme",
34
+ "homepage": "https://github.com/sxl-cc/solid-tiny-utils#readme",
8
35
  "repository": {
9
36
  "type": "git",
10
- "url": "git+https://github.com/solid-tiny/solid-tiny-utils.git"
37
+ "url": "git+https://github.com/sxl-cc/solid-tiny-utils.git"
11
38
  },
12
39
  "bugs": {
13
- "url": "https://github.com/solid-tiny/solid-tiny-utils/issues"
40
+ "url": "https://github.com/sxl-cc/solid-tiny-utils/issues"
14
41
  },
15
- "type": "module",
16
42
  "files": [
17
43
  "dist"
18
44
  ],
19
45
  "sideEffects": false,
20
- "peerDependencies": {
21
- "solid-js": "^1.9.7"
22
- },
23
- "devDependencies": {
24
- "@biomejs/biome": "2.3.11",
25
- "@formkit/auto-animate": "^0.9.0",
26
- "@solidjs/router": "^0.15.4",
27
- "@solidjs/testing-library": "^0.8.10",
28
- "@testing-library/jest-dom": "^6.9.1",
29
- "@testing-library/user-event": "^14.6.1",
30
- "@types/culori": "^4.0.0",
31
- "@types/node": "^25.0.3",
32
- "@typescript/native-preview": "7.0.0-dev.20260114.1",
33
- "@vitest/ui": "^4.0.16",
34
- "bumpp": "^10.3.2",
35
- "culori": "^4.0.2",
36
- "jsdom": "^27.3.0",
37
- "solid-tiny-context": "0.2.3",
38
- "tsdown": "^0.19.0",
39
- "ultracite": "7.0.11",
40
- "unocss": "^66.3.3",
41
- "vite": "^7.3.0",
42
- "vite-plugin-solid": "^2.11.10",
43
- "vite-plugin-solid-pages": "^0.3.5",
44
- "vitest": "^4.0.16"
45
- },
46
46
  "keywords": [
47
47
  "solidjs",
48
48
  "solid",
@@ -58,14 +58,14 @@
58
58
  "scripts": {
59
59
  "build": "tsdown",
60
60
  "dev": "vite -c ./playground/vite.config.ts",
61
- "test": "vitest --run",
61
+ "test": "vitest run",
62
62
  "clean": "rimraf dist node_modules pnpm-lock.yaml",
63
63
  "test:ui": "vitest --ui",
64
- "lint": "pnpm ultracite check",
65
- "lint:error": "pnpm ultracite check --diagnostic-level error",
66
- "lint:fix": "pnpm ultracite fix",
67
- "type-check": "tsgo --noEmit --skipLibCheck",
68
- "bump": "pnpm type-check && pnpm test && pnpm bumpp --no-push",
69
- "prepublish": "pnpm build"
64
+ "tc": "tsgo --noEmit --skipLibCheck",
65
+ "bump": "pnpm bumpp --no-push",
66
+ "prepublish": "pnpm build",
67
+ "check": "ultracite check",
68
+ "check:error": "ultracite check --diagnostic-level error",
69
+ "fix": "ultracite fix"
70
70
  }
71
71
  }