af-custom-functions
v1.0.2
Published
Provides a collection of custom functions designed to aid creation of adaptive form
Maintainers
Readme
af-custom-functions
Provides a collection of custom functions designed to aid creation of adaptive forms in AEM.
Installation
npm install af-custom-functionsUsage
// ESM
import { characterCount, formatNumber } from 'af-custom-functions';
\
// Usage
const count = characterCount('hello world'); // 11
const formatted = formatNumber(3.14159, 2); // '3.14'Functions
characterCount(str)
Returns the number of characters in the given string.
| Parameter | Type | Description |
|-----------|------|-------------|
| str | string | The input string |
Returns: number
formatNumber(value, decimals)
Formats a number to a fixed number of decimal places.
| Parameter | Type | Description |
|-----------|------|-------------|
| value | number | The number to format |
| decimals | number | Number of decimal places (defaults to 0) |
Returns: string
