UrlParams
Combinators
Signature
declare const append: { (key: string, value: Coercible): (self: UrlParams) => UrlParams; (self: UrlParams, key: string, value: Coercible): UrlParams;}Signature
declare const appendAll: { (input: Input): (self: UrlParams) => UrlParams; (self: UrlParams, input: Input): UrlParams;}Signature
declare const getAll: { (key: string): (self: UrlParams) => readonly Array<string>; (self: UrlParams, key: string): readonly Array<string>;}Signature
declare const getFirst: { (key: string): (self: UrlParams) => Option<string>; (self: UrlParams, key: string): Option<string>;}Signature
declare const getLast: { (key: string): (self: UrlParams) => Option<string>; (self: UrlParams, key: string): Option<string>;}Signature
declare const remove: { (key: string): (self: UrlParams) => UrlParams; (self: UrlParams, key: string): UrlParams;}Signature
declare const set: { (key: string, value: Coercible): (self: UrlParams) => UrlParams; (self: UrlParams, key: string, value: Coercible): UrlParams;}Signature
declare const setAll: { (input: Input): (self: UrlParams) => UrlParams; (self: UrlParams, input: Input): UrlParams;}Constructors
Conversions
Signature
declare function makeUrl(url: string, params: UrlParams, hash: Option<string>): Either<URL, Error>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"] })Signature
declare function toString(self: UrlParams): stringModels
Signature
type Coercible = string | number | bigint | boolean | null | undefinedCoercibleRecord interface
Added in v1.0.0
Source
Signature
interface CoercibleRecord { [key: string]: CoercibleRecord | Coercible | readonly Array<Coercible>;}Signature
type Input = CoercibleRecord | Iterable<readonly [string, Coercible]> | URLSearchParamsSignature
interface UrlParams extends ReadonlyArray<readonly [string, string]> { [n: number]: readonly [string, string];}Schema
schemaFromString
Added in v1.0.0
Source
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): anyschemaRecord
Added in v1.0.0
Source
Signature
declare function schemaRecord<A, I extends Record<string, string | readonly Array<string> | undefined>, R>(schema: any): anyschemaStruct
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
schemaFromSelf
Added in v1.0.0
Source
Signature
declare const schemaFromSelf: Schema.Schema<UrlParams>