(value: Value)
| 11444 | * @since 3.10.0 |
| 11445 | */ |
| 11446 | export function Chunk<Value extends Constraint>(value: Value): Chunk<Value> { |
| 11447 | const schema = declareConstructor< |
| 11448 | Chunk_.Chunk<Value["Type"]>, |
| 11449 | Chunk_.Chunk<Value["Encoded"]>, |
| 11450 | ChunkIso<Value> |
| 11451 | >()( |
| 11452 | [value], |
| 11453 | ([value]) => { |
| 11454 | const values = ArraySchema(value) |
| 11455 | return (input, ast, options) => { |
| 11456 | if (Chunk_.isChunk(input)) { |
| 11457 | return Effect.mapBothEager( |
| 11458 | SchemaParser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), |
| 11459 | { |
| 11460 | onSuccess: Chunk_.fromArrayUnsafe, |
| 11461 | onFailure: (issue) => SchemaIssue.makeCompositeAtKey(ast, "values", issue, input, options) |
| 11462 | } |
| 11463 | ) |
| 11464 | } |
| 11465 | return Effect.fail(new SchemaIssue.InvalidType(ast, input, options)) |
| 11466 | } |
| 11467 | }, |
| 11468 | { |
| 11469 | representation: { |
| 11470 | id: "effect/schema/Chunk", |
| 11471 | payload: null |
| 11472 | }, |
| 11473 | expected: "Chunk", |
| 11474 | toCodec: ([value]) => chunkLink(ArraySchema(value)), |
| 11475 | toCodecArbitrary: ({ constraint, typeParameters: [value] }) => |
| 11476 | chunkLink( |
| 11477 | withArrayLengthConstraints( |
| 11478 | ArraySchema(value), |
| 11479 | constraint?.minLength, |
| 11480 | constraint?.maxLength |
| 11481 | ) |
| 11482 | ), |
| 11483 | toEquivalence: ([value]) => Chunk_.makeEquivalence(value) |
| 11484 | } |
| 11485 | ) |
| 11486 | return make(schema.ast, { value }) |
| 11487 | } |
| 11488 | |
| 11489 | // ----------------------------------------------------------------------------- |
| 11490 | // DateTime schemas |
nothing calls this directly
no test coverage detected