Skip to main content
Module

x/fun/string.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
import * as fun from "https://deno.land/x/fun@v2.0.0/string.ts";

This file contains the String algebraic data type. String is a the built in javascript string structure. This file contains data last implementations of most of the String built in methods as well as minor "fixes" to make them less error prone.

Variables

The canonical implementation of Comparable for string. It contains the method equals.

The canonical implementation of Initializable for string. It contains the method init and combine.

The canonical implementation of Showable for string. It contains the method show.

The canonical implementation of Sortable for string. It contains the methods lt, lte, equals, gte, gt, min, max, clamp, between, and compare.

Functions

Combine two strings.

Compare two strings for equality.

Creates a Predicate over string that returns true when the string ends with the supplied searchString starting at position, if it is supplied.

Creates a Predicate over string that returns true when a string includes the searchString at or beyond the optional starting position.

Returns an init string.

A Predicate for string returning true if the string is init.

A instance of Refinement<unknown, string>. Used as a type guard to verify any type is actually a string.

Returns the length of an input string.

Create a function that returns an Option. This is a curried form of RegExp.match.

A simple curried pluralizing function. Takes the singular and plural forms of a word and returns a function that takes a count and returns the correct word for the count.

Create a function that replaces all values in a string according to a RegExp and a replacement value.

Create a substring of a string based on 0 based indices.

Compare two strings and return an Ordering (-1, 0, or 1);

Split a string into an array of strings at a character or RegExp match.

Creates a Predicate over string that returns true when the string starts with the supplied searchString starting at position, if it is supplied.

Create a Predicate that returns true when it matches the supplied RegExp. Warning, this function technically mutates RegExp, but paradoxically it does so to keep state the same. If the passed RegExp.test method is called outside of this function then mayhem will surely ensue.

A pipeable form of String.toLowerCase.

A pipeable form of String.toUpperCase.

Trims whitespace from the beginning and end of a string.

Trims whitespace from the end of a string.

Trims whitespace from the beginning of a string.