solid-tiny-utils 0.1.0 → 0.3.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 (46) hide show
  1. package/dist/chunk-2BGAGVTR.js +7 -0
  2. package/dist/{chunk-EDY67NJO.js → chunk-H6VUVMSF.js} +1 -1
  3. package/dist/chunk-KFWZFQMB.js +8 -0
  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-OECLQ3OT.js +0 -0
  8. package/dist/chunk-PNR5G432.js +85 -0
  9. package/dist/chunk-RRYFZNKE.js +36 -0
  10. package/dist/chunk-WLQ64SAO.js +32 -0
  11. package/dist/{chunk-37DCIGY3.js → chunk-WY5G2PJM.js} +4 -4
  12. package/dist/chunk-YJB637I2.js +29 -0
  13. package/dist/chunk-ZGYORUAX.js +93 -0
  14. package/dist/dom/css.d.ts +13 -0
  15. package/dist/dom/css.js +12 -0
  16. package/dist/dom/index.d.ts +1 -0
  17. package/dist/dom/index.js +13 -0
  18. package/dist/event/create-click-outside.d.ts +8 -0
  19. package/dist/event/create-click-outside.js +15 -0
  20. package/dist/event/index.d.ts +3 -0
  21. package/dist/event/index.js +16 -0
  22. package/dist/fn/create-debounce.js +8 -3
  23. package/dist/fn/create-loop-exec.js +8 -3
  24. package/dist/fn/index.d.ts +4 -0
  25. package/dist/fn/index.js +14 -6
  26. package/dist/index.d.ts +10 -3
  27. package/dist/index.js +83 -9
  28. package/dist/lodash/array.d.ts +42 -0
  29. package/dist/lodash/array.js +11 -0
  30. package/dist/lodash/async.d.ts +6 -0
  31. package/dist/lodash/async.js +6 -0
  32. package/dist/lodash/index.d.ts +5 -0
  33. package/dist/lodash/index.js +71 -0
  34. package/dist/lodash/is.d.ts +28 -0
  35. package/dist/lodash/is.js +30 -0
  36. package/dist/lodash/random.d.ts +13 -0
  37. package/dist/lodash/random.js +14 -0
  38. package/dist/lodash/str.d.ts +75 -0
  39. package/dist/lodash/str.js +20 -0
  40. package/dist/reactive/access.js +7 -2
  41. package/dist/reactive/index.js +7 -2
  42. package/package.json +8 -2
  43. package/dist/chunk-L5HLW5DG.js +0 -16
  44. package/dist/is/index.d.ts +0 -5
  45. package/dist/is/index.js +0 -10
  46. /package/dist/{chunk-QKJKTJQE.js → chunk-FFBJP5FE.js} +0 -0
