MCPcopy Create free account
hub / github.com/effect-app/libs / Exit

Function Exit

repos/effect/packages/effect/src/Schema.ts:9531–9634  ·  view source on GitHub ↗
(
  value: A,
  error: E,
  defect: D
)

Source from the content-addressed store, hash-verified

9529 * ```ts import.meta.vitest
9530 * import { Schema } from "effect"
9531 *
9532 * const schema = Schema.fromURLSearchParams(
9533 * Schema.Struct({
9534 * a: Schema.String,
9535 * b: Schema.Struct({
9536 * c: Schema.String,
9537 * d: Schema.String
9538 * })
9539 * })
9540 * )
9541 *
9542 * const urlSearchParams = new URLSearchParams("a=1&b[c]=2&b[d]=3")
9543 *
9544 * Schema.decodeUnknownSync(schema)(urlSearchParams) // => { a: "1", b: { c: "2", d: "3" } }
9545 * ```
9546 *
9547 * **Example** (Parsing non-string values)
9548 *
9549 * ```ts import.meta.vitest
9550 * import { Schema } from "effect"
9551 *
9552 * const schema = Schema.fromURLSearchParams(
9553 * Schema.toCodecStringTree(
9554 * Schema.Struct({
9555 * a: Schema.Int
9556 * })
9557 * )
9558 * )
9559 *
9560 * const urlSearchParams = new URLSearchParams("a=1&b=2")
9561 *
9562 * Schema.decodeUnknownSync(schema)(urlSearchParams) // => { a: 1 }
9563 * ```
9564 *
9565 * @category decoding
9566 * @since 4.0.0
9567 */
9568export function fromURLSearchParams<S extends Constraint>(schema: S): fromURLSearchParams<S> {
9569 return URLSearchParams.pipe(decodeTo(schema, SchemaTransformation.fromURLSearchParams))
9570}
9571/**
9572 * Type-level representation of {@link NumberFromString}.
9573 *
9574 * @category models
9575 * @since 3.10.0
9576 */
9577export interface NumberFromString extends decodeTo<Number, String> {
9578 readonly "Rebuild": NumberFromString
9579}
9580/**
9581 * Schema that parses a string into a `number` using JavaScript
9582 * number coercion.
9583 *
9584 * **Details**
9585 *
9586 * Decoding:
9587 * A `string` is decoded as a number, including possible non-finite values such as
9588 * `NaN`, `Infinity`, and `-Infinity`. Use `FiniteFromString` to reject non-finite

Callers

nothing calls this directly

Calls 15

causeToArbitraryFunction · 0.85
oneOfArbitrariesFunction · 0.85
withRecursionFunction · 0.85
causeToEquivalenceFunction · 0.85
causeFunction · 0.85
causeToFormatterFunction · 0.85
someMethod · 0.80
declareConstructorFunction · 0.70
CauseFunction · 0.70
linkFunction · 0.70
UnionFunction · 0.70
StructFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…