Skip to main content
Module

x/written/written.ts

A set of utilities for manipulating text, with a focus on providing typographic tools rather than pure string manipulation.
Latest
import * as written from "https://deno.land/x/written@v0.2.2/written.ts";

Variables

Converts a string to camel case (pascal case)

Capitalize the first letter of a string

Capitalize all words in a string apart from some common lower case words. This can be tested with the internal noncaps regular expression, which are stored by language code, or by passing a regular expression of your own.

Joins an array of words with falsy, non-string values removed with some glue.

Replace all white-space in a string with a single space character

Alias for quantify

Alias for hyphenCase

Alias for hyphenCase

Wraps a string within two other strings, repeating the first if it needs be

Get the code point of a certain character

Provide quick access to different typographic glyphs without the need commit them to memory or look at a reference table.

Converts a string to human case (separated by white space)

Add soft hyphens every n characters so that the CSS attribute hyphens: manual will allow for nice breaks in long strings of text. This is especially useful on mobile devices, where long strings can break the layout.

Converts a string to hyphen case (with hyphens/dashes between words)

Alias for quantify

Convert a number from it's cardinal to ordinal equivalent.

Extract a number from a string (or number)

Pretty-print a list of items.

Pretty print a number

Pretty print a percentage

Add an "s" to a string when an amount is non-singular, disregarding the order of the arguments passsed. If an array or collection is passed, it’s length will be used as the numerical input.

Wrap a string in single or double quotes or guillemets (angle quotes).

Set cardinal and ordinal numbers and non-caps words for different languages as appropriate. Please note that only partial support for French, German, Italian, Spanish and Swedish is currently implemented. PRs are welcome.

Alias for snakeCase

Converts a string to snake case (with underscores)

Alias for capitalizeAll

Alias for snakeCase

Enclose a string inside an HTML tag.

Convert numbers between one and twelve into their written counter-parts.

Interfaces

A language is described in the object. None of the properties are required and will be gracefully replaced by their english counterparts