Skip to content

Reqor Namespace ​

Types and classes exposed under the Reqor namespace.

Classes ​

Reqor.Error ​

Error instance used by Reqor.

Constructor ​

ts
new Reqor.Error(message: string, sub?: string)

Creates a new Reqor error with an optional sub-message.

Reqor.Headers ​

Headers returned in a Reqor Response.

Constructor ​

ts
new Reqor.Headers(original: globalThis.Headers)

Creates a new Headers instance wrapping the original globalThis.Headers.

Reqor.Status ​

Represents the status of a response.

Constructor ​

ts
new Reqor.Status(status: number, statusText: string)

Creates a new Status instance.

Properties ​

PropertyTypeDescription
statusnumberThe HTTP status code.
textstringThe status text.
okbooleanWhether the status is in the 200-299 range.
redirectedbooleanWhether the response was redirected.
clientErrorbooleanWhether the status is in the 400-499 range.
serverErrorbooleanWhether the status is in the 500-599 range.

Methods ​

.set(status: number, statusText?: string): void ​
ArgumentTypeDescription
statusnumberThe new status code.
statusTextstringOptional new status text.

Sets the status and status text.

.toString(): string ​

Returns the status as a string.

.valueOf(): number ​

Returns the status code as a number.

[Symbol.toPrimitive](hint: string): string | number ​

Returns the status code or string representation based on hint.

Reqor.Type ​

Represents the type of response.

Constructor ​

ts
new Reqor.Type(type: string)

Creates a new Type instance.

Properties ​

PropertyTypeDescription
valuestringThe response type value.

Methods ​

.isBasic(): boolean ​

Returns true if the type is "basic".

.isCors(): boolean ​

Returns true if the type is "cors".

.isError(): boolean ​

Returns true if the type is "error".

.isOpaque(): boolean ​

Returns true if the type is "opaque".

.isOpaqueRedirect(): boolean ​

Returns true if the type is "opaqueredirect".

.toString(): string ​

Returns the type value as string.

.valueOf(): string ​

Returns the type value.

[Symbol.toPrimitive](_hint: string): string ​

Returns the type value.

Reqor.Body ​

Represents the body of a response.

Constructor ​

ts
new Reqor.Body(response: globalThis.Response)

Creates a new Body instance.

Properties ​

PropertyTypeDescription
streamReadableStream<Uint8Array> | nullThe readable stream of the body.
usedbooleanWhether the body has been consumed.

Methods ​

.pump(onChunk: (chunk: Uint8Array) => void): Promise<void> ​
ArgumentTypeDescription
onChunk(chunk: Uint8Array) => voidCallback for each chunk.

Pumps the body stream through the callback.

.pipeTo(dest: WritableStream<Uint8Array>): Promise<void> | undefined ​
ArgumentTypeDescription
destWritableStream<Uint8Array>Destination writable stream.

Pipes the body to the destination.

.pipeThrough<T>(transform: TransformStream<Uint8Array, T>): ReadableStream<T> | undefined ​
ArgumentTypeDescription
transformTransformStream<Uint8Array, T&gt;Transform stream.

Pipes through a transform stream.

.json<T = any>(): Promise<T> ​

Parses the body as JSON.

.text(): Promise<string> ​

Reads the body as text.

.arrayBuffer(): Promise<ArrayBuffer> ​

Reads the body as ArrayBuffer.

.blob(): Promise<Blob> ​

Reads the body as Blob.

.formData(): Promise<FormData> ​

Reads the body as FormData.

Interfaces ​

Reqor.ResponseLater ​

Interface for delayed responses.

Properties ​

  • activated: boolean - Whether the response activated or not.
  • canceled: boolean - Whether the delayed request has been canceled.
  • cancel: () => boolean - Cancels the delayed request before or during activation. Returns true when cancellation was applied.
  • done: Promise<void> - Resolves when delayed request scheduling completes.

Reqor.Response ​

Response returned by reqor.

Properties ​

PropertyTypeDescription
rawglobalThis.ResponseRaw Response returned by fetch().
headersReqor.HeadersA easier way to use Response.headers.
okbooleanWhether the response was successful (status in the range 200-299).
redirectedbooleanWhether the response is the result of a request which was redirected.
statusReqor.StatusStatus of the response.
statusTextstringThe status message corresponding to the HTTP status code.
typeReqor.TypeType of response.
urlstringThe URL of the response.

Functions ​

Reqor.createStatus(status: number, statusText: string): Status ​

ArgumentTypeDescription
statusnumberThe status code.
statusTextstringThe status text.

Creates a new Status instance.

Reqor.createType(type: string): Type ​

ArgumentTypeDescription
typestringThe response type.

Creates a new Type instance.

Namespaces ​

Reqor.Headers.Map ​

Interface for header maps.

Types ​

Reqor.Headers.Map ​
ts
interface Reqor.Headers.Map {
  [key: string]: any;
  [key: symbol]: any;
  new?: (name: string, value?: any) => void \| ((value: any) => void);
}

