solid-tiny-utils 0.4.2 → 0.6.0

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 (70) hide show
  1. package/dist/{chunk-ZGYORUAX.js → chunk-6G7GFZV2.js} +1 -1
  2. package/dist/{chunk-ILGNNUQK.js → chunk-6OVLJ45M.js} +5 -5
  3. package/dist/chunk-ACZGS7DG.js +72 -0
  4. package/dist/{chunk-CSAKXWF3.js → chunk-BT47ISVC.js} +2 -2
  5. package/dist/{chunk-KVG6TCSE.js → chunk-DKZ3RJJI.js} +20 -2
  6. package/dist/chunk-KFLH3AZ6.js +40 -0
  7. package/dist/{chunk-KFWZFQMB.js → chunk-KKFGUHFR.js} +1 -1
  8. package/dist/chunk-LEWF7QAQ.js +47 -0
  9. package/dist/chunk-PD6VHMH6.js +26 -0
  10. package/dist/{chunk-BGLY6NJK.js → chunk-QPEF6LHH.js} +2 -2
  11. package/dist/{chunk-PBALVUKK.js → chunk-QQVSG76Z.js} +2 -2
  12. package/dist/chunk-S7U3LZNS.js +23 -0
  13. package/dist/chunk-TDJLPDJF.js +66 -0
  14. package/dist/{chunk-OUAI75QC.js → chunk-TGWWPUWD.js} +3 -3
  15. package/dist/chunk-U5LQ2AS5.js +0 -0
  16. package/dist/{chunk-NFDGLC4A.js → chunk-WJHRONQU.js} +2 -2
  17. package/dist/{chunk-PNR5G432.js → chunk-Y4GYGFIT.js} +1 -1
  18. package/dist/{chunk-M5A3VVYI.js → chunk-YK5QQQ43.js} +1 -1
  19. package/dist/color/hex-rgb.d.ts +36 -0
  20. package/dist/color/hex-rgb.js +15 -0
  21. package/dist/color/index.d.ts +3 -0
  22. package/dist/color/index.js +30 -0
  23. package/dist/color/oklch-rgb.d.ts +49 -0
  24. package/dist/color/oklch-rgb.js +15 -0
  25. package/dist/color/validation.d.ts +26 -0
  26. package/dist/color/validation.js +18 -0
  27. package/dist/dom/css.d.ts +5 -1
  28. package/dist/dom/css.js +14 -9
  29. package/dist/dom/index.d.ts +2 -1
  30. package/dist/dom/index.js +14 -9
  31. package/dist/event/create-click-outside.js +11 -10
  32. package/dist/event/create-event-listener.js +11 -10
  33. package/dist/event/create-intersection-observer.d.ts +6 -0
  34. package/dist/event/create-intersection-observer.js +16 -0
  35. package/dist/event/create-visibility-observer.d.ts +12 -0
  36. package/dist/event/create-visibility-observer.js +16 -0
  37. package/dist/event/index.d.ts +2 -0
  38. package/dist/event/index.js +21 -12
  39. package/dist/event/make-event-listener.js +10 -9
  40. package/dist/fn/create-debounce.js +9 -8
  41. package/dist/fn/create-loop-exec.js +9 -8
  42. package/dist/fn/create-throttle.js +9 -8
  43. package/dist/fn/index.js +9 -8
  44. package/dist/index.d.ts +14 -7
  45. package/dist/index.js +72 -27
  46. package/dist/reactive/access.js +8 -7
  47. package/dist/reactive/create-debounce-watch.js +9 -8
  48. package/dist/reactive/index.js +9 -8
  49. package/dist/types/index.d.ts +1 -1
  50. package/dist/types/maybe.d.ts +2 -1
  51. package/dist/{lodash → utils}/array.js +2 -2
  52. package/dist/{lodash → utils}/async.js +1 -1
  53. package/dist/{lodash → utils}/index.d.ts +1 -0
  54. package/dist/{lodash → utils}/index.js +28 -16
  55. package/dist/{lodash → utils}/is.js +1 -1
  56. package/dist/utils/number.d.ts +113 -0
  57. package/dist/utils/number.js +14 -0
  58. package/dist/utils/object.d.ts +10 -0
  59. package/dist/utils/object.js +7 -0
  60. package/dist/utils/random.js +14 -0
  61. package/dist/{lodash → utils}/str.js +1 -1
  62. package/package.json +10 -8
  63. package/dist/lodash/random.js +0 -14
  64. /package/dist/{chunk-B6TZK2S5.js → chunk-BLX3XSA6.js} +0 -0
  65. /package/dist/{chunk-OECLQ3OT.js → chunk-LUFOWTRW.js} +0 -0
  66. /package/dist/{lodash → utils}/array.d.ts +0 -0
  67. /package/dist/{lodash → utils}/async.d.ts +0 -0
  68. /package/dist/{lodash → utils}/is.d.ts +0 -0
  69. /package/dist/{lodash → utils}/random.d.ts +0 -0
  70. /package/dist/{lodash → utils}/str.d.ts +0 -0
