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.
- package/dist/{chunk-ZGYORUAX.js → chunk-6G7GFZV2.js} +1 -1
- package/dist/{chunk-ILGNNUQK.js → chunk-6OVLJ45M.js} +5 -5
- package/dist/chunk-ACZGS7DG.js +72 -0
- package/dist/{chunk-CSAKXWF3.js → chunk-BT47ISVC.js} +2 -2
- package/dist/{chunk-KVG6TCSE.js → chunk-DKZ3RJJI.js} +20 -2
- package/dist/chunk-KFLH3AZ6.js +40 -0
- package/dist/{chunk-KFWZFQMB.js → chunk-KKFGUHFR.js} +1 -1
- package/dist/chunk-LEWF7QAQ.js +47 -0
- package/dist/chunk-PD6VHMH6.js +26 -0
- package/dist/{chunk-BGLY6NJK.js → chunk-QPEF6LHH.js} +2 -2
- package/dist/{chunk-PBALVUKK.js → chunk-QQVSG76Z.js} +2 -2
- package/dist/chunk-S7U3LZNS.js +23 -0
- package/dist/chunk-TDJLPDJF.js +66 -0
- package/dist/{chunk-OUAI75QC.js → chunk-TGWWPUWD.js} +3 -3
- package/dist/chunk-U5LQ2AS5.js +0 -0
- package/dist/{chunk-NFDGLC4A.js → chunk-WJHRONQU.js} +2 -2
- package/dist/{chunk-PNR5G432.js → chunk-Y4GYGFIT.js} +1 -1
- package/dist/{chunk-M5A3VVYI.js → chunk-YK5QQQ43.js} +1 -1
- package/dist/color/hex-rgb.d.ts +36 -0
- package/dist/color/hex-rgb.js +15 -0
- package/dist/color/index.d.ts +3 -0
- package/dist/color/index.js +30 -0
- package/dist/color/oklch-rgb.d.ts +49 -0
- package/dist/color/oklch-rgb.js +15 -0
- package/dist/color/validation.d.ts +26 -0
- package/dist/color/validation.js +18 -0
- package/dist/dom/css.d.ts +5 -1
- package/dist/dom/css.js +14 -9
- package/dist/dom/index.d.ts +2 -1
- package/dist/dom/index.js +14 -9
- package/dist/event/create-click-outside.js +11 -10
- package/dist/event/create-event-listener.js +11 -10
- package/dist/event/create-intersection-observer.d.ts +6 -0
- package/dist/event/create-intersection-observer.js +16 -0
- package/dist/event/create-visibility-observer.d.ts +12 -0
- package/dist/event/create-visibility-observer.js +16 -0
- package/dist/event/index.d.ts +2 -0
- package/dist/event/index.js +21 -12
- package/dist/event/make-event-listener.js +10 -9
- package/dist/fn/create-debounce.js +9 -8
- package/dist/fn/create-loop-exec.js +9 -8
- package/dist/fn/create-throttle.js +9 -8
- package/dist/fn/index.js +9 -8
- package/dist/index.d.ts +14 -7
- package/dist/index.js +72 -27
- package/dist/reactive/access.js +8 -7
- package/dist/reactive/create-debounce-watch.js +9 -8
- package/dist/reactive/index.js +9 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/types/maybe.d.ts +2 -1
- package/dist/{lodash → utils}/array.js +2 -2
- package/dist/{lodash → utils}/async.js +1 -1
- package/dist/{lodash → utils}/index.d.ts +1 -0
- package/dist/{lodash → utils}/index.js +28 -16
- package/dist/{lodash → utils}/is.js +1 -1
- package/dist/utils/number.d.ts +113 -0
- package/dist/utils/number.js +14 -0
- package/dist/utils/object.d.ts +10 -0
- package/dist/utils/object.js +7 -0
- package/dist/utils/random.js +14 -0
- package/dist/{lodash → utils}/str.js +1 -1
- package/package.json +10 -8
- package/dist/lodash/random.js +0 -14
- /package/dist/{chunk-B6TZK2S5.js → chunk-BLX3XSA6.js} +0 -0
- /package/dist/{chunk-OECLQ3OT.js → chunk-LUFOWTRW.js} +0 -0
- /package/dist/{lodash → utils}/array.d.ts +0 -0
- /package/dist/{lodash → utils}/async.d.ts +0 -0
- /package/dist/{lodash → utils}/is.d.ts +0 -0
- /package/dist/{lodash → utils}/random.d.ts +0 -0
- /package/dist/{lodash → utils}/str.d.ts +0 -0
package/dist/types/maybe.d.ts
CHANGED
|
@@ -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 };
|
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
41
|
+
} from "../chunk-6G7GFZV2.js";
|
|
32
42
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
};
|
|
@@ -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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-tiny-utils",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
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.
|
|
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
|
|
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
|
}
|
package/dist/lodash/random.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|