@@ -0,0 +1,7 @@
1
+ // src/fn/index.ts
2
+ var noop = () => {
3
+ };
4
+
5
+ export {
6
+ noop
7
+ };
@@ -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,8 @@
1
+ // src/lodash/async.ts
2
+ var sleep = (milliseconds) => {
3
+ return new Promise((res) => setTimeout(res, milliseconds));
4
+ };
5
+
6
+ export {
7
+ sleep
8
+ };
@@ -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) {
File without changes
@@ -0,0 +1,85 @@
1
+ // src/lodash/str.ts
2
+ var capitalize = (str) => {
3
+ if (!str || str.length === 0) {
4
+ return "";
5
+ }
6
+ const lower = str.toLowerCase();
7
+ return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length);
8
+ };
9
+ var splitRegexp = /(?=[A-Z])|[.\-\s_]/;
10
+ var camel = (str) => {
11
+ const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
12
+ if (parts.length === 0) {
13
+ return "";
14
+ }
15
+ if (parts.length === 1) {
16
+ return parts[0];
17
+ }
18
+ return parts.reduce((acc, part) => {
19
+ return `${acc}${part.charAt(0).toUpperCase()}${part.slice(1)}`;
20
+ });
21
+ };
22
+ var splitOnNumberRegexp = /([A-Za-z]{1}[0-9]{1})/;
23
+ var snake = (str, options) => {
24
+ const parts = str?.replace(/([A-Z])+/g, capitalize).split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
25
+ if (parts.length === 0) {
26
+ return "";
27
+ }
28
+ if (parts.length === 1) {
29
+ return parts[0];
30
+ }
31
+ const result = parts.reduce((acc, part) => {
32
+ return `${acc}_${part.toLowerCase()}`;
33
+ });
34
+ return options?.splitOnNumber === false ? result : result.replace(splitOnNumberRegexp, (val) => `${val[0]}_${val[1]}`);
35
+ };
36
+ var dash = (str) => {
37
+ const parts = str?.replace(/([A-Z])+/g, capitalize)?.split(splitRegexp).map((x) => x.toLowerCase()) ?? [];
38
+ if (parts.length === 0) {
39
+ return "";
40
+ }
41
+ if (parts.length === 1) {
42
+ return parts[0];
43
+ }
44
+ return parts.reduce((acc, part) => {
45
+ return `${acc}-${part.toLowerCase()}`;
46
+ });
47
+ };
48
+ var pascalSplitRegexp = /[.\-\s_]/;
49
+ var pascal = (str) => {
50
+ const parts = str?.split(pascalSplitRegexp).map((x) => x.toLowerCase()) ?? [];
51
+ if (parts.length === 0) {
52
+ return "";
53
+ }
54
+ return parts.map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("");
55
+ };
56
+ var title = (str) => {
57
+ if (!str) {
58
+ return "";
59
+ }
60
+ return str.split(splitRegexp).map((s) => s.trim()).filter((s) => !!s).map((s) => capitalize(s.toLowerCase())).join(" ");
61
+ };
62
+ var template = (str, data, regex = /\{\{(.+?)\}\}/g) => {
63
+ return Array.from(str.matchAll(regex)).reduce((acc, match) => {
64
+ return acc.replace(match[0], data[match[1]]);
65
+ }, str);
66
+ };
67
+ var trim = (str, charsToTrim = " ") => {
68
+ if (!str) {
69
+ return "";
70
+ }
71
+ const toTrim = charsToTrim.replace(/[\W]{1}/g, "\\$&");
72
+ const regex = new RegExp(`^[${toTrim}]+|[${toTrim}]+$`, "g");
73
+ return str.replace(regex, "");
74
+ };
75
+
76
+ export {
77
+ capitalize,
78
+ camel,
79
+ snake,
80
+ dash,
81
+ pascal,
82
+ title,
83
+ template,
84
+ trim
85
+ };
@@ -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,12 @@
1
+ import {
2
+ mountStyle
3
+ } from "../chunk-KVG6TCSE.js";
4
+ import "../chunk-OECLQ3OT.js";
5
+ import "../chunk-KFWZFQMB.js";
6
+ import "../chunk-RRYFZNKE.js";
7
+ import "../chunk-WLQ64SAO.js";
8
+ import "../chunk-ZGYORUAX.js";
9
+ import "../chunk-PNR5G432.js";
10
+ export {
11
+ mountStyle
12
+ };
@@ -0,0 +1 @@
1
+ export { mountStyle } from './css.js';
@@ -0,0 +1,13 @@
1
+ import "../chunk-FFBJP5FE.js";
2
+ import {
3
+ mountStyle
4
+ } from "../chunk-KVG6TCSE.js";
5
+ import "../chunk-OECLQ3OT.js";
6
+ import "../chunk-KFWZFQMB.js";
7
+ import "../chunk-RRYFZNKE.js";
8
+ import "../chunk-WLQ64SAO.js";
9
+ import "../chunk-ZGYORUAX.js";
10
+ import "../chunk-PNR5G432.js";
11
+ export {
12
+ mountStyle
13
+ };
@@ -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,15 @@
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-OECLQ3OT.js";
8
+ import "../chunk-KFWZFQMB.js";
9
+ import "../chunk-RRYFZNKE.js";
10
+ import "../chunk-WLQ64SAO.js";
11
+ import "../chunk-ZGYORUAX.js";
12
+ import "../chunk-PNR5G432.js";
13
+ export {
14
+ createClickOutside
15
+ };
@@ -0,0 +1,3 @@
1
+ export { createClickOutside } from './create-click-outside.js';
2
+ import '../types/maybe.js';
3
+ import 'solid-js';
@@ -0,0 +1,16 @@
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-OECLQ3OT.js";
9
+ import "../chunk-KFWZFQMB.js";
10
+ import "../chunk-RRYFZNKE.js";
11
+ import "../chunk-WLQ64SAO.js";
12
+ import "../chunk-ZGYORUAX.js";
13
+ import "../chunk-PNR5G432.js";
14
+ export {
15
+ createClickOutside
16
+ };
@@ -1,10 +1,15 @@
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-OECLQ3OT.js";
8
+ import "../chunk-KFWZFQMB.js";
9
+ import "../chunk-RRYFZNKE.js";
10
+ import "../chunk-WLQ64SAO.js";
11
+ import "../chunk-ZGYORUAX.js";
12
+ import "../chunk-PNR5G432.js";
8
13
  export {
9
14
  createDebounce
10
15
  };
