effect 3.5.2 → 3.5.4

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 (44) hide show
  1. package/dist/cjs/Channel.js +7 -2
  2. package/dist/cjs/Channel.js.map +1 -1
  3. package/dist/cjs/Data.js +3 -3
  4. package/dist/cjs/Data.js.map +1 -1
  5. package/dist/cjs/Option.js.map +1 -1
  6. package/dist/cjs/Predicate.js.map +1 -1
  7. package/dist/cjs/internal/cause.js +6 -3
  8. package/dist/cjs/internal/cause.js.map +1 -1
  9. package/dist/cjs/internal/clock.js +2 -0
  10. package/dist/cjs/internal/clock.js.map +1 -1
  11. package/dist/cjs/internal/logger.js +3 -3
  12. package/dist/cjs/internal/logger.js.map +1 -1
  13. package/dist/cjs/internal/version.js +1 -1
  14. package/dist/dts/Channel.d.ts +5 -0
  15. package/dist/dts/Channel.d.ts.map +1 -1
  16. package/dist/dts/Option.d.ts +1 -1
  17. package/dist/dts/Option.d.ts.map +1 -1
  18. package/dist/dts/Predicate.d.ts +2 -0
  19. package/dist/dts/Predicate.d.ts.map +1 -1
  20. package/dist/dts/Stream.d.ts +1 -1
  21. package/dist/dts/Stream.d.ts.map +1 -1
  22. package/dist/esm/Channel.js +5 -0
  23. package/dist/esm/Channel.js.map +1 -1
  24. package/dist/esm/Data.js +3 -3
  25. package/dist/esm/Data.js.map +1 -1
  26. package/dist/esm/Option.js.map +1 -1
  27. package/dist/esm/Predicate.js.map +1 -1
  28. package/dist/esm/internal/cause.js +6 -3
  29. package/dist/esm/internal/cause.js.map +1 -1
  30. package/dist/esm/internal/clock.js +2 -0
  31. package/dist/esm/internal/clock.js.map +1 -1
  32. package/dist/esm/internal/logger.js +3 -3
  33. package/dist/esm/internal/logger.js.map +1 -1
  34. package/dist/esm/internal/version.js +1 -1
  35. package/package.json +1 -1
  36. package/src/Channel.ts +14 -0
  37. package/src/Data.ts +1 -1
  38. package/src/Option.ts +6 -4
  39. package/src/Predicate.ts +2 -0
  40. package/src/Stream.ts +1 -1
  41. package/src/internal/cause.ts +8 -4
  42. package/src/internal/clock.ts +2 -0
  43. package/src/internal/logger.ts +10 -3
  44. package/src/internal/version.ts +1 -1
