@solid-primitives/utils 7.0.0-next.0 → 7.0.0-next.1

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/index.d.ts CHANGED
@@ -66,6 +66,8 @@ export declare function chain<Args extends [] | any[]>(callbacks: {
66
66
  export declare function reverseChain<Args extends [] | any[]>(callbacks: (((...args: Args) => any) | undefined)[]): (...args: Args) => void;
67
67
  /** Clamps `n` to the inclusive range `[min, max]`. */
68
68
  export declare const clamp: (n: number, min: number, max: number) => number;
69
+ /** Creates an ID generator with its own isolated counter and per-generator random segment. Each call to the returned function produces a `timestamp-sequence-random` string that is unique within the generator and with high probability unique across independent generators (e.g. separate processes or SSR requests). */
70
+ export declare const createIdGenerator: () => (() => string);
69
71
  /**
70
72
  * Accesses the value of a MaybeAccessor
71
73
  * @example
package/dist/index.js CHANGED
@@ -78,6 +78,12 @@ export function reverseChain(callbacks) {
78
78
  }
79
79
  /** Clamps `n` to the inclusive range `[min, max]`. */
80
80
  export const clamp = (n, min, max) => Math.min(Math.max(n, min), max);
81
+ /** Creates an ID generator with its own isolated counter and per-generator random segment. Each call to the returned function produces a `timestamp-sequence-random` string that is unique within the generator and with high probability unique across independent generators (e.g. separate processes or SSR requests). */
82
+ export const createIdGenerator = () => {
83
+ let seq = 0;
84
+ const rand = Math.random().toString(36).slice(2, 8);
85
+ return () => `${Date.now().toString(36)}-${(++seq).toString(36)}-${rand}`;
86
+ };
81
87
  /**
82
88
  * Accesses the value of a MaybeAccessor
83
89
  * @example
@@ -106,7 +112,7 @@ export const accessArray = (list) => list.map(v => access(v));
106
112
  */
107
113
  export const withAccess = (value, fn) => {
108
114
  const _value = access(value);
109
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
115
+ // oxlint-disable-next-line @typescript-eslint/no-unnecessary-condition
110
116
  typeof _value != null && fn(_value);
111
117
  };
112
118
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/utils",
3
- "version": "7.0.0-next.0",
3
+ "version": "7.0.0-next.1",
4
4
  "description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
5
5
  "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
6
6
  "contributors": [