effect 3.10.19 → 3.11.1
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.
- package/dist/cjs/BigDecimal.js +125 -24
- package/dist/cjs/BigDecimal.js.map +1 -1
- package/dist/cjs/Channel.js +44 -4
- package/dist/cjs/Channel.js.map +1 -1
- package/dist/cjs/Config.js +8 -1
- package/dist/cjs/Config.js.map +1 -1
- package/dist/cjs/Context.js +26 -1
- package/dist/cjs/Context.js.map +1 -1
- package/dist/cjs/Cron.js +75 -67
- package/dist/cjs/Cron.js.map +1 -1
- package/dist/cjs/DateTime.js +111 -661
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Effect.js +82 -4
- package/dist/cjs/Effect.js.map +1 -1
- package/dist/cjs/Inspectable.js +8 -4
- package/dist/cjs/Inspectable.js.map +1 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/Micro.js +1099 -1072
- package/dist/cjs/Micro.js.map +1 -1
- package/dist/cjs/STM.js.map +1 -1
- package/dist/cjs/Schema.js +57 -8
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Sink.js +9 -1
- package/dist/cjs/Sink.js.map +1 -1
- package/dist/cjs/Stream.js +55 -14
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/Utils.js +7 -1
- package/dist/cjs/Utils.js.map +1 -1
- package/dist/cjs/internal/channel/channelExecutor.js +5 -9
- package/dist/cjs/internal/channel/channelExecutor.js.map +1 -1
- package/dist/cjs/internal/channel.js +156 -130
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/config.js +13 -4
- package/dist/cjs/internal/config.js.map +1 -1
- package/dist/cjs/internal/context.js +46 -3
- package/dist/cjs/internal/context.js.map +1 -1
- package/dist/cjs/internal/dateTime.js +747 -0
- package/dist/cjs/internal/dateTime.js.map +1 -0
- package/dist/cjs/internal/fiberRuntime.js +34 -11
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +9 -3
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/layer.js +1 -1
- package/dist/cjs/internal/layer.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +1 -1
- package/dist/cjs/internal/mailbox.js.map +1 -1
- package/dist/cjs/internal/pool.js +4 -2
- package/dist/cjs/internal/pool.js.map +1 -1
- package/dist/cjs/internal/sink.js +25 -21
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stream.js +70 -71
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/cjs/internal/version.js.map +1 -1
- package/dist/dts/BigDecimal.d.ts +56 -1
- package/dist/dts/BigDecimal.d.ts.map +1 -1
- package/dist/dts/Channel.d.ts +66 -5
- package/dist/dts/Channel.d.ts.map +1 -1
- package/dist/dts/Config.d.ts +23 -1
- package/dist/dts/Config.d.ts.map +1 -1
- package/dist/dts/Context.d.ts +111 -0
- package/dist/dts/Context.d.ts.map +1 -1
- package/dist/dts/Cron.d.ts +15 -6
- package/dist/dts/Cron.d.ts.map +1 -1
- package/dist/dts/DateTime.d.ts +41 -41
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Effect.d.ts +88 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Inspectable.d.ts.map +1 -1
- package/dist/dts/JSONSchema.d.ts +1 -0
- package/dist/dts/JSONSchema.d.ts.map +1 -1
- package/dist/dts/Micro.d.ts +875 -872
- package/dist/dts/Micro.d.ts.map +1 -1
- package/dist/dts/STM.d.ts +2 -0
- package/dist/dts/STM.d.ts.map +1 -1
- package/dist/dts/Schema.d.ts +32 -0
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/Sink.d.ts +8 -0
- package/dist/dts/Sink.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +166 -59
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/Utils.d.ts +4 -0
- package/dist/dts/Utils.d.ts.map +1 -1
- package/dist/dts/internal/context.d.ts +1 -1
- package/dist/dts/internal/context.d.ts.map +1 -1
- package/dist/dts/internal/dateTime.d.ts +2 -0
- package/dist/dts/internal/dateTime.d.ts.map +1 -0
- package/dist/dts/internal/fiberRuntime.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/BigDecimal.js +119 -20
- package/dist/esm/BigDecimal.js.map +1 -1
- package/dist/esm/Channel.js +42 -2
- package/dist/esm/Channel.js.map +1 -1
- package/dist/esm/Config.js +7 -0
- package/dist/esm/Config.js.map +1 -1
- package/dist/esm/Context.js +25 -0
- package/dist/esm/Context.js.map +1 -1
- package/dist/esm/Cron.js +75 -67
- package/dist/esm/Cron.js.map +1 -1
- package/dist/esm/DateTime.js +109 -624
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Effect.js +77 -0
- package/dist/esm/Effect.js.map +1 -1
- package/dist/esm/Inspectable.js +8 -4
- package/dist/esm/Inspectable.js.map +1 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/Micro.js +1077 -1047
- package/dist/esm/Micro.js.map +1 -1
- package/dist/esm/STM.js.map +1 -1
- package/dist/esm/Schema.js +54 -0
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Sink.js +8 -0
- package/dist/esm/Sink.js.map +1 -1
- package/dist/esm/Stream.js +53 -12
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/Utils.js +5 -0
- package/dist/esm/Utils.js.map +1 -1
- package/dist/esm/internal/channel/channelExecutor.js +5 -7
- package/dist/esm/internal/channel/channelExecutor.js.map +1 -1
- package/dist/esm/internal/channel.js +152 -129
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/config.js +11 -3
- package/dist/esm/internal/config.js.map +1 -1
- package/dist/esm/internal/context.js +42 -2
- package/dist/esm/internal/context.js.map +1 -1
- package/dist/esm/internal/dateTime.js +704 -0
- package/dist/esm/internal/dateTime.js.map +1 -0
- package/dist/esm/internal/fiberRuntime.js +31 -9
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +9 -3
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/layer.js +1 -1
- package/dist/esm/internal/layer.js.map +1 -1
- package/dist/esm/internal/mailbox.js +1 -1
- package/dist/esm/internal/mailbox.js.map +1 -1
- package/dist/esm/internal/pool.js +4 -2
- package/dist/esm/internal/pool.js.map +1 -1
- package/dist/esm/internal/sink.js +23 -20
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stream.js +66 -69
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/dist/esm/internal/version.js.map +1 -1
- package/package.json +1 -1
- package/src/BigDecimal.ts +131 -21
- package/src/Channel.ts +81 -5
- package/src/Config.ts +24 -1
- package/src/Context.ts +119 -0
- package/src/Cron.ts +85 -68
- package/src/DateTime.ts +151 -754
- package/src/Effect.ts +340 -1
- package/src/Inspectable.ts +11 -7
- package/src/JSONSchema.ts +1 -0
- package/src/Micro.ts +2005 -1757
- package/src/STM.ts +2 -0
- package/src/Schema.ts +60 -0
- package/src/Sink.ts +11 -0
- package/src/Stream.ts +171 -71
- package/src/Utils.ts +8 -0
- package/src/internal/channel/channelExecutor.ts +37 -33
- package/src/internal/channel.ts +504 -467
- package/src/internal/config.ts +18 -6
- package/src/internal/context.ts +56 -4
- package/src/internal/dateTime.ts +1126 -0
- package/src/internal/fiberRuntime.ts +35 -16
- package/src/internal/groupBy.ts +13 -22
- package/src/internal/layer.ts +5 -8
- package/src/internal/mailbox.ts +6 -4
- package/src/internal/pool.ts +4 -1
- package/src/internal/sink.ts +55 -35
- package/src/internal/stream.ts +299 -299
- package/src/internal/version.ts +1 -1
package/src/STM.ts
CHANGED
|
@@ -106,6 +106,8 @@ export interface STMTypeLambda extends TypeLambda {
|
|
|
106
106
|
*/
|
|
107
107
|
declare module "./Context.js" {
|
|
108
108
|
interface Tag<Id, Value> extends STM<Value, never, Id> {}
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
110
|
+
interface Reference<Id, Value> extends STM<Value> {}
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
/**
|
package/src/Schema.ts
CHANGED
|
@@ -5041,6 +5041,10 @@ export class UUID extends String$.pipe(
|
|
|
5041
5041
|
schemaId: UUIDSchemaId,
|
|
5042
5042
|
identifier: "UUID",
|
|
5043
5043
|
title: "UUID",
|
|
5044
|
+
jsonSchema: {
|
|
5045
|
+
format: "uuid",
|
|
5046
|
+
pattern: uuidRegexp.source
|
|
5047
|
+
},
|
|
5044
5048
|
description: "a Universally Unique Identifier",
|
|
5045
5049
|
arbitrary: (): LazyArbitrary<string> => (fc) => fc.uuid()
|
|
5046
5050
|
})
|
|
@@ -5073,6 +5077,49 @@ export class ULID extends String$.pipe(
|
|
|
5073
5077
|
})
|
|
5074
5078
|
) {}
|
|
5075
5079
|
|
|
5080
|
+
/**
|
|
5081
|
+
* Defines a schema that represents a `URL` object.
|
|
5082
|
+
*
|
|
5083
|
+
* @category URL constructors
|
|
5084
|
+
* @since 3.11.0
|
|
5085
|
+
*/
|
|
5086
|
+
export class URLFromSelf extends instanceOf(URL, {
|
|
5087
|
+
identifier: "URLFromSelf",
|
|
5088
|
+
title: "URLFromSelf",
|
|
5089
|
+
arbitrary: (): LazyArbitrary<URL> => (fc) => fc.webUrl().map((s) => new URL(s)),
|
|
5090
|
+
pretty: () => (url) => url.toString()
|
|
5091
|
+
}) {}
|
|
5092
|
+
|
|
5093
|
+
/** @ignore */
|
|
5094
|
+
class URL$ extends transformOrFail(
|
|
5095
|
+
String$.annotations({ description: "a string that will be parsed into a URL" }),
|
|
5096
|
+
URLFromSelf,
|
|
5097
|
+
{
|
|
5098
|
+
strict: true,
|
|
5099
|
+
decode: (str, _, ast) =>
|
|
5100
|
+
ParseResult.try({
|
|
5101
|
+
try: () => new URL(str),
|
|
5102
|
+
catch: () => new ParseResult.Type(ast, str)
|
|
5103
|
+
}),
|
|
5104
|
+
encode: (url) => ParseResult.succeed(url.toString())
|
|
5105
|
+
}
|
|
5106
|
+
).annotations({
|
|
5107
|
+
identifier: "URL",
|
|
5108
|
+
title: "URL",
|
|
5109
|
+
pretty: () => (url) => url.toString()
|
|
5110
|
+
}) {}
|
|
5111
|
+
|
|
5112
|
+
export {
|
|
5113
|
+
/**
|
|
5114
|
+
* Defines a schema that attempts to convert a `string` to a `URL` object using
|
|
5115
|
+
* the `new URL` constructor.
|
|
5116
|
+
*
|
|
5117
|
+
* @category URL transformations
|
|
5118
|
+
* @since 3.11.0
|
|
5119
|
+
*/
|
|
5120
|
+
URL$ as URL
|
|
5121
|
+
}
|
|
5122
|
+
|
|
5076
5123
|
/**
|
|
5077
5124
|
* @category schema id
|
|
5078
5125
|
* @since 3.10.0
|
|
@@ -9793,6 +9840,19 @@ export class BooleanFromUnknown extends transform(
|
|
|
9793
9840
|
{ strict: true, decode: Predicate.isTruthy, encode: identity }
|
|
9794
9841
|
).annotations({ identifier: "BooleanFromUnknown" }) {}
|
|
9795
9842
|
|
|
9843
|
+
/**
|
|
9844
|
+
* Converts an `string` value into its corresponding `boolean`
|
|
9845
|
+
* ("true" as `true` and "false" as `false`).
|
|
9846
|
+
*
|
|
9847
|
+
* @category boolean transformations
|
|
9848
|
+
* @since 3.11.0
|
|
9849
|
+
*/
|
|
9850
|
+
export class BooleanFromString extends transform(
|
|
9851
|
+
Literal("true", "false"),
|
|
9852
|
+
Boolean$,
|
|
9853
|
+
{ strict: true, decode: (value) => value === "true", encode: (value) => value ? "true" : "false" }
|
|
9854
|
+
).annotations({ identifier: "BooleanFromString" }) {}
|
|
9855
|
+
|
|
9796
9856
|
/**
|
|
9797
9857
|
* @category Config validations
|
|
9798
9858
|
* @since 3.10.0
|
package/src/Sink.ts
CHANGED
|
@@ -1765,6 +1765,17 @@ export const unwrapScoped: <A, In, L, E, R>(
|
|
|
1765
1765
|
effect: Effect.Effect<Sink<A, In, L, E, R>, E, R>
|
|
1766
1766
|
) => Sink<A, In, L, E, Exclude<R, Scope.Scope>> = internal.unwrapScoped
|
|
1767
1767
|
|
|
1768
|
+
/**
|
|
1769
|
+
* Constructs a `Sink` from a function which receives a `Scope` and returns
|
|
1770
|
+
* an effect that will result in a `Sink` if successful.
|
|
1771
|
+
*
|
|
1772
|
+
* @since 3.11.0
|
|
1773
|
+
* @category constructors
|
|
1774
|
+
*/
|
|
1775
|
+
export const unwrapScopedWith: <A, In, L, E, R>(
|
|
1776
|
+
f: (scope: Scope.Scope) => Effect.Effect<Sink<A, In, L, E, R>, E, R>
|
|
1777
|
+
) => Sink<A, In, L, E, R> = internal.unwrapScopedWith
|
|
1778
|
+
|
|
1768
1779
|
/**
|
|
1769
1780
|
* Returns the sink that executes this one and times its execution.
|
|
1770
1781
|
*
|
package/src/Stream.ts
CHANGED
|
@@ -6161,30 +6161,40 @@ export const paginateEffect: <S, A, E, R>(
|
|
|
6161
6161
|
) => Stream<A, E, R> = internal.paginateEffect
|
|
6162
6162
|
|
|
6163
6163
|
/**
|
|
6164
|
-
*
|
|
6165
|
-
*
|
|
6166
|
-
*
|
|
6167
|
-
*
|
|
6164
|
+
* Splits a stream into two substreams based on a predicate.
|
|
6165
|
+
*
|
|
6166
|
+
* **Details**
|
|
6167
|
+
*
|
|
6168
|
+
* The `Stream.partition` function splits a stream into two parts: one for
|
|
6169
|
+
* elements that satisfy the predicate (evaluated to `true`) and another for
|
|
6170
|
+
* those that do not (evaluated to `false`).
|
|
6171
|
+
*
|
|
6172
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6173
|
+
* one.
|
|
6174
|
+
*
|
|
6175
|
+
* @see {@link partitionEither} for partitioning a stream based on effectful
|
|
6176
|
+
* conditions.
|
|
6168
6177
|
*
|
|
6169
6178
|
* @example
|
|
6170
6179
|
* ```ts
|
|
6180
|
+
* // Title: Partitioning a Stream into Even and Odd Numbers
|
|
6171
6181
|
* import { Effect, Stream } from "effect"
|
|
6172
6182
|
*
|
|
6173
|
-
* const partition = Stream.range(1,
|
|
6183
|
+
* const partition = Stream.range(1, 9).pipe(
|
|
6174
6184
|
* Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
|
|
6175
6185
|
* )
|
|
6176
6186
|
*
|
|
6177
6187
|
* const program = Effect.scoped(
|
|
6178
6188
|
* Effect.gen(function*() {
|
|
6179
|
-
* const [
|
|
6180
|
-
* console.log(yield* Stream.runCollect(evens))
|
|
6189
|
+
* const [odds, evens] = yield* partition
|
|
6181
6190
|
* console.log(yield* Stream.runCollect(odds))
|
|
6191
|
+
* console.log(yield* Stream.runCollect(evens))
|
|
6182
6192
|
* })
|
|
6183
6193
|
* )
|
|
6184
6194
|
*
|
|
6185
6195
|
* // Effect.runPromise(program)
|
|
6186
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
|
|
6187
6196
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6197
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6188
6198
|
* ```
|
|
6189
6199
|
*
|
|
6190
6200
|
* @since 2.0.0
|
|
@@ -6192,30 +6202,40 @@ export const paginateEffect: <S, A, E, R>(
|
|
|
6192
6202
|
*/
|
|
6193
6203
|
export const partition: {
|
|
6194
6204
|
/**
|
|
6195
|
-
*
|
|
6196
|
-
*
|
|
6197
|
-
*
|
|
6198
|
-
*
|
|
6205
|
+
* Splits a stream into two substreams based on a predicate.
|
|
6206
|
+
*
|
|
6207
|
+
* **Details**
|
|
6208
|
+
*
|
|
6209
|
+
* The `Stream.partition` function splits a stream into two parts: one for
|
|
6210
|
+
* elements that satisfy the predicate (evaluated to `true`) and another for
|
|
6211
|
+
* those that do not (evaluated to `false`).
|
|
6212
|
+
*
|
|
6213
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6214
|
+
* one.
|
|
6215
|
+
*
|
|
6216
|
+
* @see {@link partitionEither} for partitioning a stream based on effectful
|
|
6217
|
+
* conditions.
|
|
6199
6218
|
*
|
|
6200
6219
|
* @example
|
|
6201
6220
|
* ```ts
|
|
6221
|
+
* // Title: Partitioning a Stream into Even and Odd Numbers
|
|
6202
6222
|
* import { Effect, Stream } from "effect"
|
|
6203
6223
|
*
|
|
6204
|
-
* const partition = Stream.range(1,
|
|
6224
|
+
* const partition = Stream.range(1, 9).pipe(
|
|
6205
6225
|
* Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
|
|
6206
6226
|
* )
|
|
6207
6227
|
*
|
|
6208
6228
|
* const program = Effect.scoped(
|
|
6209
6229
|
* Effect.gen(function*() {
|
|
6210
|
-
* const [
|
|
6211
|
-
* console.log(yield* Stream.runCollect(evens))
|
|
6230
|
+
* const [odds, evens] = yield* partition
|
|
6212
6231
|
* console.log(yield* Stream.runCollect(odds))
|
|
6232
|
+
* console.log(yield* Stream.runCollect(evens))
|
|
6213
6233
|
* })
|
|
6214
6234
|
* )
|
|
6215
6235
|
*
|
|
6216
6236
|
* // Effect.runPromise(program)
|
|
6217
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
|
|
6218
6237
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6238
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6219
6239
|
* ```
|
|
6220
6240
|
*
|
|
6221
6241
|
* @since 2.0.0
|
|
@@ -6228,30 +6248,40 @@ export const partition: {
|
|
|
6228
6248
|
self: Stream<C, E, R>
|
|
6229
6249
|
) => Effect.Effect<[excluded: Stream<Exclude<C, B>, E, never>, satisfying: Stream<B, E, never>], E, R | Scope.Scope>
|
|
6230
6250
|
/**
|
|
6231
|
-
*
|
|
6232
|
-
*
|
|
6233
|
-
*
|
|
6234
|
-
*
|
|
6251
|
+
* Splits a stream into two substreams based on a predicate.
|
|
6252
|
+
*
|
|
6253
|
+
* **Details**
|
|
6254
|
+
*
|
|
6255
|
+
* The `Stream.partition` function splits a stream into two parts: one for
|
|
6256
|
+
* elements that satisfy the predicate (evaluated to `true`) and another for
|
|
6257
|
+
* those that do not (evaluated to `false`).
|
|
6258
|
+
*
|
|
6259
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6260
|
+
* one.
|
|
6261
|
+
*
|
|
6262
|
+
* @see {@link partitionEither} for partitioning a stream based on effectful
|
|
6263
|
+
* conditions.
|
|
6235
6264
|
*
|
|
6236
6265
|
* @example
|
|
6237
6266
|
* ```ts
|
|
6267
|
+
* // Title: Partitioning a Stream into Even and Odd Numbers
|
|
6238
6268
|
* import { Effect, Stream } from "effect"
|
|
6239
6269
|
*
|
|
6240
|
-
* const partition = Stream.range(1,
|
|
6270
|
+
* const partition = Stream.range(1, 9).pipe(
|
|
6241
6271
|
* Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
|
|
6242
6272
|
* )
|
|
6243
6273
|
*
|
|
6244
6274
|
* const program = Effect.scoped(
|
|
6245
6275
|
* Effect.gen(function*() {
|
|
6246
|
-
* const [
|
|
6247
|
-
* console.log(yield* Stream.runCollect(evens))
|
|
6276
|
+
* const [odds, evens] = yield* partition
|
|
6248
6277
|
* console.log(yield* Stream.runCollect(odds))
|
|
6278
|
+
* console.log(yield* Stream.runCollect(evens))
|
|
6249
6279
|
* })
|
|
6250
6280
|
* )
|
|
6251
6281
|
*
|
|
6252
6282
|
* // Effect.runPromise(program)
|
|
6253
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
|
|
6254
6283
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6284
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6255
6285
|
* ```
|
|
6256
6286
|
*
|
|
6257
6287
|
* @since 2.0.0
|
|
@@ -6264,30 +6294,40 @@ export const partition: {
|
|
|
6264
6294
|
self: Stream<A, E, R>
|
|
6265
6295
|
) => Effect.Effect<[excluded: Stream<A, E, never>, satisfying: Stream<A, E, never>], E, Scope.Scope | R>
|
|
6266
6296
|
/**
|
|
6267
|
-
*
|
|
6268
|
-
*
|
|
6269
|
-
*
|
|
6270
|
-
*
|
|
6297
|
+
* Splits a stream into two substreams based on a predicate.
|
|
6298
|
+
*
|
|
6299
|
+
* **Details**
|
|
6300
|
+
*
|
|
6301
|
+
* The `Stream.partition` function splits a stream into two parts: one for
|
|
6302
|
+
* elements that satisfy the predicate (evaluated to `true`) and another for
|
|
6303
|
+
* those that do not (evaluated to `false`).
|
|
6304
|
+
*
|
|
6305
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6306
|
+
* one.
|
|
6307
|
+
*
|
|
6308
|
+
* @see {@link partitionEither} for partitioning a stream based on effectful
|
|
6309
|
+
* conditions.
|
|
6271
6310
|
*
|
|
6272
6311
|
* @example
|
|
6273
6312
|
* ```ts
|
|
6313
|
+
* // Title: Partitioning a Stream into Even and Odd Numbers
|
|
6274
6314
|
* import { Effect, Stream } from "effect"
|
|
6275
6315
|
*
|
|
6276
|
-
* const partition = Stream.range(1,
|
|
6316
|
+
* const partition = Stream.range(1, 9).pipe(
|
|
6277
6317
|
* Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
|
|
6278
6318
|
* )
|
|
6279
6319
|
*
|
|
6280
6320
|
* const program = Effect.scoped(
|
|
6281
6321
|
* Effect.gen(function*() {
|
|
6282
|
-
* const [
|
|
6283
|
-
* console.log(yield* Stream.runCollect(evens))
|
|
6322
|
+
* const [odds, evens] = yield* partition
|
|
6284
6323
|
* console.log(yield* Stream.runCollect(odds))
|
|
6324
|
+
* console.log(yield* Stream.runCollect(evens))
|
|
6285
6325
|
* })
|
|
6286
6326
|
* )
|
|
6287
6327
|
*
|
|
6288
6328
|
* // Effect.runPromise(program)
|
|
6289
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
|
|
6290
6329
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6330
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6291
6331
|
* ```
|
|
6292
6332
|
*
|
|
6293
6333
|
* @since 2.0.0
|
|
@@ -6299,30 +6339,40 @@ export const partition: {
|
|
|
6299
6339
|
options?: { bufferSize?: number | undefined } | undefined
|
|
6300
6340
|
): Effect.Effect<[excluded: Stream<Exclude<C, B>, E, never>, satisfying: Stream<B, E, never>], E, R | Scope.Scope>
|
|
6301
6341
|
/**
|
|
6302
|
-
*
|
|
6303
|
-
*
|
|
6304
|
-
*
|
|
6305
|
-
*
|
|
6342
|
+
* Splits a stream into two substreams based on a predicate.
|
|
6343
|
+
*
|
|
6344
|
+
* **Details**
|
|
6345
|
+
*
|
|
6346
|
+
* The `Stream.partition` function splits a stream into two parts: one for
|
|
6347
|
+
* elements that satisfy the predicate (evaluated to `true`) and another for
|
|
6348
|
+
* those that do not (evaluated to `false`).
|
|
6349
|
+
*
|
|
6350
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6351
|
+
* one.
|
|
6352
|
+
*
|
|
6353
|
+
* @see {@link partitionEither} for partitioning a stream based on effectful
|
|
6354
|
+
* conditions.
|
|
6306
6355
|
*
|
|
6307
6356
|
* @example
|
|
6308
6357
|
* ```ts
|
|
6358
|
+
* // Title: Partitioning a Stream into Even and Odd Numbers
|
|
6309
6359
|
* import { Effect, Stream } from "effect"
|
|
6310
6360
|
*
|
|
6311
|
-
* const partition = Stream.range(1,
|
|
6361
|
+
* const partition = Stream.range(1, 9).pipe(
|
|
6312
6362
|
* Stream.partition((n) => n % 2 === 0, { bufferSize: 5 })
|
|
6313
6363
|
* )
|
|
6314
6364
|
*
|
|
6315
6365
|
* const program = Effect.scoped(
|
|
6316
6366
|
* Effect.gen(function*() {
|
|
6317
|
-
* const [
|
|
6318
|
-
* console.log(yield* Stream.runCollect(evens))
|
|
6367
|
+
* const [odds, evens] = yield* partition
|
|
6319
6368
|
* console.log(yield* Stream.runCollect(odds))
|
|
6369
|
+
* console.log(yield* Stream.runCollect(evens))
|
|
6320
6370
|
* })
|
|
6321
6371
|
* )
|
|
6322
6372
|
*
|
|
6323
6373
|
* // Effect.runPromise(program)
|
|
6324
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8, 10 ] }
|
|
6325
6374
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6375
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6326
6376
|
* ```
|
|
6327
6377
|
*
|
|
6328
6378
|
* @since 2.0.0
|
|
@@ -6336,16 +6386,29 @@ export const partition: {
|
|
|
6336
6386
|
} = internal.partition
|
|
6337
6387
|
|
|
6338
6388
|
/**
|
|
6339
|
-
*
|
|
6340
|
-
*
|
|
6389
|
+
* Splits a stream into two substreams based on an effectful condition.
|
|
6390
|
+
*
|
|
6391
|
+
* **Details**
|
|
6392
|
+
*
|
|
6393
|
+
* The `Stream.partitionEither` function is used to divide a stream into two
|
|
6394
|
+
* parts: one for elements that satisfy a condition producing `Either.left`
|
|
6395
|
+
* values, and another for those that produce `Either.right` values. This
|
|
6396
|
+
* function applies an effectful predicate to each element in the stream to
|
|
6397
|
+
* determine which substream it belongs to.
|
|
6398
|
+
*
|
|
6399
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6400
|
+
* one.
|
|
6401
|
+
*
|
|
6402
|
+
* @see {@link partition} for partitioning a stream based on simple conditions.
|
|
6341
6403
|
*
|
|
6342
6404
|
* @example
|
|
6343
6405
|
* ```ts
|
|
6406
|
+
* // Title: Partitioning a Stream with an Effectful Predicate
|
|
6344
6407
|
* import { Effect, Either, Stream } from "effect"
|
|
6345
6408
|
*
|
|
6346
6409
|
* const partition = Stream.range(1, 9).pipe(
|
|
6347
6410
|
* Stream.partitionEither(
|
|
6348
|
-
* (n) => Effect.succeed(n % 2 === 0 ? Either.
|
|
6411
|
+
* (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
|
|
6349
6412
|
* { bufferSize: 5 }
|
|
6350
6413
|
* )
|
|
6351
6414
|
* )
|
|
@@ -6359,8 +6422,8 @@ export const partition: {
|
|
|
6359
6422
|
* )
|
|
6360
6423
|
*
|
|
6361
6424
|
* // Effect.runPromise(program)
|
|
6362
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6363
6425
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6426
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6364
6427
|
* ```
|
|
6365
6428
|
*
|
|
6366
6429
|
* @since 2.0.0
|
|
@@ -6368,16 +6431,29 @@ export const partition: {
|
|
|
6368
6431
|
*/
|
|
6369
6432
|
export const partitionEither: {
|
|
6370
6433
|
/**
|
|
6371
|
-
*
|
|
6372
|
-
*
|
|
6434
|
+
* Splits a stream into two substreams based on an effectful condition.
|
|
6435
|
+
*
|
|
6436
|
+
* **Details**
|
|
6437
|
+
*
|
|
6438
|
+
* The `Stream.partitionEither` function is used to divide a stream into two
|
|
6439
|
+
* parts: one for elements that satisfy a condition producing `Either.left`
|
|
6440
|
+
* values, and another for those that produce `Either.right` values. This
|
|
6441
|
+
* function applies an effectful predicate to each element in the stream to
|
|
6442
|
+
* determine which substream it belongs to.
|
|
6443
|
+
*
|
|
6444
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6445
|
+
* one.
|
|
6446
|
+
*
|
|
6447
|
+
* @see {@link partition} for partitioning a stream based on simple conditions.
|
|
6373
6448
|
*
|
|
6374
6449
|
* @example
|
|
6375
6450
|
* ```ts
|
|
6451
|
+
* // Title: Partitioning a Stream with an Effectful Predicate
|
|
6376
6452
|
* import { Effect, Either, Stream } from "effect"
|
|
6377
6453
|
*
|
|
6378
6454
|
* const partition = Stream.range(1, 9).pipe(
|
|
6379
6455
|
* Stream.partitionEither(
|
|
6380
|
-
* (n) => Effect.succeed(n % 2 === 0 ? Either.
|
|
6456
|
+
* (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
|
|
6381
6457
|
* { bufferSize: 5 }
|
|
6382
6458
|
* )
|
|
6383
6459
|
* )
|
|
@@ -6391,8 +6467,8 @@ export const partitionEither: {
|
|
|
6391
6467
|
* )
|
|
6392
6468
|
*
|
|
6393
6469
|
* // Effect.runPromise(program)
|
|
6394
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6395
6470
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6471
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6396
6472
|
* ```
|
|
6397
6473
|
*
|
|
6398
6474
|
* @since 2.0.0
|
|
@@ -6405,16 +6481,29 @@ export const partitionEither: {
|
|
|
6405
6481
|
self: Stream<A, E, R>
|
|
6406
6482
|
) => Effect.Effect<[left: Stream<A2, E2 | E, never>, right: Stream<A3, E2 | E, never>], E2 | E, Scope.Scope | R2 | R>
|
|
6407
6483
|
/**
|
|
6408
|
-
*
|
|
6409
|
-
*
|
|
6484
|
+
* Splits a stream into two substreams based on an effectful condition.
|
|
6485
|
+
*
|
|
6486
|
+
* **Details**
|
|
6487
|
+
*
|
|
6488
|
+
* The `Stream.partitionEither` function is used to divide a stream into two
|
|
6489
|
+
* parts: one for elements that satisfy a condition producing `Either.left`
|
|
6490
|
+
* values, and another for those that produce `Either.right` values. This
|
|
6491
|
+
* function applies an effectful predicate to each element in the stream to
|
|
6492
|
+
* determine which substream it belongs to.
|
|
6493
|
+
*
|
|
6494
|
+
* The faster stream may advance up to `bufferSize` elements ahead of the slower
|
|
6495
|
+
* one.
|
|
6496
|
+
*
|
|
6497
|
+
* @see {@link partition} for partitioning a stream based on simple conditions.
|
|
6410
6498
|
*
|
|
6411
6499
|
* @example
|
|
6412
6500
|
* ```ts
|
|
6501
|
+
* // Title: Partitioning a Stream with an Effectful Predicate
|
|
6413
6502
|
* import { Effect, Either, Stream } from "effect"
|
|
6414
6503
|
*
|
|
6415
6504
|
* const partition = Stream.range(1, 9).pipe(
|
|
6416
6505
|
* Stream.partitionEither(
|
|
6417
|
-
* (n) => Effect.succeed(n % 2 === 0 ? Either.
|
|
6506
|
+
* (n) => Effect.succeed(n % 2 === 0 ? Either.right(n) : Either.left(n)),
|
|
6418
6507
|
* { bufferSize: 5 }
|
|
6419
6508
|
* )
|
|
6420
6509
|
* )
|
|
@@ -6428,8 +6517,8 @@ export const partitionEither: {
|
|
|
6428
6517
|
* )
|
|
6429
6518
|
*
|
|
6430
6519
|
* // Effect.runPromise(program)
|
|
6431
|
-
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6432
6520
|
* // { _id: 'Chunk', values: [ 1, 3, 5, 7, 9 ] }
|
|
6521
|
+
* // { _id: 'Chunk', values: [ 2, 4, 6, 8 ] }
|
|
6433
6522
|
* ```
|
|
6434
6523
|
*
|
|
6435
6524
|
* @since 2.0.0
|
|
@@ -7420,8 +7509,7 @@ export const run: {
|
|
|
7420
7509
|
* @since 2.0.0
|
|
7421
7510
|
* @category destructors
|
|
7422
7511
|
*/
|
|
7423
|
-
export const runCollect: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Chunk.Chunk<A>, E,
|
|
7424
|
-
internal.runCollect
|
|
7512
|
+
export const runCollect: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Chunk.Chunk<A>, E, R> = internal.runCollect
|
|
7425
7513
|
|
|
7426
7514
|
/**
|
|
7427
7515
|
* Runs the stream and emits the number of elements processed
|
|
@@ -7429,8 +7517,7 @@ export const runCollect: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<Chunk
|
|
|
7429
7517
|
* @since 2.0.0
|
|
7430
7518
|
* @category destructors
|
|
7431
7519
|
*/
|
|
7432
|
-
export const runCount: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<number, E,
|
|
7433
|
-
internal.runCount
|
|
7520
|
+
export const runCount: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<number, E, R> = internal.runCount
|
|
7434
7521
|
|
|
7435
7522
|
/**
|
|
7436
7523
|
* Runs the stream only for its effects. The emitted elements are discarded.
|
|
@@ -7438,8 +7525,7 @@ export const runCount: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<number,
|
|
|
7438
7525
|
* @since 2.0.0
|
|
7439
7526
|
* @category destructors
|
|
7440
7527
|
*/
|
|
7441
|
-
export const runDrain: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<void, E,
|
|
7442
|
-
internal.runDrain
|
|
7528
|
+
export const runDrain: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<void, E, R> = internal.runDrain
|
|
7443
7529
|
|
|
7444
7530
|
/**
|
|
7445
7531
|
* Executes a pure fold over the stream of values - reduces all elements in
|
|
@@ -7456,7 +7542,7 @@ export const runFold: {
|
|
|
7456
7542
|
* @since 2.0.0
|
|
7457
7543
|
* @category destructors
|
|
7458
7544
|
*/
|
|
7459
|
-
<S, A>(s: S, f: (s: S, a: A) => S): <E, R>(self: Stream<A, E, R>) => Effect.Effect<S, E,
|
|
7545
|
+
<S, A>(s: S, f: (s: S, a: A) => S): <E, R>(self: Stream<A, E, R>) => Effect.Effect<S, E, R>
|
|
7460
7546
|
/**
|
|
7461
7547
|
* Executes a pure fold over the stream of values - reduces all elements in
|
|
7462
7548
|
* the stream to a value of type `S`.
|
|
@@ -7464,7 +7550,7 @@ export const runFold: {
|
|
|
7464
7550
|
* @since 2.0.0
|
|
7465
7551
|
* @category destructors
|
|
7466
7552
|
*/
|
|
7467
|
-
<A, E, R, S>(self: Stream<A, E, R>, s: S, f: (s: S, a: A) => S): Effect.Effect<S, E,
|
|
7553
|
+
<A, E, R, S>(self: Stream<A, E, R>, s: S, f: (s: S, a: A) => S): Effect.Effect<S, E, R>
|
|
7468
7554
|
} = internal.runFold
|
|
7469
7555
|
|
|
7470
7556
|
/**
|
|
@@ -7571,11 +7657,7 @@ export const runFoldWhile: {
|
|
|
7571
7657
|
* @since 2.0.0
|
|
7572
7658
|
* @category destructors
|
|
7573
7659
|
*/
|
|
7574
|
-
<S, A>(
|
|
7575
|
-
s: S,
|
|
7576
|
-
cont: Predicate<S>,
|
|
7577
|
-
f: (s: S, a: A) => S
|
|
7578
|
-
): <E, R>(self: Stream<A, E, R>) => Effect.Effect<S, E, Exclude<R, Scope.Scope>>
|
|
7660
|
+
<S, A>(s: S, cont: Predicate<S>, f: (s: S, a: A) => S): <E, R>(self: Stream<A, E, R>) => Effect.Effect<S, E, R>
|
|
7579
7661
|
/**
|
|
7580
7662
|
* Reduces the elements in the stream to a value of type `S`. Stops the fold
|
|
7581
7663
|
* early when the condition is not fulfilled. Example:
|
|
@@ -7583,12 +7665,7 @@ export const runFoldWhile: {
|
|
|
7583
7665
|
* @since 2.0.0
|
|
7584
7666
|
* @category destructors
|
|
7585
7667
|
*/
|
|
7586
|
-
<A, E, R, S>(
|
|
7587
|
-
self: Stream<A, E, R>,
|
|
7588
|
-
s: S,
|
|
7589
|
-
cont: Predicate<S>,
|
|
7590
|
-
f: (s: S, a: A) => S
|
|
7591
|
-
): Effect.Effect<S, E, Exclude<R, Scope.Scope>>
|
|
7668
|
+
<A, E, R, S>(self: Stream<A, E, R>, s: S, cont: Predicate<S>, f: (s: S, a: A) => S): Effect.Effect<S, E, R>
|
|
7592
7669
|
} = internal.runFoldWhile
|
|
7593
7670
|
|
|
7594
7671
|
/**
|
|
@@ -8323,6 +8400,17 @@ export const scheduleWith: {
|
|
|
8323
8400
|
export const scoped: <A, E, R>(effect: Effect.Effect<A, E, R>) => Stream<A, E, Exclude<R, Scope.Scope>> =
|
|
8324
8401
|
internal.scoped
|
|
8325
8402
|
|
|
8403
|
+
/**
|
|
8404
|
+
* Use a function that receives a scope and returns an effect to emit an output
|
|
8405
|
+
* element. The output element will be the result of the returned effect, if
|
|
8406
|
+
* successful.
|
|
8407
|
+
*
|
|
8408
|
+
* @since 3.11.0
|
|
8409
|
+
* @category constructors
|
|
8410
|
+
*/
|
|
8411
|
+
export const scopedWith: <A, E, R>(f: (scope: Scope.Scope) => Effect.Effect<A, E, R>) => Stream<A, E, R> =
|
|
8412
|
+
internal.scopedWith
|
|
8413
|
+
|
|
8326
8414
|
/**
|
|
8327
8415
|
* Emits a sliding window of `n` elements.
|
|
8328
8416
|
*
|
|
@@ -9914,6 +10002,18 @@ export const unwrapScoped: <A, E2, R2, E, R>(
|
|
|
9914
10002
|
effect: Effect.Effect<Stream<A, E2, R2>, E, R>
|
|
9915
10003
|
) => Stream<A, E | E2, R2 | Exclude<R, Scope.Scope>> = internal.unwrapScoped
|
|
9916
10004
|
|
|
10005
|
+
/**
|
|
10006
|
+
* Creates a stream produced from a function which receives a `Scope` and
|
|
10007
|
+
* returns an `Effect`. The resulting stream will emit a single element, which
|
|
10008
|
+
* will be the result of the returned effect, if successful.
|
|
10009
|
+
*
|
|
10010
|
+
* @since 3.11.0
|
|
10011
|
+
* @category constructors
|
|
10012
|
+
*/
|
|
10013
|
+
export const unwrapScopedWith: <A, E2, R2, E, R>(
|
|
10014
|
+
f: (scope: Scope.Scope) => Effect.Effect<Stream<A, E2, R2>, E, R>
|
|
10015
|
+
) => Stream<A, E | E2, R | R2> = internal.unwrapScopedWith
|
|
10016
|
+
|
|
9917
10017
|
/**
|
|
9918
10018
|
* Updates the specified service within the context of the `Stream`.
|
|
9919
10019
|
*
|
package/src/Utils.ts
CHANGED
|
@@ -791,3 +791,11 @@ const tracingFunction = (name: string) => {
|
|
|
791
791
|
* @category tracing
|
|
792
792
|
*/
|
|
793
793
|
export const internalCall = tracingFunction("effect_internal_function")
|
|
794
|
+
|
|
795
|
+
const genConstructor = (function*() {}).constructor
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* @since 3.11.0
|
|
799
|
+
*/
|
|
800
|
+
export const isGeneratorFunction = (u: unknown): u is (...args: Array<any>) => Generator<any, any, any> =>
|
|
801
|
+
isObject(u) && u.constructor === genConstructor
|