solid-tiny-utils 0.0.1 → 0.2.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-2BGAGVTR.js +7 -0
- package/dist/chunk-FFBJP5FE.js +0 -0
- package/dist/{chunk-WAZBT4BV.js → chunk-H6VUVMSF.js} +1 -1
- package/dist/chunk-KVG6TCSE.js +28 -0
- package/dist/chunk-M53KPXWR.js +0 -0
- package/dist/{chunk-7K22IJFO.js → chunk-M5A3VVYI.js} +1 -1
- package/dist/chunk-RRYFZNKE.js +36 -0
- package/dist/chunk-WLQ64SAO.js +32 -0
- package/dist/{chunk-ZHWDHAF3.js → chunk-WY5G2PJM.js} +7 -3
- package/dist/chunk-YJB637I2.js +29 -0
- package/dist/chunk-ZGYORUAX.js +93 -0
- package/dist/dom/css.d.ts +13 -0
- package/dist/dom/css.js +10 -0
- package/dist/dom/index.d.ts +1 -0
- package/dist/dom/index.js +11 -0
- package/dist/event/create-click-outside.d.ts +8 -0
- package/dist/event/create-click-outside.js +13 -0
- package/dist/event/index.d.ts +3 -0
- package/dist/event/index.js +14 -0
- package/dist/fn/create-debounce.js +6 -3
- package/dist/fn/create-loop-exec.d.ts +2 -1
- package/dist/fn/create-loop-exec.js +6 -3
- package/dist/fn/index.d.ts +4 -0
- package/dist/fn/index.js +12 -6
- package/dist/index.d.ts +8 -3
- package/dist/index.js +63 -9
- package/dist/lodash/array.d.ts +42 -0
- package/dist/lodash/array.js +11 -0
- package/dist/lodash/index.d.ts +3 -0
- package/dist/lodash/index.js +49 -0
- package/dist/lodash/is.d.ts +28 -0
- package/dist/lodash/is.js +30 -0
- package/dist/lodash/random.d.ts +13 -0
- package/dist/lodash/random.js +14 -0
- package/dist/reactive/access.js +5 -2
- package/dist/reactive/index.js +5 -2
- package/package.json +8 -2
- package/dist/chunk-PEWQLY2D.js +0 -12
- package/dist/is/index.d.ts +0 -4
- package/dist/is/index.js +0 -8
- /package/dist/{chunk-QKJKTJQE.js → chunk-33ZRZ4S2.js} +0 -0
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClient
|
|
3
|
+
} from "./chunk-ZGYORUAX.js";
|
|
4
|
+
|
|
5
|
+
// src/dom/css.ts
|
|
6
|
+
var alreadyInjected = [];
|
|
7
|
+
function mountStyle(style, id, refresh = false) {
|
|
8
|
+
if (!isClient) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (alreadyInjected.includes(id) && !refresh) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let styleElement = document.querySelector(`style#${id}`);
|
|
15
|
+
if (styleElement) {
|
|
16
|
+
styleElement.innerHTML = style;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
styleElement = document.createElement("style");
|
|
20
|
+
styleElement.id = id;
|
|
21
|
+
styleElement.innerHTML = style;
|
|
22
|
+
document.head.appendChild(styleElement);
|
|
23
|
+
alreadyInjected.push(id);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
mountStyle
|
|
28
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
iterate
|
|
3
|
+
} from "./chunk-WLQ64SAO.js";
|
|
4
|
+
|
|
5
|
+
// src/lodash/random.ts
|
|
6
|
+
var random = (min, max) => {
|
|
7
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
8
|
+
};
|
|
9
|
+
var draw = (array) => {
|
|
10
|
+
const max = array.length;
|
|
11
|
+
if (max === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const index = random(0, max - 1);
|
|
15
|
+
return array[index];
|
|
16
|
+
};
|
|
17
|
+
var shuffle = (array) => {
|
|
18
|
+
return array.map((a) => ({ rand: Math.random(), value: a })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
|
|
19
|
+
};
|
|
20
|
+
var uid = (length, specials = "") => {
|
|
21
|
+
const characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789${specials}`;
|
|
22
|
+
return iterate(
|
|
23
|
+
length,
|
|
24
|
+
(acc) => {
|
|
25
|
+
return acc + characters.charAt(random(0, characters.length - 1));
|
|
26
|
+
},
|
|
27
|
+
""
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
random,
|
|
33
|
+
draw,
|
|
34
|
+
shuffle,
|
|
35
|
+
uid
|
|
36
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isFn
|
|
3
|
+
} from "./chunk-ZGYORUAX.js";
|
|
4
|
+
|
|
5
|
+
// src/lodash/array.ts
|
|
6
|
+
var iterate = (count, func, initValue) => {
|
|
7
|
+
let value = initValue;
|
|
8
|
+
for (let i = 1; i <= count; i++) {
|
|
9
|
+
value = func(value, i);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
14
|
+
const mapper = isFn(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
15
|
+
const start = end ? startOrLength : 0;
|
|
16
|
+
const final = end ?? startOrLength;
|
|
17
|
+
for (let i = start; i <= final; i += step) {
|
|
18
|
+
yield mapper(i);
|
|
19
|
+
if (i + step > final) {
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var list = (startOrLength, end, valueOrMapper, step) => {
|
|
25
|
+
return Array.from(range(startOrLength, end, valueOrMapper, step));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
iterate,
|
|
30
|
+
range,
|
|
31
|
+
list
|
|
32
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
access
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-M5A3VVYI.js";
|
|
4
4
|
import {
|
|
5
5
|
createWatch
|
|
6
6
|
} from "./chunk-4L6FK7MF.js";
|
|
7
|
+
import {
|
|
8
|
+
isNumber
|
|
9
|
+
} from "./chunk-ZGYORUAX.js";
|
|
7
10
|
|
|
8
11
|
// src/fn/create-loop-exec.ts
|
|
9
12
|
import { onCleanup } from "solid-js";
|
|
@@ -13,7 +16,8 @@ function createLoopExec(fn, delay) {
|
|
|
13
16
|
let timer;
|
|
14
17
|
const execFn = async () => {
|
|
15
18
|
clearTimeout(timer);
|
|
16
|
-
|
|
19
|
+
const d = access(delay);
|
|
20
|
+
if (shouldStop || !isNumber(d) || d < 0) {
|
|
17
21
|
return;
|
|
18
22
|
}
|
|
19
23
|
try {
|
|
@@ -21,7 +25,7 @@ function createLoopExec(fn, delay) {
|
|
|
21
25
|
} finally {
|
|
22
26
|
timer = setTimeout(() => {
|
|
23
27
|
execFn();
|
|
24
|
-
},
|
|
28
|
+
}, d);
|
|
25
29
|
}
|
|
26
30
|
};
|
|
27
31
|
createWatch(
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
access
|
|
3
|
+
} from "./chunk-M5A3VVYI.js";
|
|
4
|
+
|
|
5
|
+
// src/event/create-click-outside.ts
|
|
6
|
+
import { makeEventListener } from "@solid-primitives/event-listener";
|
|
7
|
+
function createClickOutside(target, handler, options) {
|
|
8
|
+
const listener = (e) => {
|
|
9
|
+
const el = access(target);
|
|
10
|
+
if (!el || el.contains(e.target)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (options?.ignore) {
|
|
14
|
+
for (const item of options.ignore) {
|
|
15
|
+
const ignoreEl = access(item);
|
|
16
|
+
if (ignoreEl && (ignoreEl === e.target || ignoreEl.contains(e.target))) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
handler(e);
|
|
22
|
+
};
|
|
23
|
+
makeEventListener(document, "click", listener);
|
|
24
|
+
makeEventListener(document, "touchstart", listener);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
createClickOutside
|
|
29
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// src/lodash/is.ts
|
|
2
|
+
import { isServer } from "solid-js/web";
|
|
3
|
+
var isSymbol = (value) => {
|
|
4
|
+
return !!value && value.constructor === Symbol;
|
|
5
|
+
};
|
|
6
|
+
var isArray = Array.isArray;
|
|
7
|
+
var isObject = (value) => {
|
|
8
|
+
return !!value && value.constructor === Object;
|
|
9
|
+
};
|
|
10
|
+
var isPrimitive = (value) => {
|
|
11
|
+
return value === void 0 || value === null || typeof value !== "object" && typeof value !== "function";
|
|
12
|
+
};
|
|
13
|
+
var isFn = (value) => {
|
|
14
|
+
return !!(value && value.constructor && value.call && value.apply);
|
|
15
|
+
};
|
|
16
|
+
var isString = (value) => {
|
|
17
|
+
return typeof value === "string" || value instanceof String;
|
|
18
|
+
};
|
|
19
|
+
var isInt = (value) => {
|
|
20
|
+
return isNumber(value) && value % 1 === 0;
|
|
21
|
+
};
|
|
22
|
+
var isFloat = (value) => {
|
|
23
|
+
return isNumber(value) && value % 1 !== 0;
|
|
24
|
+
};
|
|
25
|
+
var isNumber = (value) => {
|
|
26
|
+
try {
|
|
27
|
+
return Number(value) === value;
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var isDate = (value) => {
|
|
33
|
+
return Object.prototype.toString.call(value) === "[object Date]";
|
|
34
|
+
};
|
|
35
|
+
var isPromise = (value) => {
|
|
36
|
+
if (!value) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!value.then) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!isFn(value.then)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
var isEmpty = (value) => {
|
|
48
|
+
if (value === true || value === false) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (value === null || value === void 0) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
if (isNumber(value)) {
|
|
55
|
+
return value === 0;
|
|
56
|
+
}
|
|
57
|
+
if (isDate(value)) {
|
|
58
|
+
return isNaN(value.getTime());
|
|
59
|
+
}
|
|
60
|
+
if (isFn(value)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (isSymbol(value)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const length = value.length;
|
|
67
|
+
if (isNumber(length)) {
|
|
68
|
+
return length === 0;
|
|
69
|
+
}
|
|
70
|
+
const size = value.size;
|
|
71
|
+
if (isNumber(size)) {
|
|
72
|
+
return size === 0;
|
|
73
|
+
}
|
|
74
|
+
const keys = Object.keys(value).length;
|
|
75
|
+
return keys === 0;
|
|
76
|
+
};
|
|
77
|
+
var isClient = !isServer;
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
isSymbol,
|
|
81
|
+
isArray,
|
|
82
|
+
isObject,
|
|
83
|
+
isPrimitive,
|
|
84
|
+
isFn,
|
|
85
|
+
isString,
|
|
86
|
+
isInt,
|
|
87
|
+
isFloat,
|
|
88
|
+
isNumber,
|
|
89
|
+
isDate,
|
|
90
|
+
isPromise,
|
|
91
|
+
isEmpty,
|
|
92
|
+
isClient
|
|
93
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mounts a style element to the document head.
|
|
3
|
+
* If the style element with the given id already exists, it updates its content.
|
|
4
|
+
* If `refresh` is true, it will update the style even if it has already been injected.
|
|
5
|
+
* Note: This function should only be called in a client environment or `onMount`
|
|
6
|
+
*
|
|
7
|
+
* @param style - The CSS style to inject.
|
|
8
|
+
* @param id - The id of the style element.
|
|
9
|
+
* @param refresh - Whether to refresh the style if it already exists. Defaults to **false**.
|
|
10
|
+
*/
|
|
11
|
+
declare function mountStyle(style: string, id: string, refresh?: boolean): void;
|
|
12
|
+
|
|
13
|
+
export { mountStyle };
|
package/dist/dom/css.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { mountStyle } from './css.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MaybeAccessor } from '../types/maybe.js';
|
|
2
|
+
import 'solid-js';
|
|
3
|
+
|
|
4
|
+
declare function createClickOutside(target: MaybeAccessor<HTMLElement | null | undefined>, handler: (event: MouseEvent | TouchEvent) => void, options?: {
|
|
5
|
+
ignore?: MaybeAccessor<HTMLElement | null | undefined>[];
|
|
6
|
+
}): void;
|
|
7
|
+
|
|
8
|
+
export { createClickOutside };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createClickOutside
|
|
3
|
+
} from "../chunk-YJB637I2.js";
|
|
4
|
+
import "../chunk-ZZNAXGNU.js";
|
|
5
|
+
import "../chunk-M5A3VVYI.js";
|
|
6
|
+
import "../chunk-4L6FK7MF.js";
|
|
7
|
+
import "../chunk-33ZRZ4S2.js";
|
|
8
|
+
import "../chunk-RRYFZNKE.js";
|
|
9
|
+
import "../chunk-WLQ64SAO.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
11
|
+
export {
|
|
12
|
+
createClickOutside
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "../chunk-M53KPXWR.js";
|
|
2
|
+
import {
|
|
3
|
+
createClickOutside
|
|
4
|
+
} from "../chunk-YJB637I2.js";
|
|
5
|
+
import "../chunk-ZZNAXGNU.js";
|
|
6
|
+
import "../chunk-M5A3VVYI.js";
|
|
7
|
+
import "../chunk-4L6FK7MF.js";
|
|
8
|
+
import "../chunk-33ZRZ4S2.js";
|
|
9
|
+
import "../chunk-RRYFZNKE.js";
|
|
10
|
+
import "../chunk-WLQ64SAO.js";
|
|
11
|
+
import "../chunk-ZGYORUAX.js";
|
|
12
|
+
export {
|
|
13
|
+
createClickOutside
|
|
14
|
+
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createDebounce
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-H6VUVMSF.js";
|
|
4
4
|
import "../chunk-ZZNAXGNU.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-PEWQLY2D.js";
|
|
5
|
+
import "../chunk-M5A3VVYI.js";
|
|
7
6
|
import "../chunk-4L6FK7MF.js";
|
|
7
|
+
import "../chunk-33ZRZ4S2.js";
|
|
8
|
+
import "../chunk-RRYFZNKE.js";
|
|
9
|
+
import "../chunk-WLQ64SAO.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
8
11
|
export {
|
|
9
12
|
createDebounce
|
|
10
13
|
};
|
|
@@ -7,13 +7,14 @@ import 'solid-js';
|
|
|
7
7
|
*
|
|
8
8
|
* @param fn - The asynchronous function to execute in a loop. Can return a promise or void.
|
|
9
9
|
* @param delay - The delay (in milliseconds) between each execution. Can be a number or a reactive accessor.
|
|
10
|
+
* If `false` or < 0, the loop will not execute.
|
|
10
11
|
*
|
|
11
12
|
* @remarks
|
|
12
13
|
* - The loop is automatically stopped when cleanup.
|
|
13
14
|
* - `fn`'s error will not stop scheduling.
|
|
14
15
|
* - Uses `setTimeout` for scheduling and `onCleanup` for resource management.
|
|
15
16
|
*/
|
|
16
|
-
declare function createLoopExec(fn: () => MaybePromise<void>, delay: MaybeAccessor<number>): {
|
|
17
|
+
declare function createLoopExec(fn: () => MaybePromise<void>, delay: MaybeAccessor<number | false>): {
|
|
17
18
|
stop: () => void;
|
|
18
19
|
start: () => void;
|
|
19
20
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createLoopExec
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-WY5G2PJM.js";
|
|
4
4
|
import "../chunk-ZZNAXGNU.js";
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-PEWQLY2D.js";
|
|
5
|
+
import "../chunk-M5A3VVYI.js";
|
|
7
6
|
import "../chunk-4L6FK7MF.js";
|
|
7
|
+
import "../chunk-33ZRZ4S2.js";
|
|
8
|
+
import "../chunk-RRYFZNKE.js";
|
|
9
|
+
import "../chunk-WLQ64SAO.js";
|
|
10
|
+
import "../chunk-ZGYORUAX.js";
|
|
8
11
|
export {
|
|
9
12
|
createLoopExec
|
|
10
13
|
};
|
package/dist/fn/index.d.ts
CHANGED
package/dist/fn/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
noop
|
|
3
|
+
} from "../chunk-2BGAGVTR.js";
|
|
2
4
|
import {
|
|
3
5
|
createDebounce
|
|
4
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-H6VUVMSF.js";
|
|
5
7
|
import {
|
|
6
8
|
createLoopExec
|
|
7
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-WY5G2PJM.js";
|
|
8
10
|
import "../chunk-ZZNAXGNU.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-PEWQLY2D.js";
|
|
11
|
+
import "../chunk-M5A3VVYI.js";
|
|
11
12
|
import "../chunk-4L6FK7MF.js";
|
|
13
|
+
import "../chunk-33ZRZ4S2.js";
|
|
14
|
+
import "../chunk-RRYFZNKE.js";
|
|
15
|
+
import "../chunk-WLQ64SAO.js";
|
|
16
|
+
import "../chunk-ZGYORUAX.js";
|
|
12
17
|
export {
|
|
13
18
|
createDebounce,
|
|
14
|
-
createLoopExec
|
|
19
|
+
createLoopExec,
|
|
20
|
+
noop
|
|
15
21
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { mountStyle } from './dom/css.js';
|
|
2
|
+
export { createClickOutside } from './event/create-click-outside.js';
|
|
3
|
+
export { noop } from './fn/index.js';
|
|
4
|
+
export { iterate, list, range } from './lodash/array.js';
|
|
5
|
+
export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './lodash/is.js';
|
|
6
|
+
export { draw, random, shuffle, uid } from './lodash/random.js';
|
|
4
7
|
export { access } from './reactive/access.js';
|
|
5
8
|
export { createWatch } from './reactive/create-watch.js';
|
|
6
9
|
export { MaybeAccessor, MaybeArray, MaybePromise } from './types/maybe.js';
|
|
10
|
+
export { createDebounce } from './fn/create-debounce.js';
|
|
11
|
+
export { createLoopExec } from './fn/create-loop-exec.js';
|
|
7
12
|
import 'solid-js';
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,82 @@
|
|
|
1
1
|
import "./chunk-2BUPSB7O.js";
|
|
2
2
|
import "./chunk-EZML2DEC.js";
|
|
3
|
-
import "./chunk-
|
|
3
|
+
import "./chunk-FFBJP5FE.js";
|
|
4
|
+
import {
|
|
5
|
+
mountStyle
|
|
6
|
+
} from "./chunk-KVG6TCSE.js";
|
|
7
|
+
import "./chunk-M53KPXWR.js";
|
|
8
|
+
import {
|
|
9
|
+
createClickOutside
|
|
10
|
+
} from "./chunk-YJB637I2.js";
|
|
11
|
+
import {
|
|
12
|
+
noop
|
|
13
|
+
} from "./chunk-2BGAGVTR.js";
|
|
4
14
|
import {
|
|
5
15
|
createDebounce
|
|
6
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-H6VUVMSF.js";
|
|
7
17
|
import {
|
|
8
18
|
createLoopExec
|
|
9
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-WY5G2PJM.js";
|
|
10
20
|
import "./chunk-ZZNAXGNU.js";
|
|
11
21
|
import {
|
|
12
22
|
access
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import {
|
|
15
|
-
isArray,
|
|
16
|
-
isFn
|
|
17
|
-
} from "./chunk-PEWQLY2D.js";
|
|
23
|
+
} from "./chunk-M5A3VVYI.js";
|
|
18
24
|
import {
|
|
19
25
|
createWatch
|
|
20
26
|
} from "./chunk-4L6FK7MF.js";
|
|
27
|
+
import "./chunk-33ZRZ4S2.js";
|
|
28
|
+
import {
|
|
29
|
+
draw,
|
|
30
|
+
random,
|
|
31
|
+
shuffle,
|
|
32
|
+
uid
|
|
33
|
+
} from "./chunk-RRYFZNKE.js";
|
|
34
|
+
import {
|
|
35
|
+
iterate,
|
|
36
|
+
list,
|
|
37
|
+
range
|
|
38
|
+
} from "./chunk-WLQ64SAO.js";
|
|
39
|
+
import {
|
|
40
|
+
isArray,
|
|
41
|
+
isClient,
|
|
42
|
+
isDate,
|
|
43
|
+
isEmpty,
|
|
44
|
+
isFloat,
|
|
45
|
+
isFn,
|
|
46
|
+
isInt,
|
|
47
|
+
isNumber,
|
|
48
|
+
isObject,
|
|
49
|
+
isPrimitive,
|
|
50
|
+
isPromise,
|
|
51
|
+
isString,
|
|
52
|
+
isSymbol
|
|
53
|
+
} from "./chunk-ZGYORUAX.js";
|
|
21
54
|
export {
|
|
22
55
|
access,
|
|
56
|
+
createClickOutside,
|
|
23
57
|
createDebounce,
|
|
24
58
|
createLoopExec,
|
|
25
59
|
createWatch,
|
|
60
|
+
draw,
|
|
26
61
|
isArray,
|
|
27
|
-
|
|
62
|
+
isClient,
|
|
63
|
+
isDate,
|
|
64
|
+
isEmpty,
|
|
65
|
+
isFloat,
|
|
66
|
+
isFn,
|
|
67
|
+
isInt,
|
|
68
|
+
isNumber,
|
|
69
|
+
isObject,
|
|
70
|
+
isPrimitive,
|
|
71
|
+
isPromise,
|
|
72
|
+
isString,
|
|
73
|
+
isSymbol,
|
|
74
|
+
iterate,
|
|
75
|
+
list,
|
|
76
|
+
mountStyle,
|
|
77
|
+
noop,
|
|
78
|
+
random,
|
|
79
|
+
range,
|
|
80
|
+
shuffle,
|
|
81
|
+
uid
|
|
28
82
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Like a reduce but does not require an array.
|
|
3
|
+
* Only need a number and will iterate the function
|
|
4
|
+
* as many times as specified.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: This is NOT zero indexed. If you pass count=5
|
|
7
|
+
* you will get 1, 2, 3, 4, 5 iteration in the callback
|
|
8
|
+
* function
|
|
9
|
+
*/
|
|
10
|
+
declare const iterate: <T>(count: number, func: (currentValue: T, iteration: number) => T, initValue: T) => T;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a generator that will produce an iteration through
|
|
13
|
+
* the range of number as requested.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* range(3) // yields 0, 1, 2, 3
|
|
17
|
+
* range(0, 3) // yields 0, 1, 2, 3
|
|
18
|
+
* range(0, 3, 'y') // yields y, y, y, y
|
|
19
|
+
* range(0, 3, () => 'y') // yields y, y, y, y
|
|
20
|
+
* range(0, 3, i => i) // yields 0, 1, 2, 3
|
|
21
|
+
* range(0, 3, i => `y${i}`) // yields y0, y1, y2, y3
|
|
22
|
+
* range(0, 3, obj) // yields obj, obj, obj, obj
|
|
23
|
+
* range(0, 6, i => i, 2) // yields 0, 2, 4, 6
|
|
24
|
+
*/
|
|
25
|
+
declare function range<T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number): Generator<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a list of given start, end, value, and
|
|
28
|
+
* step parameters.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* list(3) // 0, 1, 2, 3
|
|
32
|
+
* list(0, 3) // 0, 1, 2, 3
|
|
33
|
+
* list(0, 3, 'y') // y, y, y, y
|
|
34
|
+
* list(0, 3, () => 'y') // y, y, y, y
|
|
35
|
+
* list(0, 3, i => i) // 0, 1, 2, 3
|
|
36
|
+
* list(0, 3, i => `y${i}`) // y0, y1, y2, y3
|
|
37
|
+
* list(0, 3, obj) // obj, obj, obj, obj
|
|
38
|
+
* list(0, 6, i => i, 2) // 0, 2, 4, 6
|
|
39
|
+
*/
|
|
40
|
+
declare const list: <T = number>(startOrLength: number, end?: number, valueOrMapper?: T | ((i: number) => T), step?: number) => T[];
|
|
41
|
+
|
|
42
|
+
export { iterate, list, range };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import "../chunk-33ZRZ4S2.js";
|
|
2
|
+
import {
|
|
3
|
+
draw,
|
|
4
|
+
random,
|
|
5
|
+
shuffle,
|
|
6
|
+
uid
|
|
7
|
+
} from "../chunk-RRYFZNKE.js";
|
|
8
|
+
import {
|
|
9
|
+
iterate,
|
|
10
|
+
list,
|
|
11
|
+
range
|
|
12
|
+
} from "../chunk-WLQ64SAO.js";
|
|
13
|
+
import {
|
|
14
|
+
isArray,
|
|
15
|
+
isClient,
|
|
16
|
+
isDate,
|
|
17
|
+
isEmpty,
|
|
18
|
+
isFloat,
|
|
19
|
+
isFn,
|
|
20
|
+
isInt,
|
|
21
|
+
isNumber,
|
|
22
|
+
isObject,
|
|
23
|
+
isPrimitive,
|
|
24
|
+
isPromise,
|
|
25
|
+
isString,
|
|
26
|
+
isSymbol
|
|
27
|
+
} from "../chunk-ZGYORUAX.js";
|
|
28
|
+
export {
|
|
29
|
+
draw,
|
|
30
|
+
isArray,
|
|
31
|
+
isClient,
|
|
32
|
+
isDate,
|
|
33
|
+
isEmpty,
|
|
34
|
+
isFloat,
|
|
35
|
+
isFn,
|
|
36
|
+
isInt,
|
|
37
|
+
isNumber,
|
|
38
|
+
isObject,
|
|
39
|
+
isPrimitive,
|
|
40
|
+
isPromise,
|
|
41
|
+
isString,
|
|
42
|
+
isSymbol,
|
|
43
|
+
iterate,
|
|
44
|
+
list,
|
|
45
|
+
random,
|
|
46
|
+
range,
|
|
47
|
+
shuffle,
|
|
48
|
+
uid
|
|
49
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const isSymbol: (value: any) => value is symbol;
|
|
2
|
+
declare const isArray: (arg: any) => arg is any[];
|
|
3
|
+
declare const isObject: (value: any) => value is object;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the given value is primitive.
|
|
6
|
+
*
|
|
7
|
+
* Primitive Types: number , string , boolean , symbol, bigint, undefined, null
|
|
8
|
+
*
|
|
9
|
+
* @param {*} value value to check
|
|
10
|
+
* @returns {boolean} result
|
|
11
|
+
*/
|
|
12
|
+
declare const isPrimitive: (value: any) => boolean;
|
|
13
|
+
declare const isFn: (value: any) => value is Function;
|
|
14
|
+
declare const isString: (value: any) => value is string;
|
|
15
|
+
declare const isInt: (value: any) => value is number;
|
|
16
|
+
declare const isFloat: (value: any) => value is number;
|
|
17
|
+
declare const isNumber: (value: any) => value is number;
|
|
18
|
+
declare const isDate: (value: any) => value is Date;
|
|
19
|
+
/**
|
|
20
|
+
* This is really a _best guess_ promise checking. You
|
|
21
|
+
* should probably use Promise.resolve(value) to be 100%
|
|
22
|
+
* sure you're handling it correctly.
|
|
23
|
+
*/
|
|
24
|
+
declare const isPromise: (value: any) => value is Promise<any>;
|
|
25
|
+
declare const isEmpty: (value: any) => boolean;
|
|
26
|
+
declare const isClient: boolean;
|
|
27
|
+
|
|
28
|
+
export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isArray,
|
|
3
|
+
isClient,
|
|
4
|
+
isDate,
|
|
5
|
+
isEmpty,
|
|
6
|
+
isFloat,
|
|
7
|
+
isFn,
|
|
8
|
+
isInt,
|
|
9
|
+
isNumber,
|
|
10
|
+
isObject,
|
|
11
|
+
isPrimitive,
|
|
12
|
+
isPromise,
|
|
13
|
+
isString,
|
|
14
|
+
isSymbol
|
|
15
|
+
} from "../chunk-ZGYORUAX.js";
|
|
16
|
+
export {
|
|
17
|
+
isArray,
|
|
18
|
+
isClient,
|
|
19
|
+
isDate,
|
|
20
|
+
isEmpty,
|
|
21
|
+
isFloat,
|
|
22
|
+
isFn,
|
|
23
|
+
isInt,
|
|
24
|
+
isNumber,
|
|
25
|
+
isObject,
|
|
26
|
+
isPrimitive,
|
|
27
|
+
isPromise,
|
|
28
|
+
isString,
|
|
29
|
+
isSymbol
|
|
30
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a random number between min and max
|
|
3
|
+
*/
|
|
4
|
+
declare const random: (min: number, max: number) => number;
|
|
5
|
+
/**
|
|
6
|
+
* Draw a random item from a list. Returns
|
|
7
|
+
* null if the list is empty
|
|
8
|
+
*/
|
|
9
|
+
declare const draw: <T>(array: readonly T[]) => T | null;
|
|
10
|
+
declare const shuffle: <T>(array: readonly T[]) => T[];
|
|
11
|
+
declare const uid: (length: number, specials?: string) => string;
|
|
12
|
+
|
|
13
|
+
export { draw, random, shuffle, uid };
|
package/dist/reactive/access.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
access
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-M5A3VVYI.js";
|
|
4
|
+
import "../chunk-33ZRZ4S2.js";
|
|
5
|
+
import "../chunk-RRYFZNKE.js";
|
|
6
|
+
import "../chunk-WLQ64SAO.js";
|
|
7
|
+
import "../chunk-ZGYORUAX.js";
|
|
5
8
|
export {
|
|
6
9
|
access
|
|
7
10
|
};
|
package/dist/reactive/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import "../chunk-ZZNAXGNU.js";
|
|
2
2
|
import {
|
|
3
3
|
access
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-PEWQLY2D.js";
|
|
4
|
+
} from "../chunk-M5A3VVYI.js";
|
|
6
5
|
import {
|
|
7
6
|
createWatch
|
|
8
7
|
} from "../chunk-4L6FK7MF.js";
|
|
8
|
+
import "../chunk-33ZRZ4S2.js";
|
|
9
|
+
import "../chunk-RRYFZNKE.js";
|
|
10
|
+
import "../chunk-WLQ64SAO.js";
|
|
11
|
+
import "../chunk-ZGYORUAX.js";
|
|
9
12
|
export {
|
|
10
13
|
access,
|
|
11
14
|
createWatch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-tiny-utils",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A collection of tiny utilities for SolidJS applications",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@biomejs/biome": "2.1.2",
|
|
16
|
+
"@solidjs/testing-library": "^0.8.10",
|
|
17
|
+
"@testing-library/jest-dom": "^6.6.4",
|
|
18
|
+
"@testing-library/user-event": "^14.6.1",
|
|
19
|
+
"@types/node": "^24.2.1",
|
|
16
20
|
"@vitest/ui": "^3.2.4",
|
|
17
21
|
"commit-and-tag-version": "^12.5.1",
|
|
18
22
|
"husky": "^9.1.7",
|
|
@@ -36,19 +40,21 @@
|
|
|
36
40
|
"author": "",
|
|
37
41
|
"license": "MIT",
|
|
38
42
|
"dependencies": {
|
|
43
|
+
"@solid-primitives/event-listener": "^2.4.3",
|
|
39
44
|
"solid-tiny-context": "0.1.2"
|
|
40
45
|
},
|
|
41
46
|
"scripts": {
|
|
42
47
|
"build": "tsup",
|
|
43
48
|
"dev": "vite",
|
|
44
49
|
"test": "vitest",
|
|
50
|
+
"clean": "rimraf dist node_modules pnpm-lock.yaml",
|
|
45
51
|
"test:run": "vitest --run",
|
|
46
52
|
"test:ui": "vitest --ui",
|
|
47
53
|
"test:coverage": "vitest --coverage",
|
|
48
54
|
"lint": "npx ultracite lint",
|
|
49
55
|
"lint:fix": "npx ultracite format",
|
|
50
56
|
"type-check": "tsc --noEmit --skipLibCheck",
|
|
51
|
-
"release": "pnpm lint:fix && pnpm test:run &&commit-and-tag-version -i CHANGELOG.md --same-file",
|
|
57
|
+
"release": "pnpm type-check && pnpm lint:fix && pnpm test:run && commit-and-tag-version -i CHANGELOG.md --same-file",
|
|
52
58
|
"pub": "pnpm build && pnpm publish"
|
|
53
59
|
}
|
|
54
60
|
}
|
package/dist/chunk-PEWQLY2D.js
DELETED
package/dist/is/index.d.ts
DELETED
package/dist/is/index.js
DELETED
|
File without changes
|