@@ -1,10 +1,15 @@
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-OECLQ3OT.js";
8
+ import "../chunk-KFWZFQMB.js";
9
+ import "../chunk-RRYFZNKE.js";
10
+ import "../chunk-WLQ64SAO.js";
11
+ import "../chunk-ZGYORUAX.js";
12
+ import "../chunk-PNR5G432.js";
8
13
  export {
9
14
  createLoopExec
10
15
  };
@@ -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,23 @@
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-OECLQ3OT.js";
14
+ import "../chunk-KFWZFQMB.js";
15
+ import "../chunk-RRYFZNKE.js";
16
+ import "../chunk-WLQ64SAO.js";
17
+ import "../chunk-ZGYORUAX.js";
18
+ import "../chunk-PNR5G432.js";
12
19
  export {
13
20
  createDebounce,
14
- createLoopExec
21
+ createLoopExec,
22
+ noop
15
23
  };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,14 @@
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 { sleep } from './lodash/async.js';
6
+ export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './lodash/is.js';
7
+ export { draw, random, shuffle, uid } from './lodash/random.js';
8
+ export { camel, capitalize, dash, pascal, snake, template, title, trim } from './lodash/str.js';
4
9
  export { access } from './reactive/access.js';
5
10
  export { createWatch } from './reactive/create-watch.js';
6
11
  export { MaybeAccessor, MaybeArray, MaybePromise } from './types/maybe.js';
12
+ export { createDebounce } from './fn/create-debounce.js';
13
+ export { createLoopExec } from './fn/create-loop-exec.js';
7
14
  import 'solid-js';
package/dist/index.js CHANGED
@@ -1,30 +1,104 @@
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";
23
+ } from "./chunk-M5A3VVYI.js";
24
+ import {
25
+ createWatch
26
+ } from "./chunk-4L6FK7MF.js";
27
+ import "./chunk-OECLQ3OT.js";
28
+ import {
29
+ sleep
30
+ } from "./chunk-KFWZFQMB.js";
31
+ import {
32
+ draw,
33
+ random,
34
+ shuffle,
35
+ uid
36
+ } from "./chunk-RRYFZNKE.js";
37
+ import {
38
+ iterate,
39
+ list,
40
+ range
41
+ } from "./chunk-WLQ64SAO.js";
14
42
  import {
15
43
  isArray,
44
+ isClient,
45
+ isDate,
46
+ isEmpty,
47
+ isFloat,
16
48
  isFn,
17
- isNumber
18
- } from "./chunk-L5HLW5DG.js";
49
+ isInt,
50
+ isNumber,
51
+ isObject,
52
+ isPrimitive,
53
+ isPromise,
54
+ isString,
55
+ isSymbol
56
+ } from "./chunk-ZGYORUAX.js";
19
57
  import {
20
- createWatch
21
- } from "./chunk-4L6FK7MF.js";
58
+ camel,
59
+ capitalize,
60
+ dash,
61
+ pascal,
62
+ snake,
63
+ template,
64
+ title,
65
+ trim
66
+ } from "./chunk-PNR5G432.js";
22
67
  export {
23
68
  access,
69
+ camel,
70
+ capitalize,
71
+ createClickOutside,
24
72
  createDebounce,
25
73
  createLoopExec,
26
74
  createWatch,
75
+ dash,
76
+ draw,
27
77
  isArray,
78
+ isClient,
79
+ isDate,
80
+ isEmpty,
81
+ isFloat,
28
82
  isFn,
29
- isNumber
83
+ isInt,
84
+ isNumber,
85
+ isObject,
86
+ isPrimitive,
87
+ isPromise,
88
+ isString,
89
+ isSymbol,
90
+ iterate,
91
+ list,
92
+ mountStyle,
93
+ noop,
94
+ pascal,
95
+ random,
96
+ range,
97
+ shuffle,
98
+ sleep,
99
+ snake,
100
+ template,
101
+ title,
102
+ trim,
103
+ uid
30
104
  };
