@marianmeres/uid 1.0.0 → 1.1.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/mod.d.ts CHANGED
@@ -6,10 +6,14 @@
6
6
  * keep its word lists out of the core bundle.
7
7
  *
8
8
  * @example
9
+ * ```ts
9
10
  * import { uid, nanoid, uuidv7 } from "@marianmeres/uid";
10
11
  * uid(); // uuid v4
11
12
  * nanoid(12); // tree-shakeable named export
12
13
  * uid("uuidv7"); // sortable database key
14
+ * ```
15
+ *
16
+ * @module
13
17
  */
14
18
  export * from "./random.js";
15
19
  export * from "./uuid.js";
package/dist/mod.js CHANGED
@@ -6,10 +6,14 @@
6
6
  * keep its word lists out of the core bundle.
7
7
  *
8
8
  * @example
9
+ * ```ts
9
10
  * import { uid, nanoid, uuidv7 } from "@marianmeres/uid";
10
11
  * uid(); // uuid v4
11
12
  * nanoid(12); // tree-shakeable named export
12
13
  * uid("uuidv7"); // sortable database key
14
+ * ```
15
+ *
16
+ * @module
13
17
  */
14
18
  export * from "./random.js";
15
19
  export * from "./uuid.js";
package/dist/rhr.d.ts CHANGED
@@ -14,6 +14,8 @@
14
14
  * import { rhr } from "@marianmeres/uid/rhr";
15
15
  * rhr({ nounsCount: 1 });
16
16
  * ```
17
+ *
18
+ * @module
17
19
  */
18
20
  import { type RhrOptions } from "./uid.js";
19
21
  /**
package/dist/rhr.js CHANGED
@@ -14,6 +14,8 @@
14
14
  * import { rhr } from "@marianmeres/uid/rhr";
15
15
  * rhr({ nounsCount: 1 });
16
16
  * ```
17
+ *
18
+ * @module
17
19
  */
18
20
  import { getRandomHumanReadable } from "@marianmeres/random-human-readable";
19
21
  import { registerStrategy } from "./uid.js";
package/dist/uid.d.ts CHANGED
@@ -61,13 +61,21 @@ export interface ReversibleOptions {
61
61
  * subset of `@marianmeres/random-human-readable` options that yield a string.
62
62
  */
63
63
  export interface RhrOptions {
64
+ /** Number of adjectives (default: 1). */
64
65
  adjCount?: number;
66
+ /** Number of color names (default: 1). */
65
67
  colorsCount?: number;
68
+ /** Number of nouns (default: 2). */
66
69
  nounsCount?: number;
70
+ /** Number of nonsense CV syllables to append (default: 0). */
67
71
  syllablesCount?: number;
72
+ /** Number of random digits to append (default: 0). */
68
73
  digitsCount?: number;
74
+ /** Number of special characters to append (default: 0). */
69
75
  specialCharsCount?: number;
76
+ /** Randomize letter casing (default: false). */
70
77
  randomizeCase?: boolean;
78
+ /** Separator between parts (default: "-"). */
71
79
  joinWith?: string;
72
80
  }
73
81
  /** A strategy implementation: takes its options object, returns a string. */
@@ -80,14 +88,25 @@ export type StrategyFn = (options?: Record<string, unknown>) => string;
80
88
  export declare function registerStrategy(name: string, fn: StrategyFn): void;
81
89
  /** Returns the names of all currently registered strategies. */
82
90
  export declare function listStrategies(): string[];
91
+ /** Generates a UUID v4 — the default strategy. */
83
92
  export declare function uid(strategy?: "uuid" | "uuidv4", options?: UuidOptions): string;
93
+ /** Generates a time-sortable UUID v7. */
84
94
  export declare function uid(strategy: "uuidv7", options?: Uuidv7Options): string;
95
+ /** Generates a time-sortable ULID (Crockford base32). */
85
96
  export declare function uid(strategy: "ulid", options?: UlidOptions): string;
97
+ /** Generates a random base56 string, or reversibly encodes `options.uuid`. */
86
98
  export declare function uid(strategy: "base56", options?: Base56Options): string;
99
+ /** Generates a URL-safe nanoid-style id. */
87
100
  export declare function uid(strategy: "nanoid", options?: NanoidOptions): string;
101
+ /** Generates a random string over a named alphabet. */
88
102
  export declare function uid(strategy: "hex" | "base32" | "base36" | "base58" | "base62" | "numeric", options?: AlphabetOptions): string;
103
+ /** Generates a random string over a custom `options.alphabet`. */
89
104
  export declare function uid(strategy: "custom", options: CustomOptions): string;
105
+ /** Returns the next value of an in-memory, per-prefix counter. */
90
106
  export declare function uid(strategy: "counter", options?: CounterOptions): string;
107
+ /** Reversibly encodes `options.value` into a short string. */
91
108
  export declare function uid(strategy: "reversible", options: ReversibleOptions): string;
109
+ /** Generates a human-readable id (requires `import "@marianmeres/uid/rhr"`). */
92
110
  export declare function uid(strategy: "rhr", options?: RhrOptions): string;
111
+ /** Generates an id using any registered strategy, looked up by name. */
93
112
  export declare function uid(strategy: string, options?: Record<string, unknown>): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/uid",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",