effect 3.2.4 → 3.2.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.
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.2.4";
1
+ let moduleVersion = "3.2.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.2.4",
3
+ "version": "3.2.6",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/Array.ts CHANGED
@@ -326,7 +326,7 @@ export const prepend: {
326
326
  * @since 2.0.0
327
327
  */
328
328
  export const prependAll: {
329
- <S extends ReadonlyArray<any> | Iterable<any>, T extends ReadonlyArray<any> | Iterable<any>>(
329
+ <S extends Iterable<any>, T extends Iterable<any>>(
330
330
  that: T
331
331
  ): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
332
332
  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>
@@ -363,7 +363,7 @@ export const append: {
363
363
  * @since 2.0.0
364
364
  */
365
365
  export const appendAll: {
366
- <S extends ReadonlyArray<any> | Iterable<any>, T extends ReadonlyArray<any> | Iterable<any>>(
366
+ <S extends Iterable<any>, T extends Iterable<any>>(
367
367
  that: T
368
368
  ): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
369
369
  <A, B>(self: Iterable<A>, that: NonEmptyReadonlyArray<B>): NonEmptyArray<A | B>
@@ -1365,7 +1365,7 @@ export const unzip: <S extends Iterable<readonly [any, any]> | NonEmptyReadonlyA
1365
1365
  export const intersperse: {
1366
1366
  <B>(
1367
1367
  middle: B
1368
- ): <S extends ReadonlyArray<any> | Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
1368
+ ): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S> | B>
1369
1369
  <A, B>(self: NonEmptyReadonlyArray<A>, middle: B): NonEmptyArray<A | B>
1370
1370
  <A, B>(self: Iterable<A>, middle: B): Array<A | B>
1371
1371
  } = dual(2, <A, B>(self: Iterable<A>, middle: B): Array<A | B> => {
@@ -1478,7 +1478,7 @@ export const setNonEmptyLast: {
1478
1478
  * @since 2.0.0
1479
1479
  */
1480
1480
  export const rotate: {
1481
- (n: number): <S extends ReadonlyArray<any> | Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
1481
+ (n: number): <S extends Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
1482
1482
  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<A>
1483
1483
  <A>(self: Iterable<A>, n: number): Array<A>
1484
1484
  } = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {
@@ -1567,7 +1567,7 @@ export const contains: {
1567
1567
  * @since 2.0.0
1568
1568
  */
1569
1569
  export const chop: {
1570
- <S extends ReadonlyArray<any> | Iterable<any>, B>(
1570
+ <S extends Iterable<any>, B>(
1571
1571
  f: (as: NonEmptyReadonlyArray<ReadonlyArray.Infer<S>>) => readonly [B, ReadonlyArray<ReadonlyArray.Infer<S>>]
1572
1572
  ): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
1573
1573
  <A, B>(
@@ -1742,7 +1742,7 @@ export const copy: {
1742
1742
  export const chunksOf: {
1743
1743
  (
1744
1744
  n: number
1745
- ): <S extends ReadonlyArray<any> | Iterable<any>>(
1745
+ ): <S extends Iterable<any>>(
1746
1746
  self: S
1747
1747
  ) => ReadonlyArray.With<S, NonEmptyArray<ReadonlyArray.Infer<S>>>
1748
1748
  <A>(self: NonEmptyReadonlyArray<A>, n: number): NonEmptyArray<NonEmptyArray<A>>
@@ -1864,7 +1864,7 @@ export const groupBy: {
1864
1864
  * @since 2.0.0
1865
1865
  */
1866
1866
  export const unionWith: {
1867
- <S extends ReadonlyArray<any> | Iterable<any>, T extends ReadonlyArray<any> | Iterable<any>>(
1867
+ <S extends Iterable<any>, T extends Iterable<any>>(
1868
1868
  that: T,
1869
1869
  isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<T>) => boolean
1870
1870
  ): (self: S) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
@@ -1906,9 +1906,9 @@ export const unionWith: {
1906
1906
  * @since 2.0.0
1907
1907
  */
1908
1908
  export const union: {
1909
- <T extends ReadonlyArray<any> | Iterable<any>>(
1909
+ <T extends Iterable<any>>(
1910
1910
  that: T
1911
- ): <S extends ReadonlyArray<any> | Iterable<any>>(
1911
+ ): <S extends Iterable<any>>(
1912
1912
  self: S
1913
1913
  ) => ReadonlyArray.OrNonEmpty<S, T, ReadonlyArray.Infer<S> | ReadonlyArray.Infer<T>>
1914
1914
  <A, B>(self: NonEmptyReadonlyArray<A>, that: ReadonlyArray<B>): NonEmptyArray<A | B>
@@ -2026,23 +2026,22 @@ export declare namespace ReadonlyArray {
2026
2026
  /**
2027
2027
  * @since 2.0.0
2028
2028
  */
2029
- export type Infer<S extends ReadonlyArray<any> | Iterable<any>> = S extends ReadonlyArray<infer A> ? A
2029
+ export type Infer<S extends Iterable<any>> = S extends ReadonlyArray<infer A> ? A
2030
2030
  : S extends Iterable<infer A> ? A
2031
2031
  : never
2032
2032
 
2033
2033
  /**
2034
2034
  * @since 2.0.0
2035
2035
  */
2036
- export type With<S extends ReadonlyArray<any> | Iterable<any>, A> = S extends NonEmptyReadonlyArray<any> ?
2037
- NonEmptyArray<A>
2036
+ export type With<S extends Iterable<any>, A> = S extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
2038
2037
  : Array<A>
2039
2038
 
2040
2039
  /**
2041
2040
  * @since 2.0.0
2042
2041
  */
2043
2042
  export type OrNonEmpty<
2044
- S extends ReadonlyArray<any> | Iterable<any>,
2045
- T extends ReadonlyArray<any> | Iterable<any>,
2043
+ S extends Iterable<any>,
2044
+ T extends Iterable<any>,
2046
2045
  A
2047
2046
  > = S extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
2048
2047
  : T extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
@@ -2052,8 +2051,8 @@ export declare namespace ReadonlyArray {
2052
2051
  * @since 2.0.0
2053
2052
  */
2054
2053
  export type AndNonEmpty<
2055
- S extends ReadonlyArray<any> | Iterable<any>,
2056
- T extends ReadonlyArray<any> | Iterable<any>,
2054
+ S extends Iterable<any>,
2055
+ T extends Iterable<any>,
2057
2056
  A
2058
2057
  > = S extends NonEmptyReadonlyArray<any> ? T extends NonEmptyReadonlyArray<any> ? NonEmptyArray<A>
2059
2058
  : Array<A>
@@ -2255,7 +2254,10 @@ export const partitionMap: {
2255
2254
  * @category filtering
2256
2255
  * @since 2.0.0
2257
2256
  */
2258
- export const getSomes: <A>(self: Iterable<Option<A>>) => Array<A> = filterMap(identity)
2257
+
2258
+ export const getSomes: <T extends Iterable<Option<X>>, X = any>(
2259
+ self: T
2260
+ ) => Array<Option.Value<ReadonlyArray.Infer<T>>> = filterMap(identity as any)
2259
2261
 
2260
2262
  /**
2261
2263
  * Retrieves the `Left` values from an `Iterable` of `Either`s, collecting them into an array.
@@ -2271,8 +2273,8 @@ export const getSomes: <A>(self: Iterable<Option<A>>) => Array<A> = filterMap(id
2271
2273
  * @category filtering
2272
2274
  * @since 2.0.0
2273
2275
  */
2274
- export const getLefts = <R, L>(self: Iterable<Either<R, L>>): Array<L> => {
2275
- const out: Array<L> = []
2276
+ export const getLefts = <T extends Iterable<Either<any, any>>>(self: T): Array<Either.Left<ReadonlyArray.Infer<T>>> => {
2277
+ const out: Array<any> = []
2276
2278
  for (const a of self) {
2277
2279
  if (E.isLeft(a)) {
2278
2280
  out.push(a.left)
@@ -2296,8 +2298,10 @@ export const getLefts = <R, L>(self: Iterable<Either<R, L>>): Array<L> => {
2296
2298
  * @category filtering
2297
2299
  * @since 2.0.0
2298
2300
  */
2299
- export const getRights = <R, L>(self: Iterable<Either<R, L>>): Array<R> => {
2300
- const out: Array<R> = []
2301
+ export const getRights = <T extends Iterable<Either<any, any>>>(
2302
+ self: T
2303
+ ): Array<Either.Right<ReadonlyArray.Infer<T>>> => {
2304
+ const out: Array<any> = []
2301
2305
  for (const a of self) {
2302
2306
  if (E.isRight(a)) {
2303
2307
  out.push(a.right)
@@ -2378,7 +2382,9 @@ export const partition: {
2378
2382
  * @category filtering
2379
2383
  * @since 2.0.0
2380
2384
  */
2381
- export const separate: <R, L>(self: Iterable<Either<R, L>>) => [Array<L>, Array<R>] = partitionMap(
2385
+ export const separate: <T extends Iterable<Either<any, any>>>(
2386
+ self: T
2387
+ ) => [Array<Either.Left<ReadonlyArray.Infer<T>>>, Array<Either.Right<ReadonlyArray.Infer<T>>>] = partitionMap(
2382
2388
  identity
2383
2389
  )
2384
2390
 
@@ -2700,7 +2706,7 @@ export const forEach: {
2700
2706
  * @since 2.0.0
2701
2707
  */
2702
2708
  export const dedupeWith: {
2703
- <S extends ReadonlyArray<any> | Iterable<any>>(
2709
+ <S extends Iterable<any>>(
2704
2710
  isEquivalent: (self: ReadonlyArray.Infer<S>, that: ReadonlyArray.Infer<S>) => boolean
2705
2711
  ): (self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
2706
2712
  <A>(self: NonEmptyReadonlyArray<A>, isEquivalent: (self: A, that: A) => boolean): NonEmptyArray<A>
@@ -27,33 +27,32 @@ export const RequestResolverTypeId: unique symbol = core.RequestResolverTypeId
27
27
  export type RequestResolverTypeId = typeof RequestResolverTypeId
28
28
 
29
29
  /**
30
- * A `RequestResolver<A, R>` requires an environment `R` and is capable of executing
31
- * requests of type `A`.
30
+ * The `RequestResolver<A, R>` interface requires an environment `R` and handles
31
+ * the execution of requests of type `A`.
32
32
  *
33
- * Data sources must implement the method `runAll` which takes a collection of
34
- * requests and returns an effect with a `RequestCompletionMap` containing a
35
- * mapping from requests to results. The type of the collection of requests is
36
- * a `Chunk<Chunk<A>>`. The outer `Chunk` represents batches of requests that
37
- * must be performed sequentially. The inner `Chunk` represents a batch of
38
- * requests that can be performed in parallel. This allows data sources to
39
- * introspect on all the requests being executed and optimize the query.
33
+ * Implementations must provide a `runAll` method, which processes a collection
34
+ * of requests and produces an effect that fulfills these requests. Requests are
35
+ * organized into a `Array<Array<A>>`, where the outer `Array` groups requests
36
+ * into batches that are executed sequentially, and each inner `Array` contains
37
+ * requests that can be executed in parallel. This structure allows
38
+ * implementations to analyze all incoming requests collectively and optimize
39
+ * query execution accordingly.
40
40
  *
41
- * Data sources will typically be parameterized on a subtype of `Request<A>`,
42
- * though that is not strictly necessarily as long as the data source can map
43
- * the request type to a `Request<A>`. Data sources can then pattern match on
44
- * the collection of requests to determine the information requested, execute
45
- * the query, and place the results into the `RequestCompletionMap` using
46
- * `RequestCompletionMap.empty` and `RequestCompletionMap.insert`. Data
47
- * sources must provide results for all requests received. Failure to do so
48
- * will cause a query to die with a `QueryFailure` when run.
41
+ * Implementations are typically specialized for a subtype of `Request<A, E>`.
42
+ * However, they are not strictly limited to these subtypes as long as they can
43
+ * map any given request type to `Request<A, E>`. Implementations should inspect
44
+ * the collection of requests to identify the needed information and execute the
45
+ * corresponding queries. It is imperative that implementations resolve all the
46
+ * requests they receive. Failing to do so will lead to a `QueryFailure` error
47
+ * during query execution.
49
48
  *
50
49
  * @since 2.0.0
51
50
  * @category models
52
51
  */
53
52
  export interface RequestResolver<in A, out R = never> extends RequestResolver.Variance<A, R>, Equal.Equal, Pipeable {
54
53
  /**
55
- * Execute a collection of requests. The outer `Chunk` represents batches
56
- * of requests that must be performed sequentially. The inner `Chunk`
54
+ * Execute a collection of requests. The outer `Array` represents batches
55
+ * of requests that must be performed sequentially. The inner `Array`
57
56
  * represents a batch of requests that can be performed in parallel.
58
57
  */
59
58
  runAll(requests: Array<Array<Request.Entry<A>>>): Effect.Effect<void, never, R>
@@ -132,8 +131,7 @@ export const makeWithEntry: <A, R>(
132
131
  ) => RequestResolver<A, R> = internal.makeWithEntry
133
132
 
134
133
  /**
135
- * Constructs a data source from a function taking a collection of requests
136
- * and returning a `RequestCompletionMap`.
134
+ * Constructs a data source from a function taking a collection of requests.
137
135
  *
138
136
  * @since 2.0.0
139
137
  * @category constructors
package/src/Types.ts CHANGED
@@ -187,7 +187,6 @@ export type Mutable<T> = {
187
187
  */
188
188
  export type DeepMutable<T> = T extends ReadonlyMap<infer K, infer V> ? Map<DeepMutable<K>, DeepMutable<V>>
189
189
  : T extends ReadonlySet<infer V> ? Set<DeepMutable<V>>
190
- : T extends ReadonlyArray<infer V> ? Array<DeepMutable<V>>
191
190
  : [keyof T] extends [never] ? T
192
191
  : { -readonly [K in keyof T]: DeepMutable<T[K]> }
193
192
 
@@ -1781,7 +1781,6 @@ export class RequestResolverImpl<in A, out R> implements RequestResolver.Request
1781
1781
  ) => Effect.Effect<void, never, R>,
1782
1782
  readonly target?: unknown
1783
1783
  ) {
1784
- this.runAll = runAll as any
1785
1784
  }
1786
1785
  [Hash.symbol](): number {
1787
1786
  return Hash.cached(this, this.target ? Hash.hash(this.target) : Hash.random(this))
@@ -6555,7 +6555,7 @@ export const toReadableStreamRuntime = dual<
6555
6555
  <A, E, XR, R extends XR>(self: Stream.Stream<A, E, R>, runtime: Runtime.Runtime<XR>) => ReadableStream<A>
6556
6556
  >(2, <A, E, XR, R extends XR>(self: Stream.Stream<A, E, R>, runtime: Runtime.Runtime<XR>): ReadableStream<A> => {
6557
6557
  const runSync = Runtime.runSync(runtime)
6558
- const runPromise = Runtime.runPromise(runtime)
6558
+ const runFork = Runtime.runFork(runtime)
6559
6559
 
6560
6560
  let pull: Effect.Effect<void, never, R>
6561
6561
  let scope: Scope.CloseableScope
@@ -6588,10 +6588,14 @@ export const toReadableStreamRuntime = dual<
6588
6588
  )
6589
6589
  },
6590
6590
  pull() {
6591
- return runPromise(pull)
6591
+ return new Promise<void>((resolve) => {
6592
+ runFork(pull, { scope }).addObserver((_) => resolve())
6593
+ })
6592
6594
  },
6593
6595
  cancel() {
6594
- return runPromise(Scope.close(scope, Exit.void))
6596
+ return new Promise<void>((resolve) => {
6597
+ runFork(Scope.close(scope, Exit.void)).addObserver((_) => resolve())
6598
+ })
6595
6599
  }
6596
6600
  })
6597
6601
  })
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.2.4"
1
+ let moduleVersion = "3.2.6"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4