effect 3.10.13 → 3.10.15
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/DateTime.js +9 -3
- package/dist/cjs/DateTime.js.map +1 -1
- package/dist/cjs/Schema.js +1 -1
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/Stream.js +1 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/managedRuntime.js +9 -6
- package/dist/cjs/internal/managedRuntime.js.map +1 -1
- package/dist/cjs/internal/stream.js.map +1 -1
- package/dist/cjs/internal/version.js +1 -1
- package/dist/dts/DateTime.d.ts +4 -4
- package/dist/dts/DateTime.d.ts.map +1 -1
- package/dist/dts/Stream.d.ts +41 -3
- package/dist/dts/Stream.d.ts.map +1 -1
- package/dist/dts/internal/stream.d.ts.map +1 -1
- package/dist/esm/DateTime.js +9 -3
- package/dist/esm/DateTime.js.map +1 -1
- package/dist/esm/Schema.js +1 -1
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/Stream.js +1 -1
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/internal/managedRuntime.js +9 -6
- package/dist/esm/internal/managedRuntime.js.map +1 -1
- package/dist/esm/internal/stream.js.map +1 -1
- package/dist/esm/internal/version.js +1 -1
- package/package.json +1 -1
- package/src/DateTime.ts +14 -9
- package/src/Schema.ts +1 -1
- package/src/Stream.ts +43 -3
- package/src/internal/managedRuntime.ts +15 -13
- package/src/internal/stream.ts +51 -36
- package/src/internal/version.ts +1 -1
package/package.json
CHANGED
package/src/DateTime.ts
CHANGED
|
@@ -480,15 +480,21 @@ export const unsafeMake = <A extends DateTime.Input>(input: A): DateTime.Preserv
|
|
|
480
480
|
*
|
|
481
481
|
* DateTime.unsafeMakeZoned(new Date(), { timeZone: "Europe/London" })
|
|
482
482
|
*/
|
|
483
|
-
export const unsafeMakeZoned = (input: DateTime.Input, options
|
|
484
|
-
readonly timeZone
|
|
483
|
+
export const unsafeMakeZoned = (input: DateTime.Input, options?: {
|
|
484
|
+
readonly timeZone?: number | string | TimeZone | undefined
|
|
485
485
|
readonly adjustForTimeZone?: boolean | undefined
|
|
486
486
|
}): Zoned => {
|
|
487
|
+
if (options?.timeZone === undefined && isDateTime(input) && isZoned(input)) {
|
|
488
|
+
return input
|
|
489
|
+
}
|
|
487
490
|
const self = unsafeMake(input)
|
|
488
491
|
let zone: TimeZone
|
|
489
|
-
if (
|
|
492
|
+
if (options?.timeZone === undefined) {
|
|
493
|
+
const offset = new Date(self.epochMillis).getTimezoneOffset() * -60 * 1000
|
|
494
|
+
zone = zoneMakeOffset(offset)
|
|
495
|
+
} else if (isTimeZone(options?.timeZone)) {
|
|
490
496
|
zone = options.timeZone
|
|
491
|
-
} else if (typeof options
|
|
497
|
+
} else if (typeof options?.timeZone === "number") {
|
|
492
498
|
zone = zoneMakeOffset(options.timeZone)
|
|
493
499
|
} else {
|
|
494
500
|
const parsedZone = zoneFromString(options.timeZone)
|
|
@@ -497,7 +503,7 @@ export const unsafeMakeZoned = (input: DateTime.Input, options: {
|
|
|
497
503
|
}
|
|
498
504
|
zone = parsedZone.value
|
|
499
505
|
}
|
|
500
|
-
if (options
|
|
506
|
+
if (options?.adjustForTimeZone !== true) {
|
|
501
507
|
return makeZonedProto(self.epochMillis, zone, self.partsUtc)
|
|
502
508
|
}
|
|
503
509
|
return makeZonedFromAdjusted(self.epochMillis, zone)
|
|
@@ -519,12 +525,11 @@ export const unsafeMakeZoned = (input: DateTime.Input, options: {
|
|
|
519
525
|
*/
|
|
520
526
|
export const makeZoned: (
|
|
521
527
|
input: DateTime.Input,
|
|
522
|
-
options
|
|
523
|
-
readonly timeZone
|
|
528
|
+
options?: {
|
|
529
|
+
readonly timeZone?: number | string | TimeZone | undefined
|
|
524
530
|
readonly adjustForTimeZone?: boolean | undefined
|
|
525
531
|
}
|
|
526
|
-
) => Option.Option<Zoned> = Option
|
|
527
|
-
.liftThrowable(unsafeMakeZoned)
|
|
532
|
+
) => Option.Option<Zoned> = Option.liftThrowable(unsafeMakeZoned)
|
|
528
533
|
|
|
529
534
|
/**
|
|
530
535
|
* Create a `DateTime` from one of the following:
|
package/src/Schema.ts
CHANGED
|
@@ -5443,7 +5443,7 @@ export const JsonNumberSchemaId: unique symbol = Symbol.for("effect/SchemaId/Jso
|
|
|
5443
5443
|
* @since 3.10.0
|
|
5444
5444
|
*/
|
|
5445
5445
|
export class JsonNumber extends Number$.pipe(
|
|
5446
|
-
filter(
|
|
5446
|
+
filter(Number.isFinite, {
|
|
5447
5447
|
schemaId: JsonNumberSchemaId,
|
|
5448
5448
|
identifier: "JsonNumber",
|
|
5449
5449
|
title: "JSON-compatible number",
|
package/src/Stream.ts
CHANGED
|
@@ -8224,7 +8224,7 @@ export const someOrFail: {
|
|
|
8224
8224
|
} = internal.someOrFail
|
|
8225
8225
|
|
|
8226
8226
|
/**
|
|
8227
|
-
* Splits elements based on a predicate.
|
|
8227
|
+
* Splits elements based on a predicate or refinement.
|
|
8228
8228
|
*
|
|
8229
8229
|
* ```ts
|
|
8230
8230
|
* import * as Stream from "./Stream"
|
|
@@ -8243,7 +8243,28 @@ export const someOrFail: {
|
|
|
8243
8243
|
*/
|
|
8244
8244
|
export const split: {
|
|
8245
8245
|
/**
|
|
8246
|
-
* Splits elements based on a predicate.
|
|
8246
|
+
* Splits elements based on a predicate or refinement.
|
|
8247
|
+
*
|
|
8248
|
+
* ```ts
|
|
8249
|
+
* import * as Stream from "./Stream"
|
|
8250
|
+
* import { pipe } from "./Function"
|
|
8251
|
+
*
|
|
8252
|
+
* pipe(
|
|
8253
|
+
* Stream.range(1, 10),
|
|
8254
|
+
* Stream.split((n) => n % 4 === 0),
|
|
8255
|
+
* Stream.runCollect
|
|
8256
|
+
* )
|
|
8257
|
+
* // => Chunk(Chunk(1, 2, 3), Chunk(5, 6, 7), Chunk(9))
|
|
8258
|
+
* ```
|
|
8259
|
+
*
|
|
8260
|
+
* @since 2.0.0
|
|
8261
|
+
* @category utils
|
|
8262
|
+
*/
|
|
8263
|
+
<A, B extends A>(
|
|
8264
|
+
refinement: Refinement<NoInfer<A>, B>
|
|
8265
|
+
): <E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<Exclude<A, B>>, E, R>
|
|
8266
|
+
/**
|
|
8267
|
+
* Splits elements based on a predicate or refinement.
|
|
8247
8268
|
*
|
|
8248
8269
|
* ```ts
|
|
8249
8270
|
* import * as Stream from "./Stream"
|
|
@@ -8262,7 +8283,26 @@ export const split: {
|
|
|
8262
8283
|
*/
|
|
8263
8284
|
<A>(predicate: Predicate<NoInfer<A>>): <E, R>(self: Stream<A, E, R>) => Stream<Chunk.Chunk<A>, E, R>
|
|
8264
8285
|
/**
|
|
8265
|
-
* Splits elements based on a predicate.
|
|
8286
|
+
* Splits elements based on a predicate or refinement.
|
|
8287
|
+
*
|
|
8288
|
+
* ```ts
|
|
8289
|
+
* import * as Stream from "./Stream"
|
|
8290
|
+
* import { pipe } from "./Function"
|
|
8291
|
+
*
|
|
8292
|
+
* pipe(
|
|
8293
|
+
* Stream.range(1, 10),
|
|
8294
|
+
* Stream.split((n) => n % 4 === 0),
|
|
8295
|
+
* Stream.runCollect
|
|
8296
|
+
* )
|
|
8297
|
+
* // => Chunk(Chunk(1, 2, 3), Chunk(5, 6, 7), Chunk(9))
|
|
8298
|
+
* ```
|
|
8299
|
+
*
|
|
8300
|
+
* @since 2.0.0
|
|
8301
|
+
* @category utils
|
|
8302
|
+
*/
|
|
8303
|
+
<A, E, R, B extends A>(self: Stream<A, E, R>, refinement: Refinement<A, B>): Stream<Chunk.Chunk<Exclude<A, B>>, E, R>
|
|
8304
|
+
/**
|
|
8305
|
+
* Splits elements based on a predicate or refinement.
|
|
8266
8306
|
*
|
|
8267
8307
|
* ```ts
|
|
8268
8308
|
* import * as Stream from "./Stream"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Mutable } from "effect/Types"
|
|
2
1
|
import type * as Effect from "../Effect.js"
|
|
3
2
|
import * as Effectable from "../Effectable.js"
|
|
4
3
|
import type { Exit } from "../Exit.js"
|
|
@@ -9,6 +8,7 @@ import { pipeArguments } from "../Pipeable.js"
|
|
|
9
8
|
import { hasProperty } from "../Predicate.js"
|
|
10
9
|
import type * as Runtime from "../Runtime.js"
|
|
11
10
|
import * as Scope from "../Scope.js"
|
|
11
|
+
import type { Mutable } from "../Types.js"
|
|
12
12
|
import * as core from "./core.js"
|
|
13
13
|
import * as fiberRuntime from "./fiberRuntime.js"
|
|
14
14
|
import * as internalLayer from "./layer.js"
|
|
@@ -57,19 +57,21 @@ export const make = <R, ER>(
|
|
|
57
57
|
memoMap = memoMap ?? internalLayer.unsafeMakeMemoMap()
|
|
58
58
|
const scope = internalRuntime.unsafeRunSyncEffect(fiberRuntime.scopeMake())
|
|
59
59
|
let buildFiber: Fiber.RuntimeFiber<Runtime.Runtime<R>, ER> | undefined
|
|
60
|
-
const runtimeEffect = core.
|
|
61
|
-
buildFiber
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const runtimeEffect = core.withFiberRuntime<Runtime.Runtime<R>, ER>((fiber) => {
|
|
61
|
+
if (!buildFiber) {
|
|
62
|
+
buildFiber = internalRuntime.unsafeForkEffect(
|
|
63
|
+
core.tap(
|
|
64
|
+
Scope.extend(
|
|
65
|
+
internalLayer.toRuntimeWithMemoMap(layer, memoMap),
|
|
66
|
+
scope
|
|
67
|
+
),
|
|
68
|
+
(rt) => {
|
|
69
|
+
self.cachedRuntime = rt
|
|
70
|
+
}
|
|
66
71
|
),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
),
|
|
71
|
-
{ scope }
|
|
72
|
-
)
|
|
72
|
+
{ scope, scheduler: fiber.currentScheduler }
|
|
73
|
+
)
|
|
74
|
+
}
|
|
73
75
|
return core.flatten(buildFiber.await)
|
|
74
76
|
})
|
|
75
77
|
const self: ManagedRuntimeImpl<R, ER> = Object.assign(Object.create(ManagedRuntimeProto), {
|
package/src/internal/stream.ts
CHANGED
|
@@ -6189,44 +6189,59 @@ export const slidingSize = dual<
|
|
|
6189
6189
|
)
|
|
6190
6190
|
|
|
6191
6191
|
/** @internal */
|
|
6192
|
-
export const split
|
|
6193
|
-
<A
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6192
|
+
export const split: {
|
|
6193
|
+
<A, B extends A>(
|
|
6194
|
+
refinement: Refinement<NoInfer<A>, B>
|
|
6195
|
+
): <E, R>(self: Stream.Stream<A, E, R>) => Stream.Stream<Chunk.Chunk<Exclude<A, B>>, E, R>
|
|
6196
|
+
<A>(
|
|
6197
|
+
predicate: Predicate<NoInfer<A>>
|
|
6198
|
+
): <E, R>(self: Stream.Stream<A, E, R>) => Stream.Stream<Chunk.Chunk<A>, E, R>
|
|
6199
|
+
<A, E, R, B extends A>(
|
|
6200
|
+
self: Stream.Stream<A, E, R>,
|
|
6201
|
+
refinement: Refinement<A, B>
|
|
6202
|
+
): Stream.Stream<Chunk.Chunk<Exclude<A, B>>, E, R>
|
|
6203
|
+
<A, E, R>(self: Stream.Stream<A, E, R>, predicate: Predicate<A>): Stream.Stream<Chunk.Chunk<A>, E, R>
|
|
6204
|
+
} = dual(
|
|
6205
|
+
2,
|
|
6206
|
+
<A, E, R>(
|
|
6207
|
+
self: Stream.Stream<A, E, R>,
|
|
6208
|
+
predicate: Predicate<A>
|
|
6209
|
+
): Stream.Stream<Chunk.Chunk<A>, E, R> => {
|
|
6210
|
+
const split = (
|
|
6211
|
+
leftovers: Chunk.Chunk<A>,
|
|
6212
|
+
input: Chunk.Chunk<A>
|
|
6213
|
+
): Channel.Channel<Chunk.Chunk<Chunk.Chunk<A>>, Chunk.Chunk<A>, E, E, unknown, unknown, R> => {
|
|
6214
|
+
const [chunk, remaining] = pipe(leftovers, Chunk.appendAll(input), Chunk.splitWhere(predicate))
|
|
6215
|
+
if (Chunk.isEmpty(chunk) || Chunk.isEmpty(remaining)) {
|
|
6216
|
+
return loop(pipe(chunk, Chunk.appendAll(pipe(remaining, Chunk.drop(1)))))
|
|
6217
|
+
}
|
|
6218
|
+
return pipe(
|
|
6219
|
+
core.write(Chunk.of(chunk)),
|
|
6220
|
+
core.flatMap(() => split(Chunk.empty(), pipe(remaining, Chunk.drop(1))))
|
|
6221
|
+
)
|
|
6203
6222
|
}
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
return
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6223
|
+
const loop = (
|
|
6224
|
+
leftovers: Chunk.Chunk<A>
|
|
6225
|
+
): Channel.Channel<Chunk.Chunk<Chunk.Chunk<A>>, Chunk.Chunk<A>, E, E, unknown, unknown, R> =>
|
|
6226
|
+
core.readWith({
|
|
6227
|
+
onInput: (input: Chunk.Chunk<A>) => split(leftovers, input),
|
|
6228
|
+
onFailure: core.fail,
|
|
6229
|
+
onDone: () => {
|
|
6230
|
+
if (Chunk.isEmpty(leftovers)) {
|
|
6231
|
+
return core.void
|
|
6232
|
+
}
|
|
6233
|
+
if (Option.isNone(pipe(leftovers, Chunk.findFirst(predicate)))) {
|
|
6234
|
+
return channel.zipRight(core.write(Chunk.of(leftovers)), core.void)
|
|
6235
|
+
}
|
|
6236
|
+
return channel.zipRight(
|
|
6237
|
+
split(Chunk.empty(), leftovers),
|
|
6238
|
+
core.void
|
|
6239
|
+
)
|
|
6221
6240
|
}
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
}
|
|
6227
|
-
})
|
|
6228
|
-
return new StreamImpl(pipe(toChannel(self), core.pipeTo(loop(Chunk.empty()))))
|
|
6229
|
-
})
|
|
6241
|
+
})
|
|
6242
|
+
return new StreamImpl(pipe(toChannel(self), core.pipeTo(loop(Chunk.empty()))))
|
|
6243
|
+
}
|
|
6244
|
+
)
|
|
6230
6245
|
|
|
6231
6246
|
/** @internal */
|
|
6232
6247
|
export const splitOnChunk = dual<
|
package/src/internal/version.ts
CHANGED