HTTP codes and status utility for Deno. Based on Java Apache HttpStatus
import { status } from "https://deno.land/x/status/mod.ts";
status(403) // => "FORBIDDEN"
status("403") // => "FORBIDDEN"
status.pretty(403) // => "Forbidden"
status(306) // throws
import { status } from "https://deno.land/x/status/mod.ts";
status("forbidden") // => 403
status("FoRbIdDeN") // => 403
status("foo") // throws
Array of all the possible status codes.
import { status } from "https://deno.land/x/status/mod.ts";
status.codes; // => [202, 502, 400, ...]
Map of all the available codes. message (string) -> code (number)
import { status } from "https://deno.land/x/status/mod.ts";
status.code; // => { "ACCEPTED": 202, "BAD_GATEWAY": 502, "BAD_REQUEST": 400, ... }
satuus.code["FORBIDDEN"] = 403;
Map of all the available codes. code (number) -> message (string)
import { status } from "https://deno.land/x/status/mod.ts";
status.message; // => { 202: "ACCEPTED", 502: "BAD_GATEWAY, 400: "BAD_REQUEST", ... }
status.message[403] = "FORBIDDEN";
Returns true
if a status code exprects an empty body.
import { status } from "https://deno.land/x/status/mod.ts";
status.empty[200] // => undefined
status.empty[204] // => true
Returns true
if a status code is a valid redirect status.
import { status } from "https://deno.land/x/status/mod.ts";
status.redirect[200] // => undefined
status.redirect[301] // => true
Returns true
if a status code hints that the request might be retried.
import { status } from "https://deno.land/x/status/mod.ts";
status.retry[501] // => undefined
status.retry[503] // => true
Pull request and issues are very welcome. Code style is formatted with deno fmt
.
The project is inspired by the statuses project.