effect 3.2.4 → 3.2.5

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.5";
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.5",
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>
@@ -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.5"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4