effect 3.6.4 → 3.6.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.
Files changed (62) hide show
  1. package/dist/cjs/Metric.js +12 -3
  2. package/dist/cjs/Metric.js.map +1 -1
  3. package/dist/cjs/MetricHook.js +6 -1
  4. package/dist/cjs/MetricHook.js.map +1 -1
  5. package/dist/cjs/Pipeable.js +2 -0
  6. package/dist/cjs/Pipeable.js.map +1 -1
  7. package/dist/cjs/Stream.js +10 -10
  8. package/dist/cjs/internal/configProvider.js +1 -1
  9. package/dist/cjs/internal/configProvider.js.map +1 -1
  10. package/dist/cjs/internal/metric/hook.js +32 -10
  11. package/dist/cjs/internal/metric/hook.js.map +1 -1
  12. package/dist/cjs/internal/metric/keyType.js +12 -48
  13. package/dist/cjs/internal/metric/keyType.js.map +1 -1
  14. package/dist/cjs/internal/metric/polling.js +7 -1
  15. package/dist/cjs/internal/metric/polling.js.map +1 -1
  16. package/dist/cjs/internal/metric.js +21 -13
  17. package/dist/cjs/internal/metric.js.map +1 -1
  18. package/dist/cjs/internal/stream.js +10 -10
  19. package/dist/cjs/internal/stream.js.map +1 -1
  20. package/dist/cjs/internal/version.js +1 -1
  21. package/dist/dts/Metric.d.ts +21 -8
  22. package/dist/dts/Metric.d.ts.map +1 -1
  23. package/dist/dts/MetricHook.d.ts +10 -0
  24. package/dist/dts/MetricHook.d.ts.map +1 -1
  25. package/dist/dts/Pipeable.d.ts +1 -0
  26. package/dist/dts/Pipeable.d.ts.map +1 -1
  27. package/dist/dts/Stream.d.ts +28 -28
  28. package/dist/dts/Stream.d.ts.map +1 -1
  29. package/dist/dts/internal/metric/keyType.d.ts +1 -89
  30. package/dist/dts/internal/metric/keyType.d.ts.map +1 -1
  31. package/dist/esm/Metric.js +11 -2
  32. package/dist/esm/Metric.js.map +1 -1
  33. package/dist/esm/MetricHook.js +5 -0
  34. package/dist/esm/MetricHook.js.map +1 -1
  35. package/dist/esm/Pipeable.js +2 -0
  36. package/dist/esm/Pipeable.js.map +1 -1
  37. package/dist/esm/Stream.js +10 -10
  38. package/dist/esm/internal/configProvider.js +1 -1
  39. package/dist/esm/internal/configProvider.js.map +1 -1
  40. package/dist/esm/internal/metric/hook.js +31 -9
  41. package/dist/esm/internal/metric/hook.js.map +1 -1
  42. package/dist/esm/internal/metric/keyType.js +12 -48
  43. package/dist/esm/internal/metric/keyType.js.map +1 -1
  44. package/dist/esm/internal/metric/polling.js +7 -1
  45. package/dist/esm/internal/metric/polling.js.map +1 -1
  46. package/dist/esm/internal/metric.js +20 -12
  47. package/dist/esm/internal/metric.js.map +1 -1
  48. package/dist/esm/internal/stream.js +10 -10
  49. package/dist/esm/internal/stream.js.map +1 -1
  50. package/dist/esm/internal/version.js +1 -1
  51. package/package.json +1 -1
  52. package/src/Metric.ts +25 -9
  53. package/src/MetricHook.ts +11 -0
  54. package/src/Pipeable.ts +3 -0
  55. package/src/Stream.ts +49 -49
  56. package/src/internal/configProvider.ts +1 -1
  57. package/src/internal/metric/hook.ts +36 -9
  58. package/src/internal/metric/keyType.ts +12 -48
  59. package/src/internal/metric/polling.ts +8 -1
  60. package/src/internal/metric.ts +61 -17
  61. package/src/internal/stream.ts +134 -134
  62. package/src/internal/version.ts +1 -1
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.6.4";
1
+ let moduleVersion = "3.6.6";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect",
3
- "version": "3.6.4",
3
+ "version": "3.6.6",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/Metric.ts CHANGED
@@ -56,6 +56,7 @@ export interface Metric<in out Type, in In, out Out> extends Metric.Variance<Typ
56
56
  readonly keyType: Type