package/src/Data.ts CHANGED
@@ -532,7 +532,7 @@ export const Error: new<A extends Record<string, any> = {}>(
532
532
  ) => Cause.YieldableError & Readonly<A> = (function() {
533
533
  return class Base extends core.YieldableError {
534
534
  constructor(args: any) {
535
- super(args?.message, { cause: args?.cause })
535
+ super(args?.message, args?.cause ? { cause: args.cause } : undefined)
536
536
  if (args) {
537
537
  Object.assign(this, args)
538
538
  }
package/src/Option.ts CHANGED
@@ -422,14 +422,16 @@ export const orElseEither: {
422
422
  * @category error handling
423
423
  * @since 2.0.0
424
424
  */
425
- export const firstSomeOf = <A>(collection: Iterable<Option<A>>): Option<A> => {
426
- let out: Option<A> = none()
425
+ export const firstSomeOf = <T, C extends Iterable<Option<T>> = Iterable<Option<T>>>(
426
+ collection: C
427
+ ): [C] extends [Iterable<Option<infer A>>] ? Option<A> : never => {
428
+ let out: Option<unknown> = none()
427
429
  for (out of collection) {
428
430
  if (isSome(out)) {
429
- return out
431
+ return out as any
430
432
  }
431
433
  }
432
- return out
434
+ return out as any
433
435
  }
434
436
 
435
437
  /**
package/src/Predicate.ts CHANGED
@@ -750,6 +750,8 @@ export const not = <A>(self: Predicate<A>): Predicate<A> => (a) => !self(a)
750
750
  * @since 2.0.0
751
751
  */
752
752
  export const or: {
753
+ <A, C extends A>(that: Refinement<A, C>): <B extends A>(self: Refinement<A, B>) => Refinement<A, B | C>
754
+ <A, B extends A, C extends A>(self: Refinement<A, B>, that: Refinement<A, C>): Refinement<A, B | C>
753
755
  <A>(that: Predicate<A>): (self: Predicate<A>) => Predicate<A>
754
756
  <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A>
755
757
  } = dual(2, <A>(self: Predicate<A>, that: Predicate<A>): Predicate<A> => (a) => self(a) || that(a))
package/src/Stream.ts CHANGED
@@ -3679,7 +3679,7 @@ export const retry: {
3679
3679
  export const run: {
3680
3680
  <A2, A, E2, R2>(
3681
3681
  sink: Sink.Sink<A2, A, unknown, E2, R2>
3682
- ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<A2, E2 | E, R2 | R>
3682
+ ): <E, R>(self: Stream<A, E, R>) => Effect.Effect<A2, E2 | E, Exclude<R | R2, Scope.Scope>>
3683
3683
  <A, E, R, A2, E2, R2>(
3684
3684
  self: Stream<A, E, R>,
3685
3685
  sink: Sink.Sink<A2, A, unknown, E2, R2>
@@ -990,6 +990,9 @@ const renderErrorCause = (cause: PrettyError, prefix: string) => {
990
990
  for (let i = 1, len = lines.length; i < len; i++) {
991
991
  stack += `\n${prefix}${lines[i]}`
992
992
  }
993
+ if (cause.cause) {
994
+ stack += ` {\n${renderErrorCause(cause.cause as PrettyError, `${prefix} `)}\n${prefix}}`
995
+ }
993
996
  return stack
994
997
  }
995
998
 
@@ -999,11 +1002,12 @@ class PrettyError extends globalThis.Error implements Cause.PrettyError {
999
1002
  const originalErrorIsObject = typeof originalError === "object" && originalError !== null
1000
1003
  const prevLimit = Error.stackTraceLimit
1001
1004
  Error.stackTraceLimit = 1
1002
- super(prettyErrorMessage(originalError), {
1003
- cause: originalErrorIsObject && "cause" in originalError && typeof originalError.cause !== "undefined"
1004
- ? new PrettyError(originalError.cause)
1005
+ super(
1006
+ prettyErrorMessage(originalError),
1007
+ originalErrorIsObject && "cause" in originalError && typeof originalError.cause !== "undefined"
1008
+ ? { cause: new PrettyError(originalError.cause) }
1005
1009
  : undefined
1006
- })
1010
+ )
1007
1011
  if (this.message === "") {
1008
1012
  this.message = "An error has occurred"
1009
1013
  }
@@ -42,6 +42,8 @@ const performanceNowNanos = (function() {
42
42
  const bigint1e6 = BigInt(1_000_000)
43
43
  if (typeof performance === "undefined") {
44
44
  return () => BigInt(Date.now()) * bigint1e6
45
+ } else if (typeof performance.timeOrigin === "number" && performance.timeOrigin === 0) {
46
+ return () => BigInt(Math.round(performance.now() * 1_000_000))
45
47
  }
46
48
  const origin = (BigInt(Date.now()) * bigint1e6) - BigInt(Math.round(performance.now() * 1_000_000))
47
49
  return () => origin + BigInt(Math.round(performance.now() * 1_000_000))
@@ -416,9 +416,16 @@ const defaultDateFormat = (date: Date): string =>
416
416
  date.getSeconds().toString().padStart(2, "0")
417
417
  }.${date.getMilliseconds().toString().padStart(3, "0")}`
418
418
 
419
- const processStdoutIsTTY = typeof process === "object" && "stdout" in process && process.stdout.isTTY === true
419
+ const processStdoutIsTTY = typeof process === "object" &&
420
+ process !== null &&
421
+ typeof process.stdout === "object" &&
422
+ process.stdout !== null &&
423
+ process.stdout.isTTY === true
420
424
  const hasWindow = typeof window === "object"
421
- const isWorker = typeof self === "object" && self.constructor && self.constructor.name.includes("Worker")
425
+ const isWorker = typeof self === "object" &&
426
+ self !== null &&
427
+ typeof self.constructor === "function" &&
428
+ self.constructor.name.includes("Worker")
422
429
 
423
430
  /** @internal */
424
431
  export const prettyLogger = (options?: {
@@ -534,7 +541,7 @@ const prettyLoggerBrowser = (options: {
534
541
  if (typeof firstMaybeString === "string") {
535
542
  firstLine += ` ${color}${firstMaybeString}`
536
543
  if (options.colors) {
537
- firstParams.push("color:blue")
544
+ firstParams.push("color:deepskyblue")
538
545
  }
539
546
  messageIndex++
540
547
  }
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.5.2"
1
+ let moduleVersion = "3.5.4"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4