@@ -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,6 @@
1
+ /**
2
+ * Async wait
3
+ */
4
+ declare const sleep: (milliseconds: number) => Promise<unknown>;
5
+
6
+ export { sleep };
@@ -0,0 +1,6 @@
1
+ import {
2
+ sleep
3
+ } from "../chunk-KFWZFQMB.js";
4
+ export {
5
+ sleep
6
+ };
@@ -0,0 +1,5 @@
1
+ export { iterate, list, range } from './array.js';
2
+ export { sleep } from './async.js';
3
+ export { isArray, isClient, isDate, isEmpty, isFloat, isFn, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol } from './is.js';
4
+ export { draw, random, shuffle, uid } from './random.js';
5
+ export { camel, capitalize, dash, pascal, snake, template, title, trim } from './str.js';
@@ -0,0 +1,71 @@
1
+ import "../chunk-OECLQ3OT.js";
2
+ import {
3
+ sleep
4
+ } from "../chunk-KFWZFQMB.js";
5
+ import {
6
+ draw,
7
+ random,
8
+ shuffle,
9
+ uid
10
+ } from "../chunk-RRYFZNKE.js";
11
+ import {
12
+ iterate,
13
+ list,
14
+ range
15
+ } from "../chunk-WLQ64SAO.js";
16
+ import {
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
+ } from "../chunk-ZGYORUAX.js";
31
+ import {
32
+ camel,
33
+ capitalize,
34
+ dash,
35
+ pascal,
36
+ snake,
37
+ template,
38
+ title,
39
+ trim
40
+ } from "../chunk-PNR5G432.js";
41
+ export {
42
+ camel,
43
+ capitalize,
44
+ dash,
45
+ draw,
46
+ isArray,
47
+ isClient,
48
+ isDate,
49
+ isEmpty,
50
+ isFloat,
51
+ isFn,
52
+ isInt,
53
+ isNumber,
54
+ isObject,
55
+ isPrimitive,
56
+ isPromise,
57
+ isString,
58
+ isSymbol,
59
+ iterate,
60
+ list,
61
+ pascal,
62
+ random,
63
+ range,
64
+ shuffle,
65
+ sleep,
66
+ snake,
67
+ template,
68
+ title,
69
+ trim,
70
+ uid
71
+ };
@@ -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
+ };
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Capitalize the first word of the string
3
+ *
4
+ * capitalize('hello') -> 'Hello'
5
+ * capitalize('va va voom') -> 'Va va voom'
6
+ */
7
+ declare const capitalize: (str: string) => string;
8
+ /**
9
+ * Formats the given string in camel case fashion
10
+ *
11
+ * camel('hello world') -> 'helloWorld'
12
+ * camel('va va-VOOM') -> 'vaVaVoom'
13
+ * camel('helloWorld') -> 'helloWorld'
14
+ */
15
+ declare const camel: (str: string) => string;
16
+ /**
17
+ * Formats the given string in snake case fashion
18
+ *
19
+ * splitOnNumber? Treat number as capital, default is true
20
+ *
21
+ * snake('hello world') -> 'hello_world'
22
+ * snake('va va-VOOM') -> 'va_va_voom'
23
+ * snake('helloWord') -> 'hello_world'
24
+ */
25
+ declare const snake: (str: string, options?: {
26
+ splitOnNumber?: boolean;
27
+ }) => string;
28
+ /**
29
+ * Formats the given string in dash case fashion
30
+ *
31
+ * dash('hello world') -> 'hello-world'
32
+ * dash('va va_VOOM') -> 'va-va-voom'
33
+ * dash('helloWord') -> 'hello-word'
34
+ */
35
+ declare const dash: (str: string) => string;
36
+ /**
37
+ * Formats the given string in pascal case fashion
38
+ *
39
+ * pascal('hello world') -> 'HelloWorld'
40
+ * pascal('va va boom') -> 'VaVaBoom'
41
+ */
42
+ declare const pascal: (str: string) => string;
43
+ /**
44
+ * Formats the given string in title case fashion
45
+ *
46
+ * title('hello world') -> 'Hello World'
47
+ * title('va_va_boom') -> 'Va Va Boom'
48
+ * title('root-hook') -> 'Root Hook'
49
+ * title('queryItems') -> 'Query Items'
50
+ */
51
+ declare const title: (str: string | null | undefined) => string;
52
+ /**
53
+ * template is used to replace data by name in template strings.
54
+ * The default expression looks for {{name}} to identify names.
55
+ *
56
+ * Ex. template('Hello, {{name}}', { name: 'ray' })
57
+ * Ex. template('Hello, <name>', { name: 'ray' }, /<(.+?)>/g)
58
+ */
59
+ declare const template: (str: string, data: Record<string, any>, regex?: RegExp) => string;
60
+ /**
61
+ * Trims all prefix and suffix characters from the given
62
+ * string. Like the builtin trim function but accepts
63
+ * other characters you would like to trim and trims
64
+ * multiple characters.
65
+ *
66
+ * ```typescript
67
+ * trim(' hello ') // => 'hello'
68
+ * trim('__hello__', '_') // => 'hello'
69
+ * trim('/repos/:owner/:repo/', '/') // => 'repos/:owner/:repo'
70
+ * trim('222222__hello__1111111', '12_') // => 'hello'
71
+ * ```
72
+ */
73
+ declare const trim: (str: string | null | undefined, charsToTrim?: string) => string;
74
+
75
+ export { camel, capitalize, dash, pascal, snake, template, title, trim };
@@ -0,0 +1,20 @@
1
+ import {
2
+ camel,
3
+ capitalize,
4
+ dash,
5
+ pascal,
6
+ snake,
7
+ template,
8
+ title,
9
+ trim
10
+ } from "../chunk-PNR5G432.js";
11
+ export {
12
+ camel,
13
+ capitalize,
14
+ dash,
15
+ pascal,
16
+ snake,
17
+ template,
18
+ title,
19
+ trim
20
+ };
@@ -1,7 +1,12 @@
1
1
  import {
2
2
  access
3
- } from "../chunk-KK2I663A.js";
4
- import "../chunk-L5HLW5DG.js";
3
+ } from "../chunk-M5A3VVYI.js";
4
+ import "../chunk-OECLQ3OT.js";
5
+ import "../chunk-KFWZFQMB.js";
6
+ import "../chunk-RRYFZNKE.js";
7
+ import "../chunk-WLQ64SAO.js";
8
+ import "../chunk-ZGYORUAX.js";
9
+ import "../chunk-PNR5G432.js";
5
10
  export {
6
11
  access
7
12
  };
@@ -1,11 +1,16 @@
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-OECLQ3OT.js";
9
+ import "../chunk-KFWZFQMB.js";
10
+ import "../chunk-RRYFZNKE.js";
11
+ import "../chunk-WLQ64SAO.js";
12
+ import "../chunk-ZGYORUAX.js";
13
+ import "../chunk-PNR5G432.js";
9
14
  export {
10
15
  access,
11
16
  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.3.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