applyTextFunction

Applies one text function, such as format or upper, to a plain string.

@internote/canvas-sdkFunction
On this page
import { applyTextFunction } from '@internote/canvas-sdk';

format reads as (comma, percent, scientific or fixed) and places from the attributes; truncate reads length and ellipsis; pad reads length, with and side. A caller that wants to keep markup through a case change maps upper, lower and title over its text runs instead of flattening first.

#Signature

(
    name: TextFunctionName,
    text: string,
    attributes?: Record<string, unknown>,
): string

#Parameters

name
The function.
text
The body's plain text.
attributes
The micronode's attributes, by name.

#Example

applyTextFunction('format', '1234567.891', { as: 'comma', places: 2 }); // '1,234,567.89'

Declared in packages/canvas-sdk/src/content/text-functions.ts:166.

Last updated