Creates a new Key-Value in the header.

Functions ​

Reqor.Headers.value(headers: globalThis.Headers, k: string, v?: any): (value?: any) => any | undefined ​
ArgumentTypeDescription
headersglobalThis.HeadersThe headers object.
kstringThe key.
vanyOptional value.

Returns a function to get or set header value.

Reqor.Headers.HTTPHeaders ​

Namespace for HTTP header utilities.

Types ​

ValidityCheck ​
ts
type ValidityCheck = string[] \| ((value?: string) => boolean)

Type for validity checks.

HeaderPrimitive ​
ts
type HeaderPrimitive = string \| number \| boolean

Primitive types for headers.

HeaderMode ​
ts
type HeaderMode = "mime" \| "mime-array" \| "valid-string" \| "valid-string-array" \| "any-string" \| "any-string-array" \| "number" \| "number-array" \| "string-bool" \| "string-bool-array"

Modes for header controllers.

HeaderController ​
ts
type HeaderController = MIME \| MIME_ARRAY \| VALID_STRING \| VALID_STRING_ARRAY \| ANY_STRING \| ANY_STRING_ARRAY \| NUMBER_STRING \| NUMBER_ARRAY \| STRING_BOOL \| STRING_BOOL_ARRAY

Union of header controller types.

Constants ​

contentTypeValidBases ​
ts
readonly ["application", "audio", "font", "example", "image", "message", "model", "multipart", "text", "video", "*"]

Valid content type bases.

Classes ​

MIME ​

Represents a MIME type header.

Constructor ​
ts
new MIME(h: globalThis.Headers, key: string, defaultVal?: string)

Creates a new MIME instance.

Properties ​
PropertyTypeDescription
_valuestringThe MIME value.
_hglobalThis.HeadersThe headers object.
_keystringThe header key.
Methods ​

.set(val: string): void

ArgumentTypeDescription
valstringThe MIME value.

Sets the MIME value.

.base(base: string): this

ArgumentTypeDescription
basestringThe base type.

Sets the base of the MIME type.

.subtype(sub: string): this

ArgumentTypeDescription
substringThe subtype.

Sets the subtype of the MIME type.

.toString(): string

Returns the MIME value as string.

.valueOf(): string

Returns the MIME value.

[Symbol.toPrimitive](hint: string): string | number

Returns the MIME value.

MIME_ARRAY ​

Represents an array of MIME types.

Constructor ​
ts
new MIME_ARRAY(h: globalThis.Headers, key: string, defaultVal?: string)

Creates a new MIME_ARRAY instance.

Properties ​
PropertyTypeDescription
lengthnumberThe length of the array.
arrayMIME[]The array of MIME instances.
Methods ​

.set(val: string | string[] | MIME[]): void

ArgumentTypeDescription
valstring | string[] | MIME[]The values to set.

Sets the MIME array.

.at(index: number): MIME

ArgumentTypeDescription
indexnumberThe index.

Gets the MIME at index.

.toString(): string

Returns the array as string.

.valueOf(): string

Returns the array value.

[Symbol.toPrimitive](hint: string): string | number

Returns the array value.

VALID_STRING ​

Represents a validated string header.

Constructor ​
ts
new VALID_STRING(h: globalThis.Headers, key: string, defaultVal: string \| undefined, validStrings: ValidityCheck)

Creates a new VALID_STRING instance.

Properties ​
PropertyTypeDescription
valuestringThe current value.
validityArrayOrFunctionValidityCheckThe validity check.
keystringThe header key.
Methods ​

.isValid(string: string): boolean

ArgumentTypeDescription
stringstringThe string to check.

Checks if the string is valid.

.set(string: string): void

ArgumentTypeDescription
stringstringThe value to set.

Sets the value if valid.

.toString(): string

Returns the value as string.

.valueOf(): string

Returns the value.

[Symbol.toPrimitive](hint: string): string | number

Returns the value.

ANY_STRING ​

Extends VALID_STRING with no validation.

Constructor ​
ts
new ANY_STRING(h: globalThis.Headers, key: string, defaultVal?: string)

Creates a new ANY_STRING instance.

NUMBER_STRING ​

Extends VALID_STRING for numbers.

Constructor ​
ts
new NUMBER_STRING(h: globalThis.Headers, key: string, defaultVal?: string)

Creates a new NUMBER_STRING instance.

Properties ​
PropertyTypeDescription
numbernumberThe numeric value.
NUMBER_ARRAY ​

Represents an array of numbers.

Constructor ​
ts
new NUMBER_ARRAY(h: globalThis.Headers, key: string, defaultVals?: number[])

Creates a new NUMBER_ARRAY instance.

Properties ​
PropertyTypeDescription
lengthnumberThe length of the array.
arraynumber[]The array of numbers.
Methods ​

