@mulmoclaude/common 0.1.0 → 1.0.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/index.d.ts +11 -0
- package/dist/index.js +14 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,3 +22,14 @@ export declare function isErrorWithCode(value: unknown): value is {
|
|
|
22
22
|
export declare function hasStringProp<K extends string>(value: unknown, key: K): value is Record<K, string> & Record<string, unknown>;
|
|
23
23
|
/** Check that a record has a specific key with a number value. */
|
|
24
24
|
export declare function hasNumberProp<K extends string>(value: unknown, key: K): value is Record<K, number> & Record<string, unknown>;
|
|
25
|
+
/** Split a comma-separated env value into trimmed, non-empty entries.
|
|
26
|
+
* `lowercase` folds case for identifiers compared case-insensitively
|
|
27
|
+
* (JIDs, email addresses, hex pubkeys). Absent/empty input → empty list. */
|
|
28
|
+
export declare function parseCsvList(raw: string | undefined, opts?: {
|
|
29
|
+
lowercase?: boolean;
|
|
30
|
+
}): string[];
|
|
31
|
+
/** A comma-separated env value as a Set — the canonical allowlist shape,
|
|
32
|
+
* where an empty set is the "allow all" sentinel (`set.size === 0`). */
|
|
33
|
+
export declare function parseCsvSet(raw: string | undefined, opts?: {
|
|
34
|
+
lowercase?: boolean;
|
|
35
|
+
}): Set<string>;
|
package/dist/index.js
CHANGED
|
@@ -46,3 +46,17 @@ export function hasStringProp(value, key) {
|
|
|
46
46
|
export function hasNumberProp(value, key) {
|
|
47
47
|
return isRecord(value) && typeof value[key] === "number";
|
|
48
48
|
}
|
|
49
|
+
/** Split a comma-separated env value into trimmed, non-empty entries.
|
|
50
|
+
* `lowercase` folds case for identifiers compared case-insensitively
|
|
51
|
+
* (JIDs, email addresses, hex pubkeys). Absent/empty input → empty list. */
|
|
52
|
+
export function parseCsvList(raw, opts) {
|
|
53
|
+
return (raw ?? "")
|
|
54
|
+
.split(",")
|
|
55
|
+
.map((entry) => (opts?.lowercase ? entry.trim().toLowerCase() : entry.trim()))
|
|
56
|
+
.filter(Boolean);
|
|
57
|
+
}
|
|
58
|
+
/** A comma-separated env value as a Set — the canonical allowlist shape,
|
|
59
|
+
* where an empty set is the "allow all" sentinel (`set.size === 0`). */
|
|
60
|
+
export function parseCsvSet(raw, opts) {
|
|
61
|
+
return new Set(parseCsvList(raw, opts));
|
|
62
|
+
}
|
package/package.json
CHANGED