Skip to main content
Module

x/eitherway/dev_deps.ts

Yet Another Option and Result Implementation - providing safe abstractions for fallible flows inspired by F# and Rust
Latest
import * as eitherway from "https://deno.land/x/eitherway@0.10.0/dev_deps.ts";

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.

This module is browser compatible, but do not rely on good formatting of values for AssertionError messages in browsers.

Namespaces

The semantic version parser.

Variables

A comparator which will span all valid semantic versions

ANY is a sentinel value used by some range calculations. It is not a valid SemVer object and should not be used directly.

A sentinel value used to denote an invalid SemVer object which may be the result of impossible ranges or comparator operations.

MAX is a sentinel value used by some range calculations. It is equivalent to ∞.∞.∞.

The minimum valid SemVer object. Equivalent to 0.0.0.

A comparator which will not span any semantic versions

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, error will be thrown if expr have truthy value.

Make an assertion that actual is greater than expected. If not then throw.

Make an assertion that actual is greater than or equal to expected. 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 is less than expected. If not then throw.

Make an assertion that actual is less than or equal to expected. If not then throw.

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.

Asserts at compile time that the provided type argument's type resolves to the expected boolean literal type.

Builds the specified Deno module to an npm package using the TypeScript compiler.

Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted. Requires the --allow-read and --allow-write flag.

Deep equality comparison used in assertions

Forcefully throws a failed assertion

Do a comparison of two semantic version objects based on the given operator

Formats the comparator into a string

Returns true if the range of possible versions intersects with the other comparators set of possible versions

The maximum version that could match this comparator.

The minimum semantic version that could match this comparator

Compare two semantic version objects.

Compare two semantic version objects including build metadata.

Returns difference between two versions by the release type, or undefined if the versions are the same.

Returns true if they're logically equivalent, even if they're not the exact same version object.

Format a SemVer object into a string.

Greater than comparison

Greater than or equal to comparison

Checks to see if the version is greater than all possible versions of the range.

Returns the new version resulting from an increment by release type.

Checks to see if value is a valid SemVer object. It does a check into each field including prerelease and build.

Does a deep check on the value to see if it is a valid SemVerComparator object.

Does a deep check on the object to determine if its a valid range.

Less than comparison

Less than or equal to comparison

Greater than range comparison

Returns the highest version in the list that satisfies the range, or undefined if none of them do.

Returns the lowest version in the list that satisfies the range, or undefined if none of them do.

Not equal comparison

Returns true if the version is outside the bounds of the range in either the high or low direction. The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)

Attempt to parse a string as a semantic version, returning either a SemVer object or throws a TypeError.

Parses a comparator string into a valid SemVerComparator.

Parses a range string into a SemVerRange object or throws a TypeError.

Formats the range into a string

The ranges intersect every range of AND comparators intersects with a least one range of OR ranges.

The maximum valid SemVer for a given range or INVALID

The minimum valid SemVer for a given range or INVALID

A reverse comparison of two versions. Same as compare but 1 and -1 are inverted.

Sorts a list of semantic versions in descending order.

Sorts a list of semantic versions in ascending order.

Test to see if a semantic version falls within the range of the comparator.

Test to see if the version satisfies the range.

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

Use this to assert unreachable code.

Interfaces

A SemVer object parsed into its constituent parts.

The shape of a valid semantic version comparator

A type representing a semantic version range. The ranges consist of a nested array, which represents a set of OR comparisons while the inner array represents AND comparisons.

Type Aliases

Asserts at compile time that the provided type argument's type resolves to the expected boolean literal type.

Asserts at compile time that the provided type argument's type resolves to false.

Asserts at compile time that the provided type argument's type resolves to true.

Checks if type T has the specified type U.

Checks if type T is the any type.

Checks if type T exactly matches type U.

Checks if type T is the never type.

Checks if type T is possibly null or undefined.

Checks if type T is the unknown type.

Checks if type T does not have the specified type U.

The style to use when formatting a SemVer object into a string

SemVer comparison operators.

The possible release types are used as an operator for the increment function and as a result of the difference function.