.add(value: number): void

ArgumentTypeDescription
valuenumberThe value to add.

Adds a number to the array.

.remove(value: number): void

ArgumentTypeDescription
valuenumberThe value to remove.

Removes a number from the array.

.set(vals: number[]): void

ArgumentTypeDescription
valsnumber[]The values to set.

Sets the array.

.at(index: number): number

ArgumentTypeDescription
indexnumberThe index.

Gets the number at index.

.toString(): string

Returns the array as string.

.valueOf(): string

Returns the array value.

[Symbol.toPrimitive](hint: string): string | number

Returns the array value.

ANY_STRING_ARRAY ​

Represents an array of strings.

Constructor ​
ts
new ANY_STRING_ARRAY(h: globalThis.Headers, key: string, defaultVals?: string[])

Creates a new ANY_STRING_ARRAY instance.

Properties ​
PropertyTypeDescription
lengthnumberThe length of the array.
arraystring[]The array of strings.
Methods ​

.add(str: string): void

ArgumentTypeDescription
strstringThe string to add.

Adds a string to the array.

.remove(str: string): void

ArgumentTypeDescription
strstringThe string to remove.

Removes a string from the array.

.set(vals: string[]): void

ArgumentTypeDescription
valsstring[]The values to set.

Sets the array.

.at(index: number): string

ArgumentTypeDescription
indexnumberThe index.

Gets the string at index.

.toString(): string

Returns the array as string.

.valueOf(): string

Returns the array value.

[Symbol.toPrimitive](hint: string): string | number

Returns the array value.

STRING_BOOL ​

Extends VALID_STRING for boolean strings.

Constructor ​
ts
new STRING_BOOL(h: globalThis.Headers, key: string, defaultVal?: string)

Creates a new STRING_BOOL instance.

VALID_STRING_ARRAY ​

Represents an array of validated strings.

Constructor ​
ts
new VALID_STRING_ARRAY(h: globalThis.Headers, key: string, defaultVals: string[] \| undefined, validStrings: ValidityCheck)

Creates a new VALID_STRING_ARRAY instance.

Properties ​
PropertyTypeDescription
lengthnumberThe length of the array.
arraystring[]The array of strings.
Methods ​

.add(str: string): void

ArgumentTypeDescription
strstringThe string to add.

Adds a string to the array if valid.

.remove(str: string): void

ArgumentTypeDescription
strstringThe string to remove.

Removes a string from the array.

.set(vals: string[]): void

ArgumentTypeDescription
valsstring[]The values to set.

Sets the array if all valid.

.at(index: number): string

ArgumentTypeDescription
indexnumberThe index.

Gets the string at index.

.toString(): string

Returns the array as string.

.valueOf(): string

Returns the array value.

[Symbol.toPrimitive](hint: string): string | number

Returns the array value.

STRING_BOOL_ARRAY ​

Extends VALID_STRING_ARRAY for boolean strings.

Constructor

ts
new STRING_BOOL_ARRAY(h: globalThis.Headers, key: string, defaultVals?: string[])

Creates a new STRING_BOOL_ARRAY instance.

Functions ​

Reqor.Headers.HTTPHeaders.create(h: globalThis.Headers): Record<string, unknown> ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates a record of header controllers.

Reqor.Headers.HTTPHeaders.header(h: globalThis.Headers, name: string): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.
namestringThe header name.

Creates a header controller for the given name.

Reqor.Headers.HTTPHeaders.typed(h: globalThis.Headers, name: string, mode: HeaderMode, defaultValue: HeaderPrimitive | HeaderPrimitive[], validStrings?: ValidityCheck): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.
namestringThe header name.
modeHeaderModeThe header mode.
defaultValueHeaderPrimitive | HeaderPrimitive[]The default value.
validStringsValidityCheckOptional validity check.

Creates a typed header controller.

Reqor.Headers.HTTPHeaders.contentType(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates a content-type header controller.

Reqor.Headers.HTTPHeaders.accept(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates an accept header controller.

Reqor.Headers.HTTPHeaders.acceptEncoding(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates an accept-encoding header controller.

Reqor.Headers.HTTPHeaders.acceptLanguage(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates an accept-language header controller.

Reqor.Headers.HTTPHeaders.acceptPatch(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates an accept-patch header controller.

Reqor.Headers.HTTPHeaders.acceptPost(h: globalThis.Headers): HeaderController & ((v?: any) => HeaderController) ​
ArgumentTypeDescription
hglobalThis.HeadersThe headers object.

Creates an accept-post header controller.

Reqor.Headers.HTTPHeaders.ContentType ​

Sub-namespace for content type utilities.

Constants ​

validBases ​
ts
readonly ["application", "audio", "font", "example", "image", "message", "model", "multipart", "text", "video", "*"]

Valid content type bases.

Types ​

validBases ​
ts
type validBases = (typeof validBases)[number]

Union of valid bases.