effect 3.10.14 → 3.10.16
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/JSONSchema.js +26 -1
- package/dist/cjs/JSONSchema.js.map +1 -1
- package/dist/cjs/ParseResult.js +1 -1
- package/dist/cjs/ParseResult.js.map +1 -1
- package/dist/cjs/Schema.js +11 -15
- package/dist/cjs/Schema.js.map +1 -1
- package/dist/cjs/SchemaAST.js +7 -3
- package/dist/cjs/SchemaAST.js.map +1 -1
- package/dist/cjs/Stream.js +1 -1
- package/dist/cjs/Stream.js.map +1 -1
- package/dist/cjs/internal/mailbox.js +20 -1
- package/dist/cjs/internal/mailbox.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/Schema.d.ts +1 -1
- package/dist/dts/Schema.d.ts.map +1 -1
- package/dist/dts/SchemaAST.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/JSONSchema.js +26 -1
- package/dist/esm/JSONSchema.js.map +1 -1
- package/dist/esm/ParseResult.js +1 -1
- package/dist/esm/ParseResult.js.map +1 -1
- package/dist/esm/Schema.js +11 -15
- package/dist/esm/Schema.js.map +1 -1
- package/dist/esm/SchemaAST.js +5 -1
- package/dist/esm/SchemaAST.js.map +1 -1
- package/dist/esm/Stream.js +1 -1
- package/dist/esm/Stream.js.map +1 -1
- package/dist/esm/internal/mailbox.js +20 -1
- package/dist/esm/internal/mailbox.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/JSONSchema.ts +20 -1
- package/src/ParseResult.ts +1 -1
- package/src/Schema.ts +6 -15
- package/src/SchemaAST.ts +8 -1
- package/src/Stream.ts +43 -3
- package/src/internal/mailbox.ts +23 -2
- 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/JSONSchema.ts
CHANGED
|
@@ -600,7 +600,26 @@ const go = (
|
|
|
600
600
|
// the 'to' side of the AST. This approach prevents the generation of useless schemas
|
|
601
601
|
// derived from the 'from' side (type: string), ensuring the output matches the intended
|
|
602
602
|
// complex schema type.
|
|
603
|
-
|
|
603
|
+
if (isParseJsonTransformation(ast.from)) {
|
|
604
|
+
return go(ast.to, $defs, true, path)
|
|
605
|
+
}
|
|
606
|
+
let next = ast.from
|
|
607
|
+
if (AST.isTypeLiteralTransformation(ast.transformation)) {
|
|
608
|
+
// Annotations from the transformation are applied unless there are user-defined annotations on the form side,
|
|
609
|
+
// ensuring that the user's intended annotations are included in the generated schema.
|
|
610
|
+
const identifier = AST.getIdentifierAnnotation(ast)
|
|
611
|
+
if (Option.isSome(identifier) && Option.isNone(AST.getIdentifierAnnotation(next))) {
|
|
612
|
+
next = AST.annotations(next, { [AST.IdentifierAnnotationId]: identifier.value })
|
|
613
|
+
}
|
|
614
|
+
const title = AST.getTitleAnnotation(ast)
|
|
615
|
+
if (Option.isSome(title) && Option.isNone(AST.getTitleAnnotation(next))) {
|
|
616
|
+
next = AST.annotations(next, { [AST.TitleAnnotationId]: title.value })
|
|
617
|
+
}
|
|
618
|
+
const description = AST.getDescriptionAnnotation(ast)
|
|
619
|
+
if (Option.isSome(description) && Option.isNone(AST.getDescriptionAnnotation(next))) {
|
|
620
|
+
next = AST.annotations(next, { [AST.DescriptionAnnotationId]: description.value })
|
|
621
|
+
}
|
|
622
|
+
}
|
|
604
623
|
return go(next, $defs, true, path)
|
|
605
624
|
}
|
|
606
625
|
}
|
package/src/ParseResult.ts
CHANGED
|
@@ -854,7 +854,7 @@ const go = (ast: AST.AST, isDecoding: boolean): Parser => {
|
|
|
854
854
|
const result = flatMap(
|
|
855
855
|
orElse(from(i, options), (ef) => {
|
|
856
856
|
const issue = new Refinement(ast, i, "From", ef)
|
|
857
|
-
if (allErrors && AST.hasStableFilter(ast)) {
|
|
857
|
+
if (allErrors && AST.hasStableFilter(ast) && isComposite(ef)) {
|
|
858
858
|
return Option.match(
|
|
859
859
|
ast.filter(i, options, ast),
|
|
860
860
|
{
|
package/src/Schema.ts
CHANGED
|
@@ -2677,8 +2677,8 @@ const getDefaultTypeLiteralAST = <
|
|
|
2677
2677
|
})
|
|
2678
2678
|
}
|
|
2679
2679
|
return new AST.Transformation(
|
|
2680
|
-
new AST.TypeLiteral(from, issFrom, { [AST.
|
|
2681
|
-
new AST.TypeLiteral(to, issTo, { [AST.
|
|
2680
|
+
new AST.TypeLiteral(from, issFrom, { [AST.AutoTitleAnnotationId]: "Struct (Encoded side)" }),
|
|
2681
|
+
new AST.TypeLiteral(to, issTo, { [AST.AutoTitleAnnotationId]: "Struct (Type side)" }),
|
|
2682
2682
|
new AST.TypeLiteralTransformation(transformations)
|
|
2683
2683
|
)
|
|
2684
2684
|
}
|
|
@@ -8228,7 +8228,7 @@ export interface Class<Self, Fields extends Struct.Fields, I, R, C, Inherited, P
|
|
|
8228
8228
|
new(
|
|
8229
8229
|
props: RequiredKeys<C> extends never ? void | Simplify<C> : Simplify<C>,
|
|
8230
8230
|
options?: MakeOptions
|
|
8231
|
-
): Struct.Type<Fields> &
|
|
8231
|
+
): Struct.Type<Fields> & Inherited & Proto
|
|
8232
8232
|
|
|
8233
8233
|
/** @since 3.10.0 */
|
|
8234
8234
|
readonly ast: AST.Transformation
|
|
@@ -8588,15 +8588,6 @@ const extendFields = (a: Struct.Fields, b: Struct.Fields): Struct.Fields => {
|
|
|
8588
8588
|
return out
|
|
8589
8589
|
}
|
|
8590
8590
|
|
|
8591
|
-
// does not overwrite existing title annotation
|
|
8592
|
-
const orElseTitleAnnotation = <A, I, R>(schema: Schema<A, I, R>, title: string): Schema<A, I, R> => {
|
|
8593
|
-
const annotation = AST.getTitleAnnotation(schema.ast)
|
|
8594
|
-
if (option_.isNone(annotation)) {
|
|
8595
|
-
return schema.annotations({ title })
|
|
8596
|
-
}
|
|
8597
|
-
return schema
|
|
8598
|
-
}
|
|
8599
|
-
|
|
8600
8591
|
type MakeOptions = boolean | {
|
|
8601
8592
|
readonly disableValidation?: boolean
|
|
8602
8593
|
}
|
|
@@ -8616,9 +8607,9 @@ const makeClass = ({ Base, annotations, disableToString, fields, identifier, kin
|
|
|
8616
8607
|
disableToString?: boolean | undefined
|
|
8617
8608
|
}): any => {
|
|
8618
8609
|
const classSymbol = Symbol.for(`effect/Schema/${kind}/${identifier}`)
|
|
8619
|
-
const validateSchema =
|
|
8620
|
-
const encodedSide: Schema.Any =
|
|
8621
|
-
const typeSide =
|
|
8610
|
+
const validateSchema = schema.annotations({ [AST.AutoTitleAnnotationId]: `${identifier} (Constructor)` })
|
|
8611
|
+
const encodedSide: Schema.Any = schema.annotations({ [AST.AutoTitleAnnotationId]: `${identifier} (Encoded side)` })
|
|
8612
|
+
const typeSide = typeSchema(schema).annotations({ [AST.AutoTitleAnnotationId]: `${identifier} (Type side)` })
|
|
8622
8613
|
const fallbackInstanceOf = (u: unknown) => Predicate.hasProperty(u, classSymbol) && ParseResult.is(typeSide)(u)
|
|
8623
8614
|
const klass = class extends Base {
|
|
8624
8615
|
constructor(
|
package/src/SchemaAST.ts
CHANGED
|
@@ -126,6 +126,9 @@ export type TitleAnnotation = string
|
|
|
126
126
|
*/
|
|
127
127
|
export const TitleAnnotationId: unique symbol = Symbol.for("effect/annotation/Title")
|
|
128
128
|
|
|
129
|
+
/** @internal */
|
|
130
|
+
export const AutoTitleAnnotationId: unique symbol = Symbol.for("effect/annotation/AutoTitle")
|
|
131
|
+
|
|
129
132
|
/**
|
|
130
133
|
* @category annotations
|
|
131
134
|
* @since 3.10.0
|
|
@@ -354,6 +357,9 @@ export const getMissingMessageAnnotation = getAnnotation<MissingMessageAnnotatio
|
|
|
354
357
|
*/
|
|
355
358
|
export const getTitleAnnotation = getAnnotation<TitleAnnotation>(TitleAnnotationId)
|
|
356
359
|
|
|
360
|
+
/** @internal */
|
|
361
|
+
export const getAutoTitleAnnotation = getAnnotation<TitleAnnotation>(AutoTitleAnnotationId)
|
|
362
|
+
|
|
357
363
|
/**
|
|
358
364
|
* @category annotations
|
|
359
365
|
* @since 3.10.0
|
|
@@ -2822,6 +2828,7 @@ const formatKeyword = (ast: AST): string => Option.getOrElse(getExpected(ast), (
|
|
|
2822
2828
|
const getExpected = (ast: Annotated): Option.Option<string> => {
|
|
2823
2829
|
return getIdentifierAnnotation(ast).pipe(
|
|
2824
2830
|
Option.orElse(() => getTitleAnnotation(ast)),
|
|
2825
|
-
Option.orElse(() => getDescriptionAnnotation(ast))
|
|
2831
|
+
Option.orElse(() => getDescriptionAnnotation(ast)),
|
|
2832
|
+
Option.orElse(() => getAutoTitleAnnotation(ast))
|
|
2826
2833
|
)
|
|
2827
2834
|
}
|
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"
|
package/src/internal/mailbox.ts
CHANGED
|
@@ -85,7 +85,7 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
85
85
|
private messagesChunk = Chunk.empty<A>()
|
|
86
86
|
constructor(
|
|
87
87
|
readonly scheduler: Scheduler,
|
|
88
|
-
|
|
88
|
+
private capacity: number,
|
|
89
89
|
readonly strategy: "suspend" | "dropping" | "sliding"
|
|
90
90
|
) {
|
|
91
91
|
super()
|
|
@@ -100,6 +100,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
100
100
|
case "dropping":
|
|
101
101
|
return exitFalse
|
|
102
102
|
case "suspend":
|
|
103
|
+
if (this.capacity <= 0 && this.state.takers.size > 0) {
|
|
104
|
+
this.messages.push(message)
|
|
105
|
+
this.releaseTaker()
|
|
106
|
+
return exitTrue
|
|
107
|
+
}
|
|
103
108
|
return this.offerRemainingSingle(message)
|
|
104
109
|
case "sliding":
|
|
105
110
|
this.unsafeTake()
|
|
@@ -120,6 +125,10 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
120
125
|
this.unsafeTake()
|
|
121
126
|
this.messages.push(message)
|
|
122
127
|
return true
|
|
128
|
+
} else if (this.capacity <= 0 && this.state.takers.size > 0) {
|
|
129
|
+
this.messages.push(message)
|
|
130
|
+
this.releaseTaker()
|
|
131
|
+
return true
|
|
123
132
|
}
|
|
124
133
|
return false
|
|
125
134
|
}
|
|
@@ -164,7 +173,9 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
164
173
|
this.scheduleReleaseTaker()
|
|
165
174
|
return []
|
|
166
175
|
}
|
|
167
|
-
const free = this.capacity
|
|
176
|
+
const free = this.capacity <= 0
|
|
177
|
+
? this.state.takers.size
|
|
178
|
+
: this.capacity - this.messages.length - this.messagesChunk.length
|
|
168
179
|
if (free === 0) {
|
|
169
180
|
return Arr.fromIterable(messages)
|
|
170
181
|
}
|
|
@@ -274,6 +285,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
274
285
|
message = this.messages[0]
|
|
275
286
|
this.messagesChunk = Chunk.drop(Chunk.unsafeFromArray(this.messages), 1)
|
|
276
287
|
this.messages = []
|
|
288
|
+
} else if (this.capacity <= 0 && this.state.offers.size > 0) {
|
|
289
|
+
this.capacity = 1
|
|
290
|
+
this.releaseCapacity()
|
|
291
|
+
this.capacity = 0
|
|
292
|
+
return this.messages.length > 0 ? core.exitSucceed(this.messages.pop()!) : undefined
|
|
277
293
|
} else {
|
|
278
294
|
return undefined
|
|
279
295
|
}
|
|
@@ -422,6 +438,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
|
|
|
422
438
|
const messages = Chunk.unsafeFromArray(this.messages)
|
|
423
439
|
this.messages = []
|
|
424
440
|
return messages
|
|
441
|
+
} else if (this.state._tag !== "Done" && this.state.offers.size > 0) {
|
|
442
|
+
this.capacity = 1
|
|
443
|
+
this.releaseCapacity()
|
|
444
|
+
this.capacity = 0
|
|
445
|
+
return Chunk.of(this.messages.pop()!)
|
|
425
446
|
}
|
|
426
447
|
return empty
|
|
427
448
|
}
|
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