@nlozgachev/pipelined 0.42.0 → 0.44.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nlozgachev/pipelined",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "Opinionated functional abstractions for TypeScript",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://pipelined.lozgachev.dev",
@@ -67,15 +67,15 @@
67
67
  "docs:build": "pnpm --filter pipelined-docs build"
68
68
  },
69
69
  "devDependencies": {
70
- "@types/node": "25.9.1",
71
- "@vitest/coverage-v8": "4.1.7",
70
+ "@types/node": "25.9.3",
71
+ "@vitest/coverage-v8": "4.1.8",
72
72
  "bumpp": "11.1.0",
73
73
  "dprint": "0.54.0",
74
74
  "fast-check": "4.8.0",
75
- "oxlint": "1.66.0",
75
+ "oxlint": "1.69.0",
76
76
  "tsup": "8.5.1",
77
77
  "typescript": "6.0.3",
78
- "vitest": "4.1.7"
78
+ "vitest": "4.1.8"
79
79
  },
80
- "packageManager": "pnpm@11.2.2+sha512.36e6621fad506178936455e70247b8808ef4ec25797a9f437a93281a020484e2607f6a469a22e982987c3dbb8866e3071514ab10a4a1749e06edcd1ec118436f"
80
+ "packageManager": "pnpm@11.6.0+sha512.9a36518224080c6fe5165afdcfe79bfa118c29be703f3f462b1e32efe1e98e47e8750b148e08286250aad4113cc7993ca413c4e2cd447752708c2ee5751bc95f"
81
81
  }