57
57
  unsafeUpdate(input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>): void
58
58
  unsafeValue(extraTags: ReadonlyArray<MetricLabel.MetricLabel>): Out
59
+ unsafeModify(input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>): void
59
60
  register(): this
60
61
  <A extends In, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>
61
62
  }
@@ -68,7 +69,8 @@ export interface MetricApply {
68
69
  <Type, In, Out>(
69
70
  keyType: Type,
70
71
  unsafeUpdate: (input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => void,
71
- unsafeValue: (extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => Out
72
+ unsafeValue: (extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => Out,
73
+ unsafeModify: (input: In, extraTags: ReadonlyArray<MetricLabel.MetricLabel>) => void
72
74
  ): Metric<Type, In, Out>
73
75
  }
74
76
 
@@ -306,20 +308,21 @@ export const histogram: (
306
308
 
307
309
  /**
308
310
  * @since 2.0.0
309
- * @category aspects
311
+ * @category combinators
310
312
  */
311
- export const increment: (self: Metric.Counter<number> | Metric.Counter<bigint>) => Effect.Effect<void> =
312
- internal.increment
313
+ export const increment: (
314
+ self: Metric.Counter<number> | Metric.Counter<bigint> | Metric.Gauge<number> | Metric.Gauge<bigint>
315
+ ) => Effect.Effect<void> = internal.increment
313
316
 
314
317
  /**
315
318
  * @since 2.0.0
316
- * @category aspects
319
+ * @category combinators
317
320
  */
318
321
  export const incrementBy: {
319
- (amount: number): (self: Metric.Counter<number>) => Effect.Effect<void>
320
- (amount: bigint): (self: Metric.Counter<bigint>) => Effect.Effect<void>
321
- (self: Metric.Counter<number>, amount: number): Effect.Effect<void>
322
- (self: Metric.Counter<bigint>, amount: bigint): Effect.Effect<void>
322
+ (amount: number): (self: Metric.Counter<number> | Metric.Counter<number>) => Effect.Effect<void>
323
+ (amount: bigint): (self: Metric.Counter<bigint> | Metric.Gauge<bigint>) => Effect.Effect<void>
324
+ (self: Metric.Counter<number> | Metric.Gauge<number>, amount: number): Effect.Effect<void>
325
+ (self: Metric.Counter<bigint> | Metric.Gauge<bigint>, amount: bigint): Effect.Effect<void>
323
326
  } = internal.incrementBy
324
327
 
325
328
  /**
@@ -344,6 +347,19 @@ export const mapType: {
344
347
  <Type, In, Out, Type2>(self: Metric<Type, In, Out>, f: (type: Type) => Type2): Metric<Type2, In, Out>
345
348
  } = internal.mapType
346
349
 
350
+ /**
351
+ * Modifies the metric with the specified update message. For example, if the
352
+ * metric were a gauge, the update would increment the method by the provided
353
+ * amount.
354
+ *
355
+ * @since 3.6.5
356
+ * @category utils
357
+ */
358
+ export const modify: {
359
+ <In>(input: In): <Type, Out>(self: Metric<Type, In, Out>) => Effect.Effect<void>
360
+ <Type, In, Out>(self: Metric<Type, In, Out>, input: In): Effect.Effect<void>
361
+ } = internal.modify
362
+
347
363
  /**
348
364
  * @since 2.0.0
349
365
  * @category aspects
package/src/MetricHook.ts CHANGED
@@ -27,6 +27,7 @@ export type MetricHookTypeId = typeof MetricHookTypeId
27
27
  export interface MetricHook<in In, out Out> extends MetricHook.Variance<In, Out>, Pipeable {
28
28
  get(): Out
29
29
  update(input: In): void
30
+ modify(input: In): void
30
31
  }
31
32
 
32
33
  /**
@@ -94,6 +95,7 @@ export declare namespace MetricHook {
94
95
  export const make: <In, Out>(options: {
95
96
  readonly get: LazyArg<Out>
96
97
  readonly update: (input: In) => void
98
+ readonly modify: (input: In) => void
97
99
  }) => MetricHook<In, Out> = internal.make
98
100
 
99
101
  /**
@@ -138,3 +140,12 @@ export const onUpdate: {
138
140
  <In, Out>(f: (input: In) => void): (self: MetricHook<In, Out>) => MetricHook<In, Out>
139
141
  <In, Out>(self: MetricHook<In, Out>, f: (input: In) => void): MetricHook<In, Out>
140
142
  } = internal.onUpdate
143
+
144
+ /**
145
+ * @since 3.6.5
146
+ * @category utils
147
+ */
148
+ export const onModify: {
149
+ <In, Out>(f: (input: In) => void): (self: MetricHook<In, Out>) => MetricHook<In, Out>
150
+ <In, Out>(self: MetricHook<In, Out>, f: (input: In) => void): MetricHook<In, Out>
151
+ } = internal.onModify
package/src/Pipeable.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * @category models
8
8
  */
9
9
  export interface Pipeable {
10
+ pipe<A>(this: A): A
10
11
  pipe<A, B>(this: A, ab: (_: A) => B): B
11
12
  pipe<A, B, C>(this: A, ab: (_: A) => B, bc: (_: B) => C): C
12
13
  pipe<A, B, C, D>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D
@@ -289,6 +290,8 @@ export interface Pipeable {
289
290
  */
290
291
  export const pipeArguments = <A>(self: A, args: IArguments): unknown => {
291
292
  switch (args.length) {
293
+ case 0:
294
+ return self
292
295
  case 1:
293
296
  return args[0](self)
294
297
  case 2:
package/src/Stream.ts CHANGED
@@ -1009,8 +1009,8 @@ export const concatAll: <A, E, R>(streams: Chunk.Chunk<Stream<A, E, R>>) => Stre
1009
1009
 
1010
1010
  /**
1011
1011
  * Composes this stream with the specified stream to create a cartesian
1012
- * product of elements. The `that` stream would be run multiple times, for
1013
- * every element in the `this` stream.
1012
+ * product of elements. The `right` stream would be run multiple times, for
1013
+ * every element in the `left` stream.
1014
1014
  *
1015
1015
  * See also `Stream.zip` for the more common point-wise variant.
1016
1016
  *
@@ -1034,14 +1034,14 @@ export const concatAll: <A, E, R>(streams: Chunk.Chunk<Stream<A, E, R>>) => Stre
1034
1034
  * @category utils
1035
1035
  */
1036
1036
  export const cross: {
1037
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<[A, A2], E2 | E, R2 | R>
1038
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<[A, A2], E | E2, R | R2>
1037
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<[AL, AR], EL | ER, RL | RR>
1038
+ <AL, ER, RR, AR, EL, RL>(left: Stream<AL, ER, RR>, right: Stream<AR, EL, RL>): Stream<[AL, AR], EL | ER, RL | RR>
1039
1039
  } = internal.cross
1040
1040
 
1041
1041
  /**
1042
1042
  * Composes this stream with the specified stream to create a cartesian
1043
- * product of elements, but keeps only elements from this stream. The `that`
1044
- * stream would be run multiple times, for every element in the `this` stream.
1043
+ * product of elements, but keeps only elements from `left` stream. The `right`
1044
+ * stream would be run multiple times, for every element in the `left` stream.
1045
1045
  *
1046
1046
  * See also `Stream.zipLeft` for the more common point-wise variant.
1047
1047
  *
@@ -1049,14 +1049,14 @@ export const cross: {
1049
1049
  * @category utils
1050
1050
  */
1051
1051
  export const crossLeft: {
1052
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R>
1053
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A, E | E2, R | R2>
1052
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<AL, EL | ER, RL | RR>
1053
+ <AL, EL, RL, AR, ER, RR>(left: Stream<AL, EL, RL>, right: Stream<AR, ER, RR>): Stream<AL, EL | ER, RL | RR>
1054
1054
  } = internal.crossLeft
1055
1055
 
1056
1056
  /**
1057
1057
  * Composes this stream with the specified stream to create a cartesian
1058
- * product of elements, but keeps only elements from the other stream. The
1059
- * `that` stream would be run multiple times, for every element in the `this`
1058
+ * product of elements, but keeps only elements from the `right` stream. The
1059
+ * `left` stream would be run multiple times, for every element in the `right`
1060
1060
  * stream.
1061
1061
  *
1062
1062
  * See also `Stream.zipRight` for the more common point-wise variant.
@@ -1065,14 +1065,14 @@ export const crossLeft: {
1065
1065
  * @category utils
1066
1066
  */
1067
1067
  export const crossRight: {
1068
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R>
1069
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A2, E | E2, R | R2>
1068
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<AR, EL | ER, RL | RR>
1069
+ <AL, EL, RL, AR, ER, RR>(left: Stream<AL, EL, RL>, right: Stream<AR, ER, RR>): Stream<AR, EL | ER, RL | RR>
1070
1070
  } = internal.crossRight
1071
1071
 
1072
1072
  /**
1073
1073
  * Composes this stream with the specified stream to create a cartesian
1074
- * product of elements with a specified function. The `that` stream would be
1075
- * run multiple times, for every element in the `this` stream.
1074
+ * product of elements with a specified function. The `right` stream would be
1075
+ * run multiple times, for every element in the `left` stream.
1076
1076
  *
1077
1077
  * See also `Stream.zipWith` for the more common point-wise variant.
1078
1078
  *
@@ -1080,15 +1080,15 @@ export const crossRight: {
1080
1080
  * @category utils
1081
1081
  */
1082
1082
  export const crossWith: {
1083
- <B, E2, R2, A, C>(
1084
- that: Stream<B, E2, R2>,
1085
- f: (a: A, b: B) => C
1086
- ): <E, R>(self: Stream<A, E, R>) => Stream<C, E2 | E, R2 | R>
1087
- <A, E, R, B, E2, R2, C>(
1088
- self: Stream<A, E, R>,
1089
- that: Stream<B, E2, R2>,
1090
- f: (a: A, b: B) => C
1091
- ): Stream<C, E | E2, R | R2>
1083
+ <AR, ER, RR, AL, A>(
1084
+ right: Stream<AR, ER, RR>,
1085
+ f: (left: AL, right: AR) => A
1086
+ ): <EL, RL>(left: Stream<AL, EL, RL>) => Stream<A, EL | ER, RL | RR>
1087
+ <AL, EL, RL, AR, ER, RR, A>(
1088
+ left: Stream<AL, EL, RL>,
1089
+ right: Stream<AR, ER, RR>,
1090
+ f: (left: AL, right: AR) => A
1091
+ ): Stream<A, EL | ER, RL | RR>
1092
1092
  } = internal.crossWith
1093
1093
 
1094
1094
  /**
@@ -5519,8 +5519,8 @@ export const zipAllWith: {
5519
5519
  * @category zipping
5520
5520
  */
5521
5521
  export const zipLatest: {
5522
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<[A, A2], E2 | E, R2 | R>
5523
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<[A, A2], E | E2, R | R2>
5522
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<[AL, AR], EL | ER, RL | RR>
5523
+ <AL, EL, RL, AR, ER, RR>(left: Stream<AL, EL, RL>, right: Stream<AR, ER, RR>): Stream<[AL, AR], EL | ER, RL | RR>
5524
5524
  } = internal.zipLatest
5525
5525
 
5526
5526
  /**
@@ -5575,20 +5575,20 @@ export const zipLatestAll: <T extends ReadonlyArray<Stream<any, any, any>>>(
5575
5575
  * @category zipping
5576
5576
  */
5577
5577
  export const zipLatestWith: {
5578
- <A2, E2, R2, A, A3>(
5579
- that: Stream<A2, E2, R2>,
5580
- f: (a: A, a2: A2) => A3
5581
- ): <E, R>(self: Stream<A, E, R>) => Stream<A3, E2 | E, R2 | R>
5582
- <A, E, R, A2, E2, R2, A3>(
5583
- self: Stream<A, E, R>,
5584
- that: Stream<A2, E2, R2>,
5585
- f: (a: A, a2: A2) => A3
5586
- ): Stream<A3, E | E2, R | R2>
5578
+ <AR, ER, RR, AL, A>(
5579
+ right: Stream<AR, ER, RR>,
5580
+ f: (left: AL, right: AR) => A
5581
+ ): <EL, RL>(left: Stream<AL, EL, RL>) => Stream<A, EL | ER, RL | RR>
5582
+ <AL, EL, RL, AR, ER, RR, A>(
5583
+ left: Stream<AL, EL, RL>,
5584
+ right: Stream<AR, ER, RR>,
5585
+ f: (left: AL, right: AR) => A
5586
+ ): Stream<A, EL | ER, RL | RR>
5587
5587
  } = internal.zipLatestWith
5588
5588
 
5589
5589
  /**
5590
5590
  * Zips this stream with another point-wise, but keeps only the outputs of
5591
- * this stream.
5591
+ * `left` stream.
5592
5592
  *
5593
5593
  * The new stream will end when one of the sides ends.
5594
5594
  *
@@ -5596,13 +5596,13 @@ export const zipLatestWith: {
5596
5596
  * @category zipping
5597
5597
  */
5598
5598
  export const zipLeft: {
5599
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A, E2 | E, R2 | R>
5600
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A, E | E2, R | R2>
5599
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<AL, ER | EL, RR | RL>
5600
+ <AL, EL, RL, AR, ER, RR>(left: Stream<AL, EL, RL>, right: Stream<AR, ER, RR>): Stream<AL, EL | ER, RL | RR>
5601
5601
  } = internal.zipLeft
5602
5602
 
5603
5603
  /**
5604
5604
  * Zips this stream with another point-wise, but keeps only the outputs of the
5605
- * other stream.
5605
+ * `right` stream.
5606
5606
  *
5607
5607
  * The new stream will end when one of the sides ends.
5608
5608
  *
@@ -5610,8 +5610,8 @@ export const zipLeft: {
5610
5610
  * @category zipping
5611
5611
  */
5612
5612
  export const zipRight: {
5613
- <A2, E2, R2>(that: Stream<A2, E2, R2>): <A, E, R>(self: Stream<A, E, R>) => Stream<A2, E2 | E, R2 | R>
5614
- <A, E, R, A2, E2, R2>(self: Stream<A, E, R>, that: Stream<A2, E2, R2>): Stream<A2, E | E2, R | R2>
5613
+ <AR, ER, RR>(right: Stream<AR, ER, RR>): <AL, EL, RL>(left: Stream<AL, EL, RL>) => Stream<AR, ER | EL, RR | RL>
5614
+ <AL, EL, RL, AR, ER, RR>(left: Stream<AL, EL, RL>, right: Stream<AR, ER, RR>): Stream<AR, EL | ER, RL | RR>
5615
5615
  } = internal.zipRight
5616
5616
 
5617
5617
  /**
@@ -5637,15 +5637,15 @@ export const zipRight: {
5637
5637
  * @category zipping
5638
5638
  */
5639
5639
  export const zipWith: {
5640
- <A2, E2, R2, A, A3>(
5641
- that: Stream<A2, E2, R2>,
5642
- f: (a: A, a2: A2) => A3
5643
- ): <E, R>(self: Stream<A, E, R>) => Stream<A3, E2 | E, R2 | R>
5644
- <A, E, R, A2, E2, R2, A3>(
5645
- self: Stream<A, E, R>,
5646
- that: Stream<A2, E2, R2>,
5647
- f: (a: A, a2: A2) => A3
5648
- ): Stream<A3, E | E2, R | R2>
5640
+ <AR, ER, RR, AL, A>(
5641
+ right: Stream<AR, ER, RR>,
5642
+ f: (left: AL, right: AR) => A
5643
+ ): <EL, RL>(left: Stream<AL, EL, RL>) => Stream<A, EL | ER, RL | RR>
5644
+ <AL, EL, RL, AR, ER, RR, A>(
5645
+ left: Stream<AL, EL, RL>,
5646
+ right: Stream<AR, ER, RR>,
5647
+ f: (left: AL, right: AR) => A
5648
+ ): Stream<A, EL | ER, RL | RR>
5649
5649
  } = internal.zipWith
5650
5650
 
5651
5651
  /**
@@ -329,7 +329,7 @@ const fromFlatLoop = <A>(
329
329
  core.flatMap((indices) => {
330
330
  if (indices.length === 0) {
331
331
  return core.suspend(() =>
332
- core.map(fromFlatLoop(flat, patchedPrefix, op.config, true), Arr.of)
332
+ core.map(fromFlatLoop(flat, prefix, op.config, true), Arr.of)
333
333
  ) as unknown as Effect.Effect<Array<A>, ConfigError.ConfigError>
334
334
  }
335
335
  return pipe(
@@ -30,6 +30,7 @@ export const make = <In, Out>(
30
30
  options: {
31
31
  readonly get: LazyArg<Out>
32
32
  readonly update: (input: In) => void
33
+ readonly modify: (input: In) => void
33
34
  }
34
35
  ): MetricHook.MetricHook<In, Out> => ({
35
36
  [MetricHookTypeId]: metricHookVariance,
@@ -39,6 +40,23 @@ export const make = <In, Out>(
39
40
  ...options
40
41
  })
41
42
 
43
+ /** @internal */
44
+ export const onModify = dual<
45
+ <In, Out>(f: (input: In) => void) => (self: MetricHook.MetricHook<In, Out>) => MetricHook.MetricHook<In, Out>,
46
+ <In, Out>(self: MetricHook.MetricHook<In, Out>, f: (input: In) => void) => MetricHook.MetricHook<In, Out>
47
+ >(2, (self, f) => ({
48
+ [MetricHookTypeId]: metricHookVariance,
49
+ pipe() {
50
+ return pipeArguments(this, arguments)
51
+ },
52
+ get: self.get,
53
+ update: self.update,
54
+ modify: (input) => {
55
+ self.modify(input)
56
+ return f(input)
57
+ }
58
+ }))
59
+
42
60
  /** @internal */
43
61
  export const onUpdate = dual<
44
62
  <In, Out>(f: (input: In) => void) => (self: MetricHook.MetricHook<In, Out>) => MetricHook.MetricHook<In, Out>,
@@ -52,7 +70,8 @@ export const onUpdate = dual<
52
70
  update: (input) => {
53
71
  self.update(input)
54
72
  return f(input)
55
- }
73
+ },
74
+ modify: self.modify
56
75
  }))
57
76
 
58
77
  const bigint0 = BigInt(0)
@@ -67,13 +86,15 @@ export const counter = <A extends (number | bigint)>(
67
86
  ? (value: A) => value >= bigint0
68
87
  : (value: A) => value >= 0
69
88
  : (_value: A) => true
89
+ const update = (value: A) => {
90
+ if (canUpdate(value)) {
91
+ sum = (sum as any) + value
92
+ }
93
+ }
70
94
  return make({
71
95
  get: () => metricState.counter(sum as number) as unknown as MetricState.MetricState.Counter<A>,
72
- update: (value) => {
73
- if (canUpdate(value)) {
74
- sum = (sum as any) + value
75
- }
76
- }
96
+ update,
97
+ modify: update
77
98
  })
78
99
  }
79
100
 
@@ -89,7 +110,8 @@ export const frequency = (key: MetricKey.MetricKey.Frequency): MetricHook.Metric
89
110
  }
90
111
  return make({
91
112
  get: () => metricState.frequency(values),
92
- update
113
+ update,
114
+ modify: update
93
115
  })
94
116
  }
95
117
 
@@ -106,6 +128,9 @@ export const gauge: {
106
128
  get: () => metricState.gauge(value as number) as unknown as MetricState.MetricState.Gauge<A>,
107
129
  update: (v) => {
108
130
  value = v
131
+ },
132
+ modify: (v) => {
133
+ value = (value as any) + v
109
134
  }
110
135
  })
111
136
  }
