effect 3.16.13 → 3.16.14
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/Predicate.js +516 -200
- package/dist/cjs/Predicate.js.map +1 -1
- package/dist/cjs/Schema.js +2 -2
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/internal/channel.js +2 -2
- package/dist/cjs/internal/channel.js.map +1 -1
- package/dist/cjs/internal/core-effect.js +1 -0
- package/dist/cjs/internal/core-effect.js.map +1 -1
- package/dist/cjs/internal/dataSource.js +2 -2
- package/dist/cjs/internal/dataSource.js.map +1 -1
- package/dist/cjs/internal/fiberRuntime.js +1 -1
- package/dist/cjs/internal/fiberRuntime.js.map +1 -1
- package/dist/cjs/internal/groupBy.js +2 -2
- package/dist/cjs/internal/groupBy.js.map +1 -1
- package/dist/cjs/internal/sink.js +4 -4
- package/dist/cjs/internal/sink.js.map +1 -1
- package/dist/cjs/internal/stm/stm.js +3 -3
- package/dist/cjs/internal/stm/stm.js.map +1 -1
- package/dist/cjs/internal/stream.js +5 -5
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/Effect.d.ts +1 -1
- package/dist/dts/Effect.d.ts.map +1 -1
- package/dist/dts/Predicate.d.ts +1190 -375
- package/dist/dts/Predicate.d.ts.map +1 -1
- package/dist/dts/index.d.ts +15 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/internal/core-effect.d.ts.map +1 -1
- package/dist/dts/internal/stm/stm.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/Predicate.js +516 -200
- package/dist/esm/Predicate.js.map +1 -1
- package/dist/esm/Schema.js +2 -2
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/index.js +15 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/internal/channel.js +2 -2
- package/dist/esm/internal/channel.js.map +1 -1
- package/dist/esm/internal/core-effect.js +1 -0
- package/dist/esm/internal/core-effect.js.map +1 -1
- package/dist/esm/internal/dataSource.js +2 -2
- package/dist/esm/internal/dataSource.js.map +1 -1
- package/dist/esm/internal/fiberRuntime.js +1 -1
- package/dist/esm/internal/fiberRuntime.js.map +1 -1
- package/dist/esm/internal/groupBy.js +2 -2
- package/dist/esm/internal/groupBy.js.map +1 -1
- package/dist/esm/internal/sink.js +4 -4
- package/dist/esm/internal/sink.js.map +1 -1
- package/dist/esm/internal/stm/stm.js +3 -3
- package/dist/esm/internal/stm/stm.js.map +1 -1
- package/dist/esm/internal/stream.js +5 -5
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +1 -1
- package/src/Predicate.ts +1213 -377
- package/src/Schema.ts +2 -2
- package/src/index.ts +15 -0
- package/src/internal/channel.ts +2 -2
- package/src/internal/core-effect.ts +1 -0
- package/src/internal/dataSource.ts +12 -14
- package/src/internal/fiberRuntime.ts +2 -2
- package/src/internal/groupBy.ts +12 -14
- package/src/internal/sink.ts +13 -15
- package/src/internal/stm/stm.ts +16 -20
- package/src/internal/stream.ts +17 -23
- package/src/internal/version.ts +1 -1
package/src/Schema.ts
CHANGED
|
@@ -7151,8 +7151,8 @@ export const lessThanOrEqualToDate = <S extends Schema.Any>(
|
|
|
7151
7151
|
<A extends Date>(self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>): filter<S> =>
|
|
7152
7152
|
self.pipe(
|
|
7153
7153
|
filter((a: Date) => a <= max, {
|
|
7154
|
-
schemaId:
|
|
7155
|
-
[
|
|
7154
|
+
schemaId: LessThanOrEqualToDateSchemaId,
|
|
7155
|
+
[LessThanOrEqualToDateSchemaId]: { max },
|
|
7156
7156
|
title: `lessThanOrEqualToDate(${util_.formatDate(max)})`,
|
|
7157
7157
|
description: `a date before or equal to ${util_.formatDate(max)}`,
|
|
7158
7158
|
...annotations
|
package/src/index.ts
CHANGED
|
@@ -1089,6 +1089,21 @@ export * as Pipeable from "./Pipeable.js"
|
|
|
1089
1089
|
export * as Pool from "./Pool.js"
|
|
1090
1090
|
|
|
1091
1091
|
/**
|
|
1092
|
+
* This module provides a collection of functions for working with predicates and refinements.
|
|
1093
|
+
*
|
|
1094
|
+
* A `Predicate<A>` is a function that takes a value of type `A` and returns a boolean.
|
|
1095
|
+
* It is used to check if a value satisfies a certain condition.
|
|
1096
|
+
*
|
|
1097
|
+
* A `Refinement<A, B>` is a special type of predicate that not only checks a condition
|
|
1098
|
+
* but also provides a type guard, allowing TypeScript to narrow the type of the input
|
|
1099
|
+
* value from `A` to a more specific type `B` within a conditional block.
|
|
1100
|
+
*
|
|
1101
|
+
* The module includes:
|
|
1102
|
+
* - Basic predicates and refinements for common types (e.g., `isString`, `isNumber`).
|
|
1103
|
+
* - Combinators to create new predicates from existing ones (e.g., `and`, `or`, `not`).
|
|
1104
|
+
* - Advanced combinators for working with data structures (e.g., `tuple`, `struct`).
|
|
1105
|
+
* - Type-level utilities for inspecting predicate and refinement types.
|
|
1106
|
+
*
|
|
1092
1107
|
* @since 2.0.0
|
|
1093
1108
|
*/
|
|
1094
1109
|
export * as Predicate from "./Predicate.js"
|
package/src/internal/channel.ts
CHANGED
|
@@ -2300,8 +2300,8 @@ const toQueueInternal = <Err, Done, Elem>(
|
|
|
2300
2300
|
core.fromEffect(Queue.offer(queue, Either.right(elem))),
|
|
2301
2301
|
() => toQueueInternal(queue)
|
|
2302
2302
|
),
|
|
2303
|
-
onFailure: (cause) => core.fromEffect(
|
|
2304
|
-
onDone: (done) => core.fromEffect(
|
|
2303
|
+
onFailure: (cause) => core.fromEffect(Queue.offer(queue, Either.left(Exit.failCause(cause)))),
|
|
2304
|
+
onDone: (done) => core.fromEffect(Queue.offer(queue, Either.left(Exit.succeed(done))))
|
|
2305
2305
|
})
|
|
2306
2306
|
}
|
|
2307
2307
|
|
|
@@ -2168,6 +2168,7 @@ export const endSpan = <A, E>(span: Tracer.Span, exit: Exit<A, E>, clock: Clock.
|
|
|
2168
2168
|
return
|
|
2169
2169
|
}
|
|
2170
2170
|
if (core.exitIsFailure(exit) && internalCause.spanToTrace.has(span)) {
|
|
2171
|
+
// https://opentelemetry.io/docs/specs/semconv/registry/attributes/code/#code-stacktrace
|
|
2171
2172
|
span.attribute("code.stacktrace", internalCause.spanToTrace.get(span)!())
|
|
2172
2173
|
}
|
|
2173
2174
|
span.end(timingEnabled ? clock.unsafeCurrentTimeNanos() : bigint0, exit)
|
|
@@ -190,20 +190,18 @@ export const eitherWith = dual<
|
|
|
190
190
|
) =>
|
|
191
191
|
new core.RequestResolverImpl<C, R | R2>(
|
|
192
192
|
(batch) =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
})
|
|
206
|
-
),
|
|
193
|
+
core.forEachSequential(batch, (requests) => {
|
|
194
|
+
const [as, bs] = pipe(
|
|
195
|
+
requests,
|
|
196
|
+
RA.partitionMap(f)
|
|
197
|
+
)
|
|
198
|
+
return zipWithOptions(
|
|
199
|
+
self.runAll(Array.of(as)),
|
|
200
|
+
that.runAll(Array.of(bs)),
|
|
201
|
+
() => void 0,
|
|
202
|
+
{ concurrent: true }
|
|
203
|
+
)
|
|
204
|
+
}),
|
|
207
205
|
Chunk.make("EitherWith", self, that, f)
|
|
208
206
|
))
|
|
209
207
|
|
|
@@ -1772,10 +1772,10 @@ const existsLoop = <A, E, R>(
|
|
|
1772
1772
|
if (next.done) {
|
|
1773
1773
|
return core.succeed(false)
|
|
1774
1774
|
}
|
|
1775
|
-
return
|
|
1775
|
+
return core.flatMap(
|
|
1776
1776
|
f(next.value, index),
|
|
1777
1777
|
(b) => b ? core.succeed(b) : existsLoop(iterator, index + 1, f)
|
|
1778
|
-
)
|
|
1778
|
+
)
|
|
1779
1779
|
}
|
|
1780
1780
|
|
|
1781
1781
|
/* @internal */
|
package/src/internal/groupBy.ts
CHANGED
|
@@ -467,20 +467,18 @@ export const groupByKey = dual<
|
|
|
467
467
|
),
|
|
468
468
|
onFailure: (cause) => core.fromEffect(Queue.offer(outerQueue, take.failCause(cause))),
|
|
469
469
|
onDone: () =>
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
Effect.zipRight(Queue.offer(outerQueue, take.end))
|
|
483
|
-
)
|
|
470
|
+
core.fromEffect(
|
|
471
|
+
pipe(
|
|
472
|
+
Effect.forEach(map.entries(), ([_, innerQueue]) =>
|
|
473
|
+
pipe(
|
|
474
|
+
Queue.offer(innerQueue, take.end),
|
|
475
|
+
Effect.catchSomeCause((cause) =>
|
|
476
|
+
Cause.isInterruptedOnly(cause) ?
|
|
477
|
+
Option.some(Effect.void) :
|
|
478
|
+
Option.none()
|
|
479
|
+
)
|
|
480
|
+
), { discard: true }),
|
|
481
|
+
Effect.zipRight(Queue.offer(outerQueue, take.end))
|
|
484
482
|
)
|
|
485
483
|
)
|
|
486
484
|
})
|
package/src/internal/sink.ts
CHANGED
|
@@ -125,19 +125,17 @@ export const collectAllToMap = <In, K>(
|
|
|
125
125
|
key: (input: In) => K,
|
|
126
126
|
merge: (x: In, y: In) => In
|
|
127
127
|
): Sink.Sink<HashMap.HashMap<K, In>, In> => {
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
))
|
|
140
|
-
)
|
|
128
|
+
return foldLeftChunks(HashMap.empty<K, In>(), (map, chunk) =>
|
|
129
|
+
pipe(
|
|
130
|
+
chunk,
|
|
131
|
+
Chunk.reduce(map, (map, input) => {
|
|
132
|
+
const k: K = key(input)
|
|
133
|
+
const v: In = pipe(map, HashMap.has(k)) ?
|
|
134
|
+
merge(pipe(map, HashMap.unsafeGet(k)), input) :
|
|
135
|
+
input
|
|
136
|
+
return pipe(map, HashMap.set(k, v))
|
|
137
|
+
})
|
|
138
|
+
))
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
/** @internal */
|
|
@@ -698,7 +696,7 @@ export const contextWithEffect = <R0, A, E, R>(
|
|
|
698
696
|
export const contextWithSink = <R0, A, In, L, E, R>(
|
|
699
697
|
f: (context: Context.Context<R0>) => Sink.Sink<A, In, L, E, R>
|
|
700
698
|
): Sink.Sink<A, In, L, E, R0 | R> =>
|
|
701
|
-
new SinkImpl(channel.unwrap(
|
|
699
|
+
new SinkImpl(channel.unwrap(Effect.contextWith((context) => toChannel(f(context)))))
|
|
702
700
|
|
|
703
701
|
/** @internal */
|
|
704
702
|
export const every = <In>(predicate: Predicate<In>): Sink.Sink<boolean, In, In> =>
|
|
@@ -1487,7 +1485,7 @@ export const fromQueue = <In>(
|
|
|
1487
1485
|
fromQueue
|
|
1488
1486
|
)
|
|
1489
1487
|
) :
|
|
1490
|
-
forEachChunk((input: Chunk.Chunk<In>) =>
|
|
1488
|
+
forEachChunk((input: Chunk.Chunk<In>) => Queue.offerAll(queue, input))
|
|
1491
1489
|
|
|
1492
1490
|
/** @internal */
|
|
1493
1491
|
export const head = <In>(): Sink.Sink<Option.Option<In>, In, In> =>
|
package/src/internal/stm/stm.ts
CHANGED
|
@@ -340,21 +340,19 @@ export const every = dual<
|
|
|
340
340
|
iterable: Iterable<A>,
|
|
341
341
|
predicate: (a: A) => STM.STM<boolean, E, R>
|
|
342
342
|
): STM.STM<boolean, E, R> =>
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
)
|
|
354
|
-
})
|
|
355
|
-
return loop
|
|
343
|
+
core.flatMap(core.sync(() => iterable[Symbol.iterator]()), (iterator) => {
|
|
344
|
+
const loop: STM.STM<boolean, E, R> = suspend(() => {
|
|
345
|
+
const next = iterator.next()
|
|
346
|
+
if (next.done) {
|
|
347
|
+
return core.succeed(true)
|
|
348
|
+
}
|
|
349
|
+
return pipe(
|
|
350
|
+
predicate(next.value),
|
|
351
|
+
core.flatMap((bool) => bool ? loop : core.succeed(bool))
|
|
352
|
+
)
|
|
356
353
|
})
|
|
357
|
-
|
|
354
|
+
return loop
|
|
355
|
+
})
|
|
358
356
|
)
|
|
359
357
|
|
|
360
358
|
/** @internal */
|
|
@@ -1156,12 +1154,10 @@ export const repeatWhile = dual<
|
|
|
1156
1154
|
>(2, (self, predicate) => repeatWhileLoop(self, predicate))
|
|
1157
1155
|
|
|
1158
1156
|
const repeatWhileLoop = <A, E, R>(self: STM.STM<A, E, R>, predicate: Predicate<A>): STM.STM<A, E, R> =>
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
predicate
|
|
1162
|
-
|
|
1163
|
-
core.succeed(a))
|
|
1164
|
-
)
|
|
1157
|
+
core.flatMap(self, (a) =>
|
|
1158
|
+
predicate(a) ?
|
|
1159
|
+
repeatWhileLoop(self, predicate) :
|
|
1160
|
+
core.succeed(a))
|
|
1165
1161
|
|
|
1166
1162
|
/** @internal */
|
|
1167
1163
|
export const replicate = dual<
|
package/src/internal/stream.ts
CHANGED
|
@@ -2016,7 +2016,7 @@ export const distributedWith = dual<
|
|
|
2016
2016
|
)
|
|
2017
2017
|
return pipe(
|
|
2018
2018
|
Deferred.succeed(deferred, (a: A) =>
|
|
2019
|
-
Effect.map(options.decide(a), (f) => (key: number) =>
|
|
2019
|
+
Effect.map(options.decide(a), (f) => (key: number) => f(mappings.get(key)!))),
|
|
2020
2020
|
Effect.as(
|
|
2021
2021
|
Array.from(queues) as Types.TupleOf<N, Queue.Dequeue<Exit.Exit<A, Option.Option<E>>>>
|
|
2022
2022
|
)
|
|
@@ -2143,14 +2143,12 @@ export const distributedWithDynamicCallback = dual<
|
|
|
2143
2143
|
}),
|
|
2144
2144
|
Effect.flatMap((ids) => {
|
|
2145
2145
|
if (Chunk.isNonEmpty(ids)) {
|
|
2146
|
-
return
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
})
|
|
2153
|
-
)
|
|
2146
|
+
return Ref.update(queuesRef, (map) => {
|
|
2147
|
+
for (const id of ids) {
|
|
2148
|
+
map.delete(id)
|
|
2149
|
+
}
|
|
2150
|
+
return map
|
|
2151
|
+
})
|
|
2154
2152
|
}
|
|
2155
2153
|
return Effect.void
|
|
2156
2154
|
})
|
|
@@ -8374,21 +8372,17 @@ export const zipLatestWith: {
|
|
|
8374
8372
|
mergeEither(repeatEffectOption(right)),
|
|
8375
8373
|
mapEffectSequential(Either.match({
|
|
8376
8374
|
onLeft: (leftChunk) =>
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
] as const)
|
|
8383
|
-
),
|
|
8375
|
+
Ref.modify(latest, ([_, rightLatest]) =>
|
|
8376
|
+
[
|
|
8377
|
+
pipe(leftChunk, Chunk.map((a) => f(a, rightLatest))),
|
|
8378
|
+
[Chunk.unsafeLast(leftChunk), rightLatest] as const
|
|
8379
|
+
] as const),
|
|
8384
8380
|
onRight: (rightChunk) =>
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
] as const)
|
|
8391
|
-
)
|
|
8381
|
+
Ref.modify(latest, ([leftLatest, _]) =>
|
|
8382
|
+
[
|
|
8383
|
+
pipe(rightChunk, Chunk.map((a2) => f(leftLatest, a2))),
|
|
8384
|
+
[leftLatest, Chunk.unsafeLast(rightChunk)] as const
|
|
8385
|
+
] as const)
|
|
8392
8386
|
})),
|
|
8393
8387
|
flatMap(fromChunk)
|
|
8394
8388
|
)
|
package/src/internal/version.ts
CHANGED