@@ -3,5 +3,6 @@ import { Accessor } from 'solid-js';
3
3
  type MaybeArray<T> = T | T[];
4
4
  type MaybePromise<T> = T | Promise<T>;
5
5
  type MaybeAccessor<T> = T | Accessor<T>;
6
+ type MaybeNullableAccessor<T> = T | Accessor<T | null | undefined>;
6
7
 
7
- export type { MaybeAccessor, MaybeArray, MaybePromise };
8
+ export type { MaybeAccessor, MaybeArray, MaybeNullableAccessor, MaybePromise };
@@ -3,8 +3,8 @@ import {
3
3
  iterate,
4
4
  list,
5
5
  range
6
- } from "../chunk-CSAKXWF3.js";
7
- import "../chunk-ZGYORUAX.js";
6
+ } from "../chunk-BT47ISVC.js";
7
+ import "../chunk-6G7GFZV2.js";
8
8
  export {
9
9
  clearArray,
10
10
  iterate,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  sleep
3
- } from "../chunk-KFWZFQMB.js";
3
+ } from "../chunk-KKFGUHFR.js";
4
4
  export {
5
5
  sleep
6
6
  };
@@ -1,5 +1,6 @@
1
1
  export { clearArray, iterate, list, range } from './array.js';
2
2
  export { sleep } from './async.js';
3
3
  export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './is.js';
4
+ export { clamp, inRange, max, min, toHex } from './number.js';
4
5
  export { draw, random, shuffle, uid } from './random.js';
5
6
  export { camel, capitalize, dash, pascal, snake, template, title, trim } from './str.js';