@@ -182,7 +207,8 @@ export const histogram = (key: MetricKey.MetricKey.Histogram): MetricHook.Metric
182
207
  max,
183
208
  sum
184
209
  }),
185
- update
210
+ update,
211
+ modify: update
186
212
  })
187
213
  }
188
214
 
@@ -258,7 +284,8 @@ export const summary = (key: MetricKey.MetricKey.Summary): MetricHook.MetricHook
258
284
  max,
259
285
  sum
260
286
  }),
261
- update: ([value, timestamp]) => observe(value, timestamp)
287
+ update: ([value, timestamp]) => observe(value, timestamp),
288
+ modify: ([value, timestamp]) => observe(value, timestamp)
262
289
  })
263
290
  }
264
291
 
@@ -117,10 +117,7 @@ class GaugeKeyType<A extends (number | bigint)> implements MetricKeyType.MetricK
117
117
  }
118
118
  }
119
119
 
120
- /**
121
- * @category model
122
- * @since 2.0.0
123
- */
120
+ /** @internal */
124
121
  export class HistogramKeyType implements MetricKeyType.MetricKeyType.Histogram {
125
122
  readonly [MetricKeyTypeTypeId] = metricKeyTypeVariance
126
123
  readonly [HistogramKeyTypeTypeId]: MetricKeyType.HistogramKeyTypeTypeId = HistogramKeyTypeTypeId
@@ -176,10 +173,7 @@ class SummaryKeyType implements MetricKeyType.MetricKeyType.Summary {
176
173
  }
177
174
  }