@@ -1,127 +0,0 @@
1
- declare const _brand: unique symbol;
2
- /**
3
- * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
4
- * Prevents accidentally mixing up values that share the same underlying type.
5
- *
6
- * @example
7
- * ```ts
8
- * type UserId = Brand<"UserId", string>;
9
- * type ProductId = Brand<"ProductId", string>;
10
- *
11
- * const toUserId = Brand.wrap<"UserId", string>();
12
- * const toProductId = Brand.wrap<"ProductId", string>();
13
- *
14
- * const userId: UserId = toUserId("user-123");
15
- * const productId: ProductId = toProductId("prod-456");
16
- *
17
- * // Type error: ProductId is not assignable to UserId
18
- * // const wrong: UserId = productId;
19
- * ```
20
- */
21
- type Brand<K extends string, T> = T & {
22
- readonly [_brand]: K;
23
- };
24
- declare namespace Brand {
25
- /**
26
- * Returns a constructor that wraps a value of type T in brand K.
27
- * The resulting function performs an unchecked cast — only use when the raw
28
- * value is known to satisfy the brand's invariants.
29
- *
30
- * @example
31
- * ```ts
32
- * type PositiveNumber = Brand<"PositiveNumber", number>;
33
- * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
34
- *
35
- * const n: PositiveNumber = toPositiveNumber(42);
36
- * ```
37
- */
38
- const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
- /**
40
- * Strips the brand and returns the underlying value.
41
- * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
42
- *
43
- * @example
44
- * ```ts
45
- * const userId: UserId = toUserId("user-123");
46
- * const raw: string = Brand.unwrap(userId); // "user-123"
47
- * ```
48
- */
49
- const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
50
- }
51
-
52
- /**
53
- * A branded nominal type representing a duration of time in milliseconds.
54
- * Use Duration to ensure safe time-based operators and clear unit conversions.
55
- *
56
- * @example
57
- * ```ts
58
- * const halfSecond = Duration.milliseconds(500);
59
- * const twoSeconds = Duration.seconds(2);
60
- * const total = pipe(halfSecond, Duration.add(twoSeconds));
61
- *
62
- * Duration.toSeconds(total); // 2.5
63
- * ```
64
- */
65
- type Duration = Brand<"Duration", number>;
66
- declare namespace Duration {
67
- /**
68
- * Creates a Duration from milliseconds.
69
- */
70
- const milliseconds: (ms: number) => Duration;
71
- /**
72
- * Creates a Duration from seconds.
73
- */
74
- const seconds: (s: number) => Duration;
75
- /**
76
- * Creates a Duration from minutes.
77
- */
78
- const minutes: (m: number) => Duration;
79
- /**
80
- * Creates a Duration from hours.
81
- */
82
- const hours: (h: number) => Duration;
83
- /**
84
- * Creates a Duration from days.
85
- */
86
- const days: (d: number) => Duration;
87
- /**
88
- * Converts a Duration back to raw milliseconds.
89
- */
90
- const toMilliseconds: (d: Duration) => number;
91
- /**
92
- * Converts a Duration to seconds.
93
- */
94
- const toSeconds: (d: Duration) => number;
95
- /**
96
- * Converts a Duration to minutes.
97
- */
98
- const toMinutes: (d: Duration) => number;
99
- /**
100
- * Converts a Duration to hours.
101
- */
102
- const toHours: (d: Duration) => number;
103
- /**
104
- * Converts a Duration to days.
105
- */
106
- const toDays: (d: Duration) => number;
107
- /**
108
- * Adds two Durations together.
109
- *
110
- * @example
111
- * ```ts
112
- * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
113
- * ```
114
- */
115
- const add: (other: Duration) => (self: Duration) => Duration;
116
- /**
117
- * Subtracts the other Duration from this one.
118
- *
119
- * @example
120
- * ```ts
121
- * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
122
- * ```
123
- */
124
- const subtract: (other: Duration) => (self: Duration) => Duration;
125
- }
126
-
127
- export { Brand as B, Duration as D };
@@ -1,127 +0,0 @@
1
- declare const _brand: unique symbol;
2
- /**
3
- * Brand<K, T> creates a nominal type by tagging T with a phantom brand K.
4
- * Prevents accidentally mixing up values that share the same underlying type.
5
- *
6
- * @example
7
- * ```ts
8
- * type UserId = Brand<"UserId", string>;
9
- * type ProductId = Brand<"ProductId", string>;
10
- *
11
- * const toUserId = Brand.wrap<"UserId", string>();
12
- * const toProductId = Brand.wrap<"ProductId", string>();
13
- *
14
- * const userId: UserId = toUserId("user-123");
15
- * const productId: ProductId = toProductId("prod-456");
16
- *
17
- * // Type error: ProductId is not assignable to UserId
18
- * // const wrong: UserId = productId;
19
- * ```
20
- */
21
- type Brand<K extends string, T> = T & {
22
- readonly [_brand]: K;
23
- };
24
- declare namespace Brand {
25
- /**
26
- * Returns a constructor that wraps a value of type T in brand K.
27
- * The resulting function performs an unchecked cast — only use when the raw
28
- * value is known to satisfy the brand's invariants.
29
- *
30
- * @example
31
- * ```ts
32
- * type PositiveNumber = Brand<"PositiveNumber", number>;
33
- * const toPositiveNumber = Brand.wrap<"PositiveNumber", number>();
34
- *
35
- * const n: PositiveNumber = toPositiveNumber(42);
36
- * ```
37
- */
38
- const wrap: <K extends string, T>() => (value: T) => Brand<K, T>;
39
- /**
40
- * Strips the brand and returns the underlying value.
41
- * Since Brand<K, T> extends T this is rarely needed, but can improve readability.
42
- *
43
- * @example
44
- * ```ts
45
- * const userId: UserId = toUserId("user-123");
46
- * const raw: string = Brand.unwrap(userId); // "user-123"
47
- * ```
48
- */
49
- const unwrap: <K extends string, T>(branded: Brand<K, T>) => T;
50
- }
51
-
52
- /**
53
- * A branded nominal type representing a duration of time in milliseconds.
54
- * Use Duration to ensure safe time-based operators and clear unit conversions.
55
- *
56
- * @example
57
- * ```ts
58
- * const halfSecond = Duration.milliseconds(500);
59
- * const twoSeconds = Duration.seconds(2);
60
- * const total = pipe(halfSecond, Duration.add(twoSeconds));
61
- *
62
- * Duration.toSeconds(total); // 2.5
63
- * ```
64
- */
65
- type Duration = Brand<"Duration", number>;
66
- declare namespace Duration {
67
- /**
68
- * Creates a Duration from milliseconds.
69
- */
70
- const milliseconds: (ms: number) => Duration;
71
- /**
72
- * Creates a Duration from seconds.
73
- */
74
- const seconds: (s: number) => Duration;
75
- /**
76
- * Creates a Duration from minutes.
77
- */
78
- const minutes: (m: number) => Duration;
79
- /**
80
- * Creates a Duration from hours.
81
- */
82
- const hours: (h: number) => Duration;
83
- /**
84
- * Creates a Duration from days.
85
- */
86
- const days: (d: number) => Duration;
87
- /**
88
- * Converts a Duration back to raw milliseconds.
89
- */
90
- const toMilliseconds: (d: Duration) => number;
91
- /**
92
- * Converts a Duration to seconds.
93
- */
94
- const toSeconds: (d: Duration) => number;
95
- /**
96
- * Converts a Duration to minutes.
97
- */
98
- const toMinutes: (d: Duration) => number;
99
- /**
100
- * Converts a Duration to hours.
101
- */
102
- const toHours: (d: Duration) => number;
103
- /**
104
- * Converts a Duration to days.
105
- */
106
- const toDays: (d: Duration) => number;
107
- /**
108
- * Adds two Durations together.
109
- *
110
- * @example
111
- * ```ts
112
- * pipe(Duration.seconds(1), Duration.add(Duration.milliseconds(500))); // 1500ms
113
- * ```
114
- */
115
- const add: (other: Duration) => (self: Duration) => Duration;
116
- /**
117
- * Subtracts the other Duration from this one.
118
- *
119
- * @example
120
- * ```ts
121
- * pipe(Duration.seconds(1), Duration.subtract(Duration.milliseconds(500))); // 500ms
122
- * ```
123
- */
124
- const subtract: (other: Duration) => (self: Duration) => Duration;
125
- }
126
-
127
- export { Brand as B, Duration as D };