Skip to main content
Module

x/dtils/deps.ts

The best unofficial library of utilities for Deno applications
Go to Latest
import * as dtils from "https://deno.land/x/dtils@2.2.0/deps.ts";

Namespaces

A library of assertion functions. If the assertion is false an AssertionError will be thrown which will result in pretty-printed diff of failing assertion.

encode and decode for base64 encoding.

String formatters and utilities for dealing with ANSI color codes.

Utilities for working with OS-specific file paths.

Utilities for working with the Streams API.

Classes

A variable-sized buffer of bytes with read() and write() methods.

A transform stream that only transforms from the zero-indexed start and end bytes (both inclusive).

Divide a stream into chunks delimited by a given byte sequence.

A TransformStream that will only read & enqueue size amount of bytes. This operation is chunk based and not BYOB based, and as such will read more than needed.

A TransformStream that will only read & enqueue size amount of chunks.

Transform a stream into a stream where each chunk is divided by a given delimiter.

Transform a stream into a stream where each chunk is divided by a newline, be it \n or \r\n. \r can be enabled via the allowCR option.

Functions

Make an assertion, error will be thrown if expr does not have truthy value.

Make an assertion that actual and expected are almost equal numbers through a given tolerance. It can be used to take into account IEEE-754 double-precision floating-point representation limitations. If the values are not almost equal then throw.

Make an assertion that actual includes the expected values. If not then an error will be thrown.

Make an assertion that actual and expected are equal, deeply. If not deeply equal, then throw.

Make an assertion that actual is not null or undefined. If not then throw.

Make an assertion that obj is an instance of type. If not then throw.

Make an assertion that error is an Error. If not then an error will be thrown. An error class and a string that should be included in the error message can also be asserted.

Make an assertion that actual match RegExp expected. If not then throw.

Make an assertion that actual and expected are not equal, deeply. If not then throw.

Make an assertion that obj is not an instance of type. If so, then throw.

Make an assertion that actual not match RegExp expected. If match then throw.

Make an assertion that actual and expected are not strictly equal. If the values are strictly equal then throw.

Make an assertion that actual object is a subset of expected object, deeply. If not, then throw.

Executes a function which returns a promise, expecting it to reject.

Make an assertion that actual and expected are strictly equal. If not then throw.

Make an assertion that actual includes expected. If not then throw.

Executes a function, expecting it to throw. If it does not, then it throws.

Deep equality comparison used in assertions

Forcefully throws a failed assertion

Use this to stub out methods that will throw when invoked.

Use this to assert unreachable code.

Decodes a given RFC4648 base64 encoded string

CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation

Set background color to black.

Set background color to blue.

Set background color to bright black.

Set background color to bright blue.

Set background color to bright cyan.

Set background color to bright green.

Set background color to bright magenta.

Set background color to bright red.

Set background color to bright white.

Set background color to bright yellow.

Set background color to cyan.

Set background color to green.

Set background color to magenta.

Set background color to red.

Set background color using 24bit rgb. color can be a number in range 0x000000 to 0xffffff or an Rgb.

Set background color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

Set background color to white.

Set background color to yellow.

Set text color to black.

Set text color to blue.

Make the text bold.

Set text color to bright black.

Set text color to bright blue.

Set text color to bright cyan.

Set text color to bright green.

Set text color to bright magenta.

Set text color to bright red.

Set text color to bright white.

Set text color to bright yellow.

Set text color to cyan.

The text emits only a small amount of light.

Get whether text color change is enabled or disabled.

Set text color to gray.

Set text color to green.

Make the text hidden.

Invert background color and text color.

Make the text italic.

Set text color to magenta.

Set text color to red.

Reset the text modified

Set text color using 24bit rgb. color can be a number in range 0x000000 to 0xffffff or an Rgb.

Set text color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit

Set changing text color to enabled or disabled

Put horizontal line through the center of the text.

Remove ANSI escape codes from the string.

Make the text underline.

Set text color to white.

Set text color to yellow.

Takes Header, Payload and CryptoKey and returns the url-safe encoded jwt.

Takes a jwt and returns a 3-tuple [unknown, unknown, Uint8Array] if the jwt has a valid serialization. Otherwise it throws an Error. This function does not verify the digital signature.

This helper function simplifies setting a NumericDate. It takes either a Date object or a number (in seconds) and returns the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time.

It does not verify the digital signature.

Takes jwt, CryptoKey and VerifyOptions and returns the Payload of the jwt if the jwt is valid. Otherwise it throws an Error.

Determines the common path from a set of paths, using an optional separator, which defaults to the OS default separator.

Convert a glob string to a regular expression.

Test whether the given string is a glob

Like join(), but doesn't collapse "**/.." when globstar is true.

Like normalize(), but doesn't collapse "**/.." when globstar is true.

Copies from src to dst until either EOF (null) is read from src or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.

Merge multiple streams into a single one, taking order into account, and each stream will wait for a chunk to enqueue before the next stream can append another chunk. If a stream ends before other ones, the others will be cancelled.

Turns a Reader, r, into an async iterator.

Turns a ReaderSync, r, into an iterator.

Merge multiple streams into a single one, not taking order into account. If a stream ends before other ones, the other will continue adding data, and the finished one will not add any more data.

Create a ReadableStream from any kind of iterable.

Create a ReadableStream<Uint8Array> from a Reader.

Read Reader r until EOF (null) and resolve to the content as Uint8Array`.

Synchronously reads Reader r until EOF (null) and returns the content as Uint8Array.

Create a Reader from an iterable of Uint8Arrays.

Create a Reader from a ReadableStreamDefaultReader.

Convert the generator function into a TransformStream.

Create a WritableStream from a Writer.

Write all the content of the array buffer (arr) to the writer (w).

Synchronously write all the content of the array buffer (arr) to the writer (w).

Create a Writer from a WritableStreamDefaultWriter.

Merge multiple streams into a single one, taking order into account, and each stream will wait for a chunk to enqueue before the next stream can append another chunk. If a stream ends before other ones, the others will continue adding data in order, and the finished one will not add any more data.

Interfaces

JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a StringOrURI value. This Header Parameter MUST be present and MUST be understood and processed by implementations.

JWT §1: JWTs encode claims to be transmitted as a JSON [RFC7159] object [...]. JWT §4.1: The following Claim Names are registered in the IANA "JSON Web Token Claims" registry established by Section 10.1. None of the claims defined below are intended to be mandatory to use or implement in all cases, but rather they provide a starting point for a set of useful, interoperable claims. Applications using JWTs should define which specific claims they use and when they are required or optional.

A parsed path object generated by path.parse() or consumed by path.format().

Type Aliases

With expLeeway and nbfLeeway implementers may provide for some small leeway to account for clock skew (JWT §4.1.4). The default is 1 second. By passing the option audience, this application tries to identify the recipient with a value in the aud claim. If the values don't match, an Error is thrown.

Disposition of the delimiter.