178
175
 
179
- /**
180
- * @since 2.0.0
181
- * @category constructors
182
- */
176
+ /** @internal */
183
177
  export const counter: <A extends number | bigint>(options?: {
184
178
  readonly bigint: boolean
185
179
  readonly incremental: boolean
@@ -189,18 +183,12 @@ export const counter: <A extends number | bigint>(options?: {
189
183
  options?.bigint ?? false
190
184
  )
191
185
 
192
- /**
193
- * @since 2.0.0
194
- * @category constructors
195
- */
186
+ /** @internal */
196
187
  export const frequency = (options?: {
197
188
  readonly preregisteredWords?: ReadonlyArray<string> | undefined
198
189
  }): MetricKeyType.MetricKeyType.Frequency => new FrequencyKeyType(options?.preregisteredWords ?? [])
199
190
 
200
- /**
201
- * @since 2.0.0
202
- * @category constructors
203
- */
191
+ /** @internal */
204
192
  export const gauge: <A extends number | bigint>(options?: {
205
193
  readonly bigint: boolean
206
194
  }) => GaugeKeyType<A> = (options) =>
@@ -208,18 +196,12 @@ export const gauge: <A extends number | bigint>(options?: {
208
196
  options?.bigint ?? false
209
197
  )
210
198
 
211
- /**
212
- * @since 2.0.0
213
- * @category constructors
214
- */
199
+ /** @internal */
215
200
  export const histogram = (boundaries: MetricBoundaries.MetricBoundaries): MetricKeyType.MetricKeyType.Histogram => {
216
201
  return new HistogramKeyType(boundaries)
217
202
  }
218
203
 
219
- /**
220
- * @since 2.0.0
221
- * @category constructors
222
- */
204
+ /** @internal */
223
205
  export const summary = (
224
206
  options: {
225
207
  readonly maxAge: Duration.DurationInput
@@ -231,44 +213,26 @@ export const summary = (
231
213
  return new SummaryKeyType(Duration.decode(options.maxAge), options.maxSize, options.error, options.quantiles)
232
214
  }
233
215
 
234
- /**
235
- * @since 2.0.0
236
- * @category refinements
237
- */
216
+ /** @internal */
238
217
  export const isMetricKeyType = (u: unknown): u is MetricKeyType.MetricKeyType<unknown, unknown> =>
239
218
  hasProperty(u, MetricKeyTypeTypeId)
240
219
 
241
- /**
242
- * @since 2.0.0
243
- * @category refinements
244
- */
220
+ /** @internal */
245
221
  export const isCounterKey = (u: unknown): u is MetricKeyType.MetricKeyType.Counter<number | bigint> =>
246
222
  hasProperty(u, CounterKeyTypeTypeId)
247
223
 
248
- /**
249
- * @since 2.0.0
250
- * @category refinements
251
- */
224
+ /** @internal */
252
225
  export const isFrequencyKey = (u: unknown): u is MetricKeyType.MetricKeyType.Frequency =>
253
226
  hasProperty(u, FrequencyKeyTypeTypeId)
254
227
 
255
- /**
256
- * @since 2.0.0
257
- * @category refinements
258
- */
228
+ /** @internal */
259
229
  export const isGaugeKey = (u: unknown): u is MetricKeyType.MetricKeyType.Gauge<number | bigint> =>
260
230
  hasProperty(u, GaugeKeyTypeTypeId)
261
231
 
262
- /**
263
- * @since 2.0.0
264
- * @category refinements
265
- */
232
+ /** @internal */
266
233
  export const isHistogramKey = (u: unknown): u is MetricKeyType.MetricKeyType.Histogram =>
267
234
  hasProperty(u, HistogramKeyTypeTypeId)
268
235
 
269
- /**
270
- * @since 2.0.0
271
- * @category refinements
272
- */
236
+ /** @internal */
273
237
  export const isSummaryKey = (u: unknown): u is MetricKeyType.MetricKeyType.Summary =>
274
238
  hasProperty(u, SummaryKeyTypeTypeId)
@@ -56,7 +56,14 @@ export const collectAll = <R, E, Out>(
56
56
  (extraTags) =>
57
57
  Array.from(
58
58
  metrics.map((pollingMetric) => pollingMetric.metric.unsafeValue(extraTags))
59
- )
59
+ ),
60
+ (inputs: Array<any>, extraTags) => {
61
+ for (let i = 0; i < inputs.length; i++) {
62
+ const pollingMetric = metrics[i]!
63
+ const input = pipe(inputs, (x) => x[i])
64
+ pollingMetric.metric.unsafeModify(input, extraTags)
65
+ }
66
+ }
60
67
  ),
61
68
  poll: core.forEachSequential(metrics, (metric) => metric.poll)
62
69
  }