effect 2.4.7 → 2.4.8

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.
@@ -54,10 +54,7 @@ export const make: Metric.MetricApply = function<Type, In, Out>(
54
54
  ): Metric.Metric<Type, In, Out> {
55
55
  const metric: Metric.Metric<Type, In, Out> = Object.assign(
56
56
  <A extends In, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> =>
57
- core.tap(
58
- effect,
59
- (a) => core.sync(() => unsafeUpdate(a, []))
60
- ),
57
+ core.tap(effect, (a) => update(metric, a)),
61
58
  {
62
59
  [MetricTypeId]: metricVariance,
63
60
  keyType,
@@ -345,14 +342,8 @@ export const trackAll = dual<
345
342
  ) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>
346
343
  >(2, (self, input) => (effect) =>
347
344
  core.matchCauseEffect(effect, {
348
- onFailure: (cause) => {
349
- self.unsafeUpdate(input, [])
350
- return core.failCause(cause)
351
- },
352
- onSuccess: (value) => {
353
- self.unsafeUpdate(input, [])
354
- return core.succeed(value)
355
- }
345
+ onFailure: (cause) => core.zipRight(update(self, input), core.failCause(cause)),
346
+ onSuccess: (value) => core.zipRight(update(self, input), core.succeed(value))
356
347
  }))
357
348
 
358
349
  /* @internal */
@@ -378,14 +369,8 @@ export const trackDefectWith = dual<
378
369
  f: (defect: unknown) => In
379
370
  ) => Effect.Effect<A, E, R>
380
371
  >(3, (self, metric, f) => {
381
- const updater = (defect: unknown): void => metric.unsafeUpdate(f(defect), [])
382
- return _effect.tapDefect(self, (cause) =>
383
- core.sync(() =>
384
- pipe(
385
- Cause.defects(cause),
386
- ReadonlyArray.forEach(updater)
387
- )
388
- ))
372
+ const updater = (defect: unknown) => update(metric, f(defect))
373
+ return _effect.tapDefect(self, (cause) => core.forEachSequentialDiscard(Cause.defects(cause), updater))
389
374
  })
390
375
 
391
376
  /* @internal */
@@ -413,11 +398,10 @@ export const trackDurationWith = dual<
413
398
  >(3, (self, metric, f) =>
414
399
  Clock.clockWith((clock) => {
415
400
  const startTime = clock.unsafeCurrentTimeNanos()
416
- return core.map(self, (a) => {
401
+ return core.tap(self, (_) => {
417
402
  const endTime = clock.unsafeCurrentTimeNanos()
418
403
  const duration = Duration.nanos(endTime - startTime)
419
- metric.unsafeUpdate(f(duration), [])
420
- return a
404
+ return update(metric, f(duration))
421
405
  })
422
406
  }))
423
407
 
@@ -1,4 +1,4 @@
1
- let moduleVersion = "2.4.7"
1
+ let moduleVersion = "2.4.8"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4