Skip to content
Effect Days 2026 Get your ticket

UrlParams

23 exports Added in v1.0.0 Source

Combinators

append

Added in v1.0.0 Source

Signature

declare const append: {
(key: string, value: Coercible): (self: UrlParams) => UrlParams;
(self: UrlParams, key: string, value: Coercible): UrlParams;
}

appendAll

Added in v1.0.0 Source

Signature

declare const appendAll: {
(input: Input): (self: UrlParams) => UrlParams;
(self: UrlParams, input: Input): UrlParams;
}

getAll

Added in v1.0.0 Source

Signature

declare const getAll: {
(key: string): (self: UrlParams) => readonly Array<string>;
(self: UrlParams, key: string): readonly Array<string>;
}

getFirst

Added in v1.0.0 Source

Signature

declare const getFirst: {
(key: string): (self: UrlParams) => Option<string>;
(self: UrlParams, key: string): Option<string>;
}

getLast

Added in v1.0.0 Source

Signature

declare const getLast: {
(key: string): (self: UrlParams) => Option<string>;
(self: UrlParams, key: string): Option<string>;
}

remove

Added in v1.0.0 Source

Signature

declare const remove: {
(key: string): (self: UrlParams) => UrlParams;
(self: UrlParams, key: string): UrlParams;
}

set

Added in v1.0.0 Source

Signature

declare const set: {
(key: string, value: Coercible): (self: UrlParams) => UrlParams;
(self: UrlParams, key: string, value: Coercible): UrlParams;
}

setAll

Added in v1.0.0 Source

Signature

declare const setAll: {
(input: Input): (self: UrlParams) => UrlParams;
(self: UrlParams, input: Input): UrlParams;
}

Constructors

empty

Added in v1.0.0 Source

Signature

declare const empty: UrlParams

fromInput

Added in v1.0.0 Source

Signature

declare function fromInput(input: Input): UrlParams

Conversions

makeUrl

Added in v1.0.0 Source

Signature

declare function makeUrl(url: string, params: UrlParams, hash: Option<string>): Either<URL, Error>

toRecord

Added in v1.0.0 Source

Builds a Record containing all the key-value pairs in the given UrlParams as string (if only one value for a key) or a NonEmptyArray<string> (when more than one value for a key)

Signature

declare function toRecord(self: UrlParams): Record<string, string | Arr.NonEmptyArray<string>>

Example

import * as assert from "node:assert"
import { UrlParams } from "@effect/platform"
const urlParams = UrlParams.fromInput({ a: 1, b: true, c: "string", e: [1, 2, 3] })
const result = UrlParams.toRecord(urlParams)
assert.deepStrictEqual(
result,
{ "a": "1", "b": "true", "c": "string", "e": ["1", "2", "3"] }
)

toString

Added in v1.0.0 Source

Signature

declare function toString(self: UrlParams): string

Models

Coercible type

Added in v1.0.0 Source

Signature

type Coercible = string | number | bigint | boolean | null | undefined

CoercibleRecord interface

Added in v1.0.0 Source

Signature

interface CoercibleRecord {
[key: string]: CoercibleRecord | Coercible | readonly Array<Coercible>;
}

Input type

Added in v1.0.0 Source

Signature

type Input = CoercibleRecord | Iterable<readonly [string, Coercible]> | URLSearchParams

UrlParams interface

Added in v1.0.0 Source

Signature

interface UrlParams extends ReadonlyArray<readonly [string, string]> {
[n: number]: readonly [string, string];
}

Schema

Signature

declare const schemaFromString: Schema.Schema<UrlParams, string>

schemaJson

Added in v1.0.0 Source

Signature

declare function schemaJson<A, I, R>(schema: any, options?: ParseOptions): {
(field: string): (self: UrlParams) => Effect<A, ParseError, R>;
(self: UrlParams, field: string): Effect<A, ParseError, R>;
}

schemaParse

Added in v1.0.0 Source

Signature

declare function schemaParse<A, I extends Record<string, string | readonly Array<string> | undefined>, R>(schema: any): any

schemaRecord

Added in v1.0.0 Source

Signature

declare function schemaRecord<A, I extends Record<string, string | readonly Array<string> | undefined>, R>(schema: any): any

schemaStruct

Added in v1.0.0 Source

Extract schema from all key-value pairs in the given UrlParams.

Signature

declare function schemaStruct<A, I extends Record<string, string | readonly Array<string> | undefined>, R>(schema: any, options?: ParseOptions): (self: UrlParams) => Effect<A, ParseError, R>

Example

import * as assert from "node:assert"
import { Effect, Schema } from "effect"
import { UrlParams } from "@effect/platform"
Effect.gen(function* () {
const urlParams = UrlParams.fromInput({ "a": [10, "string"], "b": false })
const result = yield* UrlParams.schemaStruct(Schema.Struct({
a: Schema.Tuple(Schema.NumberFromString, Schema.String),
b: Schema.BooleanFromString
}))(urlParams)
assert.deepStrictEqual(result, {
a: [10, "string"],
b: false
})
})

Schemas

Signature

declare const schemaFromSelf: Schema.Schema<UrlParams>