@lionad/port-key 0.1.5 → 0.1.6

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/bin/port-key.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@lionad/port-key",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "A simple, practical port naming strategy",
5
5
  "type": "module",
6
+ "types": "./src/port-key.d.ts",
6
7
  "exports": {
7
- ".": "./src/port-key.js"
8
+ ".": {
9
+ "types": "./src/port-key.d.ts",
10
+ "default": "./src/port-key.js"
11
+ }
8
12
  },
9
13
  "keywords": [
10
14
  "portkey",
@@ -0,0 +1,43 @@
1
+ export type DigitKey = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
2
+
3
+ export type DigitLetterMap = Record<DigitKey | `${DigitKey}`, string>;
4
+
5
+ export type RejectedCandidate = {
6
+ candidate: string;
7
+ reason: string;
8
+ };
9
+
10
+ export type PickPortOptions = {
11
+ preferDigitCount?: number;
12
+ minPort?: number;
13
+ maxPort?: number;
14
+ blockedPorts?: ReadonlySet<number> | number[];
15
+ };
16
+
17
+ export const DEFAULT_MAP: Readonly<DigitLetterMap>;
18
+ export const DEFAULT_BLOCKED_PORTS: ReadonlySet<number>;
19
+
20
+ export function buildReverseMap(map: DigitLetterMap): Map<string, string>;
21
+ export function normalizeInput(text: unknown): string;
22
+ export function mapToDigits(text: unknown, map?: DigitLetterMap): string;
23
+ export function isValidPort(port: unknown): port is number;
24
+
25
+ export function pickPortFromDigits(
26
+ digits: unknown,
27
+ options?: PickPortOptions
28
+ ):
29
+ | { port: number; rejectedCandidates?: RejectedCandidate[] }
30
+ | { port: null; reason: string; rejectedCandidates?: RejectedCandidate[] };
31
+
32
+ export function mapToPort(
33
+ text: unknown,
34
+ map?: DigitLetterMap,
35
+ options?: PickPortOptions
36
+ ): {
37
+ digits: string;
38
+ port: number | null;
39
+ rejectedCandidates?: RejectedCandidate[];
40
+ reason?: string;
41
+ };
42
+
43
+ export function parseUserMap(mapString: unknown): DigitLetterMap;