solid-tiny-utils 0.1.0 → 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.
Files changed (40) hide show
  1. package/dist/chunk-2BGAGVTR.js +7 -0
  2. package/dist/chunk-FFBJP5FE.js +0 -0
  3. package/dist/{chunk-EDY67NJO.js → chunk-H6VUVMSF.js} +1 -1
  4. package/dist/chunk-KVG6TCSE.js +28 -0
  5. package/dist/chunk-M53KPXWR.js +0 -0
  6. package/dist/{chunk-KK2I663A.js → chunk-M5A3VVYI.js} +1 -1
  7. package/dist/chunk-RRYFZNKE.js +36 -0
  8. package/dist/chunk-WLQ64SAO.js +32 -0
  9. package/dist/{chunk-37DCIGY3.js → chunk-WY5G2PJM.js} +4 -4
  10. package/dist/chunk-YJB637I2.js +29 -0
  11. package/dist/chunk-ZGYORUAX.js +93 -0
  12. package/dist/dom/css.d.ts +13 -0
  13. package/dist/dom/css.js +10 -0
  14. package/dist/dom/index.d.ts +1 -0
  15. package/dist/dom/index.js +11 -0
  16. package/dist/event/create-click-outside.d.ts +8 -0
  17. package/dist/event/create-click-outside.js +13 -0
  18. package/dist/event/index.d.ts +3 -0
  19. package/dist/event/index.js +14 -0
  20. package/dist/fn/create-debounce.js +6 -3
  21. package/dist/fn/create-loop-exec.js +6 -3
  22. package/dist/fn/index.d.ts +4 -0
  23. package/dist/fn/index.js +12 -6
  24. package/dist/index.d.ts +8 -3
  25. package/dist/index.js +62 -10
  26. package/dist/lodash/array.d.ts +42 -0
  27. package/dist/lodash/array.js +11 -0
  28. package/dist/lodash/index.d.ts +3 -0
  29. package/dist/lodash/index.js +49 -0
  30. package/dist/lodash/is.d.ts +28 -0
  31. package/dist/lodash/is.js +30 -0
  32. package/dist/lodash/random.d.ts +13 -0
  33. package/dist/lodash/random.js +14 -0
  34. package/dist/reactive/access.js +5 -2
  35. package/dist/reactive/index.js +5 -2
  36. package/package.json +8 -2
  37. package/dist/chunk-L5HLW5DG.js +0 -16
  38. package/dist/is/index.d.ts +0 -5
  39. package/dist/is/index.js +0 -10
  40. /package/dist/{chunk-QKJKTJQE.js → chunk-33ZRZ4S2.js} +0 -0
@@ -0,0 +1,7 @@
1
+ // src/fn/index.ts
2
+ var noop = () => {
3
+ };
4
+
5
+ export {
6
+ noop
7
+ };
File without changes
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  access
3
- } from "./chunk-KK2I663A.js";
3
+ } from "./chunk-M5A3VVYI.js";
4
4
 
5
5
  // src/fn/create-debounce.ts
6
6
  import { onCleanup } from "solid-js";
@@ -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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isFn
3
- } from "./chunk-L5HLW5DG.js";
3
+ } from "./chunk-ZGYORUAX.js";
4
4
 
5
5
  // src/reactive/access.ts
6
6
  function access(value) {
@@ -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,12 +1,12 @@
1
1
  import {
2
2
  access
3
- } from "./chunk-KK2I663A.js";
4
- import {
5
- isNumber
6
- } from "./chunk-L5HLW5DG.js";
3
+ } from "./chunk-M5A3VVYI.js";
7
4
  import {
8
5
  createWatch
9
6
  } from "./chunk-4L6FK7MF.js";
7
+ import {
8
+ isNumber
9
+ } from "./chunk-ZGYORUAX.js";
10
10
 
11
11
  // src/fn/create-loop-exec.ts
12
12
  import { onCleanup } from "solid-js";
@@ -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 };
@@ -0,0 +1,10 @@
1
+ import {
2
+ mountStyle
3
+ } from "../chunk-KVG6TCSE.js";
4
+ import "../chunk-33ZRZ4S2.js";
5
+ import "../chunk-RRYFZNKE.js";
6
+ import "../chunk-WLQ64SAO.js";
7
+ import "../chunk-ZGYORUAX.js";
8
+ export {
9
+ mountStyle
10
+ };
@@ -0,0 +1 @@
1
+ export { mountStyle } from './css.js';
@@ -0,0 +1,11 @@
1
+ import "../chunk-FFBJP5FE.js";
2
+ import {
3
+ mountStyle
4
+ } from "../chunk-KVG6TCSE.js";
5
+ import "../chunk-33ZRZ4S2.js";
6
+ import "../chunk-RRYFZNKE.js";
7
+ import "../chunk-WLQ64SAO.js";
8
+ import "../chunk-ZGYORUAX.js";
9
+ export {
10
+ mountStyle
11
+ };
@@ -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,3 @@
1
+ export { createClickOutside } from './create-click-outside.js';
2
+ import '../types/maybe.js';
3
+ import 'solid-js';
@@ -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-EDY67NJO.js";
3
+ } from "../chunk-H6VUVMSF.js";
4
4
  import "../chunk-ZZNAXGNU.js";
