Skip to main content

Headers

Callable

  • Headers(values: Iterable<readonly [string, string], any, any> | Record<string, string>): Headers

  • HTTP header record constructor

    @example
    const headersFromIterable = Headers([
    ['key1', 'value1'],
    ['key2', 'value2']
    ]);// { key1: 'value1, key2: 'value2' }
    const headersFromObject = Headers({
    key1: 'value1',
    key2: 'value2'
    });// { key1: 'value1, key2: 'value2' }

Index

Codec

codecDecode

  • codecDecode(this: void, input: unknown, context: Context<Record<string, string>>): Result<Record<string, string>, CodecError>
  • Returns the decoded input, Result.Ok or Result.Error()

    @example
    interface SomeObject {
    foo: string
    }
    const someCodec: Codec<SomeObject> = ...;
    const input: unknown = ...;
    const decoded = Codec.decode(someCodec, input);

codecEncode

  • codecEncode(this: void, input: Record<string, string>): unknown
  • Returns the encoded input

    @example
    interface SomeObject {
    foo: string
    }
    const someCodec: Codec<SomeObject> = ...;
    const someObject: SomeObject = { foo: "bar" }
    const encoded = Codec.decode(someCodec, someObject);

codecSchema

  • codecSchema(this: void): JSONValue
  • Returns the JSONSchema corresponding to the decoded type

    @example
    const someCodec: Codec<unknown> = ...;
    const jsonSchema = Codec.schema(someCodec);

Constructor

asInstance

  • asInstance(anyValue: unknown): Option<Record<string, string>>
  • Try to convert anyValue to enum value or else returns Option.None

    @example
    const StringType: Type<string>;
    StringType.asInstance('foo'); // Option.Some('foo')
    StringType.asInstance(12); // Option.None

Type

inspect

inspect: Option<(anyValue: Record<string, string>, depth: number, options: InspectOptions, inspect: InspectFunction) => string>

When defined, returns a custom string representation

@example

@param

hasInstance

  • hasInstance(anyValue: unknown): anyValue is Record<string, string>
  • Return true if the given value is an instance of the class.

    @example
    const StringType: Type<string>;
    StringType.hasInstance('foo'); // true
    StringType.hasInstance(42); // false

Other

__call__

__call__: (values: Iterable<readonly [string, string], any, any> | Record<string, string>) => Headers = ...

empty

empty: () => Readonly<{}>

typeName

typeName: string = 'Headers'