Skip to content

Strings ​

stringConversion
string(value: unknown): string

Converts any value to its string representation (JSON for objects and arrays).

lengthInspect
length(value: string): number

Number of characters in the string.

containsInspect
contains(value: string, substring: string): boolean

True if the string contains the given substring.

matchesInspect
matches(value: string, pattern: string): boolean

True if the string matches the regular expression `pattern`.

upperCase & whitespace
upper(value: string): string

Uppercases the string.

lowerCase & whitespace
lower(value: string): string

Lowercases the string.

trimCase & whitespace
trim(value: string): string

Removes leading and trailing whitespace.

padCase & whitespace
pad(value: string, width: number, char?: string): string

Pads to `width` with `char` (default space); a negative width pads on the left.

substringTransform
substring(value: string, start: number, length?: number): string

Extracts `length` characters from `start`; a negative start counts from the end.

splitTransform
split(value: string, separator: string, limit?: number): string[]

Splits on a separator, optionally keeping only the first `limit` parts.

replaceTransform
replace(value: string, pattern: string, replacement: string): string

Replaces every occurrence of `pattern` with `replacement`.

base64encodeEncoding
base64encode(value: string): string

Encodes the string to Base64 (UTF-8 safe).

base64decodeEncoding
base64decode(value: string): string

Decodes a Base64 string (UTF-8 safe).

encodeUrlEncoding
encodeUrl(value: string): string

Encodes a full URL (`encodeURI`).

decodeUrlEncoding
decodeUrl(value: string): string

Decodes a full URL (`decodeURI`).

encodeUrlComponentEncoding
encodeUrlComponent(value: string): string

Encodes a URL component (`encodeURIComponent`).

decodeUrlComponentEncoding
decodeUrlComponent(value: string): string

Decodes a URL component (`decodeURIComponent`).

Conversion ​

string ​

string(value: unknown): string

Converts any value to its string representation (JSON for objects and arrays).

typeflow
label: "Order #" + string(order.id)

Inspect ​

length ​

length(value: string): number

Number of characters in the string.

typeflow
nameLength: length(user.name)

contains ​

contains(value: string, substring: string): boolean

True if the string contains the given substring.

typeflow
isWorkEmail: contains(user.email, "@work.")

matches ​

matches(value: string, pattern: string): boolean

True if the string matches the regular expression pattern.

typeflow
isZip: matches(user.zip, "^[0-9]{5}$")

Case & whitespace ​

upper ​

upper(value: string): string

Uppercases the string.

typeflow
shout: upper(user.name)

lower ​

lower(value: string): string

Lowercases the string.

typeflow
handle: lower(user.username)

trim ​

trim(value: string): string

Removes leading and trailing whitespace.

typeflow
clean: trim(user.rawName)

pad ​

pad(value: string, width: number, char?: string): string

Pads to width with char (default space); a negative width pads on the left.

typeflow
padded: pad(user.ref, -8, "0")

Transform ​

substring ​

substring(value: string, start: number, length?: number): string

Extracts length characters from start; a negative start counts from the end.

typeflow
initials: substring(user.name, 0, 1)

split ​

split(value: string, separator: string, limit?: number): string[]

Splits on a separator, optionally keeping only the first limit parts.

typeflow
domain: split(user.email, "@")[1]

replace ​

replace(value: string, pattern: string, replacement: string): string

Replaces every occurrence of pattern with replacement.

typeflow
masked: replace(user.email, "a", "*")

Encoding ​

base64encode ​

base64encode(value: string): string

Encodes the string to Base64 (UTF-8 safe).

typeflow
token: base64encode(user.id + ":" + user.secret)

base64decode ​

base64decode(value: string): string

Decodes a Base64 string (UTF-8 safe).

typeflow
decoded: base64decode(request.token)

encodeUrl ​

encodeUrl(value: string): string

Encodes a full URL (encodeURI).

typeflow
link: encodeUrl(page.canonicalUrl)

decodeUrl ​

decodeUrl(value: string): string

Decodes a full URL (decodeURI).

typeflow
link: decodeUrl(request.rawUrl)

encodeUrlComponent ​

encodeUrlComponent(value: string): string

Encodes a URL component (encodeURIComponent).

typeflow
query: encodeUrlComponent(search.term)

decodeUrlComponent ​

decodeUrlComponent(value: string): string

Decodes a URL component (decodeURIComponent).

typeflow
term: decodeUrlComponent(request.query)

Playground ​

Mapping✔Playground ↗
Input JSON
Output
{
  "local": "ada",
  "domain": "work.dev",
  "padded": "00000042",
  "isWorkEmail": true,
  "masked": "*d*@work.dev",
  "shout": "ADA"
}
inferred type{ local: string; domain: string; padded: string; isWorkEmail: boolean; masked: string; shout: string; }

Released under the MIT License.