5
- import "../chunk-KK2I663A.js";
6
- import "../chunk-L5HLW5DG.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
  };
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  createLoopExec
3
- } from "../chunk-37DCIGY3.js";
3
+ } from "../chunk-WY5G2PJM.js";
4
4
  import "../chunk-ZZNAXGNU.js";
5
- import "../chunk-KK2I663A.js";
6
- import "../chunk-L5HLW5DG.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
  };
@@ -2,3 +2,7 @@ export { createDebounce } from './create-debounce.js';
2
2
  export { createLoopExec } from './create-loop-exec.js';
3
3
  import '../types/maybe.js';
4
4
  import 'solid-js';
5
+
6
+ declare const noop: () => void;
7
+
8
+ export { noop };
package/dist/fn/index.js CHANGED
@@ -1,15 +1,21 @@
1
- import "../chunk-QKJKTJQE.js";
1
+ import {
2
+ noop
3
+ } from "../chunk-2BGAGVTR.js";
2
4
  import {
3
5
  createDebounce
4
- } from "../chunk-EDY67NJO.js";
6
+ } from "../chunk-H6VUVMSF.js";
5
7
  import {
6
8
  createLoopExec
7
- } from "../chunk-37DCIGY3.js";
9
+ } from "../chunk-WY5G2PJM.js";
8
10
  import "../chunk-ZZNAXGNU.js";
9
- import "../chunk-KK2I663A.js";
10
- import "../chunk-L5HLW5DG.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 { createDebounce } from './fn/create-debounce.js';
2
- export { createLoopExec } from './fn/create-loop-exec.js';
3
- export { isArray, isFn, isNumber } from './is/index.js';
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,30 +1,82 @@
1
1
  import "./chunk-2BUPSB7O.js";
2
2
  import "./chunk-EZML2DEC.js";
3
- import "./chunk-QKJKTJQE.js";
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-EDY67NJO.js";
16
+ } from "./chunk-H6VUVMSF.js";
7
17
  import {
8
18
  createLoopExec
9
- } from "./chunk-37DCIGY3.js";
19
+ } from "./chunk-WY5G2PJM.js";
10
20
  import "./chunk-ZZNAXGNU.js";
11
21
  import {
12
22
  access
13
- } from "./chunk-KK2I663A.js";
14
- import {
15
- isArray,
16
- isFn,
17
- isNumber
18
- } from "./chunk-L5HLW5DG.js";
23
+ } from "./chunk-M5A3VVYI.js";
19
24
  import {
20
25
  createWatch
21
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";
22
54
  export {
23
55
  access,
56
+ createClickOutside,
24
57
  createDebounce,
25
58
  createLoopExec,
26
59
  createWatch,
60
+ draw,
27
61
  isArray,
62
+ isClient,
63
+ isDate,
64
+ isEmpty,
65
+ isFloat,
28
66
  isFn,
29
- isNumber
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
30
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,11 @@
1
+ import {
2
+ iterate,
3
+ list,
4
+ range
5
+ } from "../chunk-WLQ64SAO.js";
6
+ import "../chunk-ZGYORUAX.js";
7
+ export {
8
+ iterate,
9
+ list,
10
+ range
11
+ };
@@ -0,0 +1,3 @@
1
+ export { iterate, list, range } from './array.js';
2
+ export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './is.js';
3
+ export { draw, random, shuffle, uid } from './random.js';
@@ -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 };
@@ -0,0 +1,14 @@
1
+ import {
2
+ draw,
3
+ random,
4
+ shuffle,
5
+ uid
6
+ } from "../chunk-RRYFZNKE.js";
7
+ import "../chunk-WLQ64SAO.js";
8
+ import "../chunk-ZGYORUAX.js";
9
+ export {
10
+ draw,
11
+ random,
12
+ shuffle,
13
+ uid
14
+ };
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  access
3
- } from "../chunk-KK2I663A.js";
4
- import "../chunk-L5HLW5DG.js";
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
  };
@@ -1,11 +1,14 @@
1
1
  import "../chunk-ZZNAXGNU.js";
2
2
  import {
3
3
  access
4
- } from "../chunk-KK2I663A.js";
5
- import "../chunk-L5HLW5DG.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.1.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
  }
@@ -1,16 +0,0 @@
1
- // src/is/index.ts
2
- function isFn(value) {
3
- return typeof value === "function";
4
- }
5
- function isArray(value) {
6
- return Array.isArray(value);
7
- }
8
- function isNumber(value) {
9
- return typeof value === "number" && !Number.isNaN(value);
10
- }
11
-
12
- export {
13
- isFn,
14
- isArray,
15
- isNumber
16
- };
@@ -1,5 +0,0 @@
1
- declare function isFn(value: unknown): value is Function;
2
- declare function isArray<T>(value: unknown): value is T[];
3
- declare function isNumber(value: unknown): value is number;
4
-
5
- export { isArray, isFn, isNumber };
package/dist/is/index.js DELETED
@@ -1,10 +0,0 @@
1
- import {
2
- isArray,
3
- isFn,
4
- isNumber
5
- } from "../chunk-L5HLW5DG.js";
6
- export {
7
- isArray,
8
- isFn,
9
- isNumber
10
- };
File without changes