Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/typical/mod.ts

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
import * as rimbu from "https://deno.land/x/rimbu@0.13.5/typical/mod.ts";

Type Aliases

Returns the sum of given numbers.

Decreases a positive number by 1, or if the number is not positive, returns never.

Returns the result of dividing the first given natural number by the second.

Returns a tuple containing the quotient and remainer of dividing the first number by the second.

Returns true if the given numbers are equal.

Returns true if the first given number is greater than the second.

Returns true if the given first natural number is greater or equal than the second. Returns never otherwise.

Add 1 to the given natural number.

Returns true if the given number is greater than or equal to given L, and less than or equal to given H, and returns false otherwise.

Returns true if the given natural number is even, or never otherwise.

Returns true if the given number is a natural number (>= 0), false otherwise

Returns true if the given number is negative (< 0), false otherwise.

Returns true if the given natural number is odd, or never otherwise.

Returns true if the given number is positive (> 0), false otherwise

Returns true if the first given number is less than the second.

Returns true if the first given number is less than or equal to the second.

Returns the largest of the given 2 natural numbers, of never otherwise

Returns the smallest of the given 2 natural numbers, of never otherwise

Returns the remainder after dividing the first given natural number by the second.

Returns the result of multiplying the given natural numbers.

Returns true if the given numbers are not equal.

Returns the power of the first natural number to the second given natural number.

Returns the result of subtracting N2 from N1.

Convenience type to represent the concatenation of two string types.

Convenience type to represent the concatenation of three string types.

Returns the character in the given string at the given Index, or false if the index is out of bounds.

Returns true if the given string contains the given Amount (default 1) of Sub types.

Returns the amount of times the given Sub type is encountered in the given string.

Returns the given string without the first N characters, or an empty string if the string has less characters.

Returns the given string without the first N characters, or false if the string has less characters.

Skips part of the string as long as its parts match Sub.

If the given string does not end with the given End type, returns false. Otherwise, returns a tuple containing the start and the matched end.

Returns a string containing all the elements that match the given Sub type.

Returns a string containing all the elements that do not match the given Sub type.

Returns the first character of the given string, or false if the string is empty.

Returns all but the last character of the given string, or false if the string is empty.

Returns false if the given string is empty, true otherwise.

Returns the last character of the given string, or false if the string if empty.

Returns the length of the given string S.

Returns never if the given string is empty, otherwise the given string.

Returns true if the given string does not contain the given Amount (default 1) of Sub types.

Returns a tuple containing the matched part and the rest of the given string if the string start repeats the given Sub at least N times.

Returns a tuple containing the matched part and the rest of the given string if the string start repeats the given Sub at most N times.

Returns a tuple containing the matched part and the rest of the given string if the string start repeats the given Sub exactly N times.

Replaces, in the given string, all matches with Sub with the given Repl.

Replaces, in the given string, the first match with Sub with the given Repl. Returns never if there was no match.

Replaces, in the given string, the last match with Sub with the given Repl. Returns never if there was no match.

Returns the given string reversed.

Returns false if the given string does not contain the given Middle type, or a 3-tuple containing the start, the matched middle, and the rest.

If the given string does not start with the given Start type, returns false. Otherwise, returns a tuple containing the matched start and the rest.

Returns all but the first character of the given string, or false if the string is empty.

Returns the first N characters of the given string, or the given string if it does not have enough characters.

Returns the first N characters of the given string, or false if the string does not have enough characters.

Returns part of the string as long as its parts match Sub.

Returns the result of adding the two given string-numbers.

Given two string digits, this type returns a tuple of which the first element is the digit resulting from addition of the two digits, and the second element is a boolean indicating whether there was an overflow.

Builds a tuple of the length of a given string-number. The length can be used to convert a string-number to a number.

All numeric digits as strings

A table from StringDigits to an array that repeats the elements of given array T digit amount of times. 'deca' is used to represent an exponent of 10

Converts a natural number to a string-number, otherwise never.

Type that validates whether a given string-number is even. Checks that the last digit is even.

Returns true if the given string is a valid natural number, false otherwise.

Type that validates whether a given string-number is odd. Checks that the last digit is odd.

Returns true if the given string is a valid positive integer, false otherwise.

Returns the result of multiplying the given string number with the given digit.

Type that will return the incoming type if the value is a valid natural number, or never otherwise.

Positive numeric digits as strings

Type that will return the incoming type if the value is a valid positive integer, or never otherwise.

Given two string digits, returns a tuple of which the first element is the resulting digit from subtracting the second from the first, and the second element a boolean that is true if there is an 'underflow' or borrow, never otherwise.

Returns the result of subtracting the second from the first given string-number, or never if the second value is greater than the first. (Only natural numbers currently supported)

A symmetric tuple, where the order or the elements does not matter. As an example: SymTup<'a', 1> is equal to SymTup<1, 'a'>

Converts the given string-number to its corresponding number.

Infers and returns the length of given Tuple T.

Returns never if the given type is false, otherwise unknown.

If A extends B, returns Then (default true) or else Else (default false)

Returns true if the input type is false, and false if the input type is true.

If A does not extend B, returns Then (default true) or else Else (default false)

Returns false is the given type is false, true otherwise.

Returns never if the given type is false, otherwise true.