@@ -1,19 +1,29 @@
1
- import "../chunk-OECLQ3OT.js";
2
- import {
3
- sleep
4
- } from "../chunk-KFWZFQMB.js";
1
+ import "../chunk-U5LQ2AS5.js";
5
2
  import {
6
3
  draw,
7
4
  random,
8
5
  shuffle,
9
6
  uid
10
- } from "../chunk-PBALVUKK.js";
7
+ } from "../chunk-QQVSG76Z.js";
8
+ import {
9
+ camel,
10
+ capitalize,
11
+ dash,
12
+ pascal,
13
+ snake,
14
+ template,
15
+ title,
16
+ trim
17
+ } from "../chunk-Y4GYGFIT.js";
11
18
  import {
12
19
  clearArray,
13
20
  iterate,
14
21
  list,
15
22
  range
16
- } from "../chunk-CSAKXWF3.js";
23
+ } from "../chunk-BT47ISVC.js";
24
+ import {
25
+ sleep
26
+ } from "../chunk-KKFGUHFR.js";
17
27
  import {
18
28
  isArray,
19
29
  isClient,
@@ -28,23 +38,22 @@ import {
28
38
  isPromise,
29
39
  isString,
30
40
  isSymbol
31
- } from "../chunk-ZGYORUAX.js";
41
+ } from "../chunk-6G7GFZV2.js";
32
42
  import {
33
- camel,
34
- capitalize,
35
- dash,
36
- pascal,
37
- snake,
38
- template,
39
- title,
40
- trim
41
- } from "../chunk-PNR5G432.js";
43
+ clamp,
44
+ inRange,
45
+ max,
46
+ min,
47
+ toHex
48
+ } from "../chunk-PD6VHMH6.js";
42
49
  export {
43
50
  camel,
44
51
  capitalize,
52
+ clamp,
45
53
  clearArray,
46
54
  dash,
47
55
  draw,
56
+ inRange,
48
57
  isArray,
49
58
  isClient,
50
59
  isDate,
@@ -60,6 +69,8 @@ export {
60
69
  isSymbol,
61
70
  iterate,
62
71
  list,
72
+ max,
73
+ min,
63
74
  pascal,
64
75
  random,
65
76
  range,
@@ -68,6 +79,7 @@ export {
68
79
  snake,
69
80
  template,
70
81
  title,
82
+ toHex,
71
83
  trim,
72
84
  uid
73
85
  };
@@ -12,7 +12,7 @@ import {
12
12
  isPromise,
13
13
  isString,
14
14
  isSymbol
15
- } from "../chunk-ZGYORUAX.js";
15
+ } from "../chunk-6G7GFZV2.js";
16
16
  export {
17
17
  isArray,
18
18
  isClient,
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Returns the smallest of the given numbers.
3
+ *
4
+ * This is a convenience wrapper around `Math.min` that provides better type safety
5
+ * and consistency with other utility functions.
6
+ *
7
+ * @param numbers - The numbers to compare
8
+ * @returns The smallest number from the input
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * min(1, 2, 3) // => 1
13
+ * min(-5, 0, 10) // => -5
14
+ * min(3.14, 2.71, 1.41) // => 1.41
15
+ * ```
16
+ */
17
+ declare function min(...numbers: number[]): number;
18
+ /**
19
+ * Returns the largest of the given numbers.
20
+ *
21
+ * This is a convenience wrapper around `Math.max` that provides better type safety
22
+ * and consistency with other utility functions.
23
+ *
24
+ * @param numbers - The numbers to compare
25
+ * @returns The largest number from the input
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * max(1, 2, 3) // => 3
30
+ * max(-5, 0, 10) // => 10
31
+ * max(3.14, 2.71, 1.41) // => 3.14
32
+ * ```
33
+ */
34
+ declare function max(...numbers: number[]): number;
35
+ /**
36
+ * Clamps a number to within the specified bounds.
37
+ *
38
+ * If the number is less than the minimum, returns the minimum.
39
+ * If the number is greater than the maximum, returns the maximum.
40
+ * Otherwise, returns the number unchanged.
41
+ *
42
+ * @param x - The number to clamp
43
+ * @param minimum - The lower bound (inclusive)
44
+ * @param maximum - The upper bound (inclusive)
45
+ * @returns The clamped number
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * clamp(0.5) // => 0.5 (within default 0-1 range)
50
+ * clamp(-0.1) // => 0 (clamped to minimum)
51
+ * clamp(1.5) // => 1 (clamped to maximum)
52
+ * clamp(15, 10, 20) // => 15 (within range)
53
+ * clamp(5, 10, 20) // => 10 (clamped to minimum)
54
+ * clamp(25, 10, 20) // => 20 (clamped to maximum)
55
+ * ```
56
+ */
57
+ declare function clamp(x: number, minimum?: number, maximum?: number): number;
58
+ /**
59
+ * Checks if a number is within a specified range.
60
+ *
61
+ * Supports different inclusivity modes:
62
+ * - `'[]'` - Both bounds inclusive (default): `minimum ≤ x ≤ maximum`
63
+ * - `'()'` - Both bounds exclusive: `minimum < x < maximum`
64
+ * - `'[)'` - Lower inclusive, upper exclusive: `minimum ≤ x < maximum`
65
+ * - `'(]'` - Lower exclusive, upper inclusive: `minimum < x ≤ maximum`
66
+ *
67
+ * @param x - The number to check
68
+ * @param minimum - The lower bound of the range
69
+ * @param maximum - The upper bound of the range
70
+ * @param inclusivity - Specifies whether the bounds are inclusive or exclusive
71
+ * @returns `true` if the number is within the range, `false` otherwise
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Default inclusive range [0, 1]
76
+ * inRange(0.5) // => true
77
+ * inRange(0) // => true (inclusive)
78
+ * inRange(1) // => true (inclusive)
79
+ * inRange(-0.1) // => false
80
+ * inRange(1.1) // => false
81
+ *
82
+ * // Custom range [10, 20]
83
+ * inRange(15, 10, 20) // => true
84
+ * inRange(10, 10, 20) // => true (inclusive)
85
+ * inRange(20, 10, 20) // => true (inclusive)
86
+ *
87
+ * // Exclusive bounds (10, 20)
88
+ * inRange(15, 10, 20, '()') // => true
89
+ * inRange(10, 10, 20, '()') // => false (exclusive)
90
+ * inRange(20, 10, 20, '()') // => false (exclusive)
91
+ *
92
+ * // Mixed inclusivity [10, 20)
93
+ * inRange(10, 10, 20, '[)') // => true (lower inclusive)
94
+ * inRange(20, 10, 20, '[)') // => false (upper exclusive)
95
+ * ```
96
+ */
97
+ declare function inRange(x: number, minimum?: number, maximum?: number, inclusivity?: '()' | '[]' | '[)' | '(]'): boolean;
98
+ /**
99
+ * Converts a number to a hexadecimal string.
100
+ *
101
+ * @param x - The number to convert
102
+ * @param pad - The number of digits to pad the output with (default: 2)
103
+ * @returns The hexadecimal representation of the number
104
+ *
105
+ * @example
106
+ * ```typescript
107
+ * toHEX(255) // => "ff"
108
+ * toHEX(255, 4) // => "00ff"
109
+ * ```
110
+ */
111
+ declare function toHex(x: number, pad?: number): string;
112
+
113
+ export { clamp, inRange, max, min, toHex };
@@ -0,0 +1,14 @@
1
+ import {
2
+ clamp,
3
+ inRange,
4
+ max,
5
+ min,
6
+ toHex
7
+ } from "../chunk-PD6VHMH6.js";
8
+ export {
9
+ clamp,
10
+ inRange,
11
+ max,
12
+ min,
13
+ toHex
14
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Get entries of an object
3
+ */
4
+ declare const entries: <T extends object>(obj: T) => [keyof T, T[keyof T]][];
5
+ /**
6
+ * Get keys of an object
7
+ */
8
+ declare const keys: <T extends object>(object: T) => (keyof T)[];
9
+
10
+ export { entries, keys };
@@ -0,0 +1,7 @@
1
+ // src/utils/object.ts
2
+ var entries = Object.entries;
3
+ var keys = Object.keys;
4
+ export {
5
+ entries,
6
+ keys
7
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ draw,
3
+ random,
4
+ shuffle,
5
+ uid
6
+ } from "../chunk-QQVSG76Z.js";
7
+ import "../chunk-BT47ISVC.js";
8
+ import "../chunk-6G7GFZV2.js";
9
+ export {
10
+ draw,
11
+ random,
12
+ shuffle,
13
+ uid
14
+ };
@@ -7,7 +7,7 @@ import {
7
7
  template,
8
8
  title,
9
9
  trim
10
- } from "../chunk-PNR5G432.js";
10
+ } from "../chunk-Y4GYGFIT.js";
11
11
  export {
12
12
  camel,
13
13
  capitalize,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-tiny-utils",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "A collection of tiny utilities for SolidJS applications",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",
@@ -12,21 +12,25 @@
12
12
  "solid-js": "^1.9.7"
13
13
  },
14
14
  "devDependencies": {
15
- "@biomejs/biome": "2.1.2",
15
+ "@biomejs/biome": "2.2.0",
16
+ "@solidjs/router": "^0.15.3",
16
17
  "@solidjs/testing-library": "^0.8.10",
17
18
  "@testing-library/jest-dom": "^6.6.4",
18
19
  "@testing-library/user-event": "^14.6.1",
20
+ "@types/culori": "^4.0.0",
19
21
  "@types/node": "^24.2.1",
20
22
  "@vitest/ui": "^3.2.4",
21
23
  "commit-and-tag-version": "^12.5.1",
24
+ "culori": "^4.0.2",
22
25
  "husky": "^9.1.7",
23
26
  "jsdom": "^26.1.0",
24
27
  "tsup": "^8.5.0",
25
28
  "typescript": "^5.8.3",
26
- "ultracite": "5.1.2",
29
+ "ultracite": "5.2.2",
27
30
  "unocss": "^66.3.3",
28
31
  "vite": "^6.2.1",
29
32
  "vite-plugin-solid": "^2.11.0",
33
+ "vite-plugin-solid-pages": "^0.3.4",
30
34
  "vitest": "^3.2.4"
31
35
  },
32
36
  "keywords": [
@@ -44,16 +48,14 @@
44
48
  },
45
49
  "scripts": {
46
50
  "build": "tsup",
47
- "dev": "vite",
48
- "test": "vitest",
51
+ "dev": "vite -c ./playground/vite.config.ts",
52
+ "test": "vitest --run",
49
53
  "clean": "rimraf dist node_modules pnpm-lock.yaml",
50
- "test:run": "vitest --run",
51
54
  "test:ui": "vitest --ui",
52
- "test:coverage": "vitest --coverage",
53
55
  "lint": "npx ultracite lint",
54
56
  "lint:fix": "npx ultracite format",
55
57
  "type-check": "tsc --noEmit --skipLibCheck",
56
- "release": "pnpm type-check && pnpm lint:fix && pnpm test:run && commit-and-tag-version -i CHANGELOG.md --same-file",
58
+ "release": "pnpm type-check && pnpm lint:fix && pnpm test && commit-and-tag-version -i CHANGELOG.md --same-file",
57
59
  "pub": "pnpm build && pnpm publish"
58
60
  }
59
61
  }
@@ -1,14 +0,0 @@
1
- import {
2
- draw,
3
- random,
4
- shuffle,
5
- uid
6
- } from "../chunk-PBALVUKK.js";
7
- import "../chunk-CSAKXWF3.js";
8
- import "../chunk-ZGYORUAX.js";
9
- export {
10
- draw,
11
- random,
12
- shuffle,
13
- uid
14
- };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes