legal-markdown-js
Version:
Node.js implementation of LegalMarkdown for processing legal documents with markdown and YAML - Complete feature parity with Ruby version
198 lines • 7.73 kB
TypeScript
/**
* @fileoverview Extensions Helpers Module - Node.js Enhancements
*
* This module provides advanced helper functions that extend beyond the basic
* functionality of the original Ruby legal-markdown. These are Node.js specific
* enhancements for complex document processing and formatting.
*
* Extended helpers include:
* - Advanced date manipulation and formatting
* - Currency and number formatting utilities
* - String manipulation and text processing
* - Mathematical operations for template expressions
* - Legal document specific formatting functions
*
* For basic Ruby-compatible helpers, see src/core/helpers/
*
* @example
* ```typescript
* import { formatCurrency, addYears, capitalize, multiply } from '../helpers/index.js';
*
* // Advanced functionality not in Ruby legal-markdown
* const price = formatCurrency(1234.56, 'USD');
* const futureDate = addYears(new Date(), 5);
* const title = capitalize('legal document');
* const total = multiply(10, 5);
* ```
*/
export * from './advanced-date-helpers.js';
export * from './number-helpers.js';
export * from './string-helpers.js';
export * from './math-helpers.js';
import { addYears, addMonths, addDays, formatDate } from './advanced-date-helpers.js';
import { formatInteger, formatPercent, formatCurrency, formatEuro, formatDollar, formatPound, numberToWords, round, ordinal, abs, max, min } from './number-helpers.js';
import { capitalize, capitalizeWords, upper, lower, titleCase, kebabCase, snakeCase, camelCase, pascalCase, truncate, clean, pluralize, padStart, padEnd, contains, replaceAll, initials, join, length, defaultVal } from './string-helpers.js';
import { multiply, divide, add, subtract, modulo, power } from './math-helpers.js';
/**
* Registry of extension helper functions for template processing
*
* This object provides all the advanced helper functions that extend
* beyond the Ruby legal-markdown capabilities. It includes the complete
* set of Node.js specific enhancements for document processing.
*
* {Object} extensionHelpers
* @example
* ```typescript
* import { extensionHelpers } from '../helpers/index.js';
*
* // Use advanced helpers in template processing
* const currency = extensionHelpers.formatCurrency(1000, 'EUR');
* const future = extensionHelpers.addYears(new Date(), 3);
* const title = extensionHelpers.titleCase('document title');
* ```
*/
export declare const extensionHelpers: {
addYears: typeof addYears;
addMonths: typeof addMonths;
addDays: typeof addDays;
formatDate: typeof formatDate;
DateFormats: {
readonly LEGAL: "Do day of MMMM, YYYY";
readonly FORMAL: "dddd, MMMM Do, YYYY";
readonly SPANISH: "D de MMMM_ES de YYYY";
readonly US: "MM/DD/YYYY";
readonly EU: "DD/MM/YYYY";
readonly ISO: "YYYY-MM-DD";
readonly LONG: "MMMM D, YYYY";
readonly SHORT: "MMM D, YYYY";
readonly YEAR: "YYYY";
readonly MONTH_YEAR: "MMMM YYYY";
};
formatInteger: typeof formatInteger;
formatPercent: typeof formatPercent;
formatCurrency: typeof formatCurrency;
formatEuro: typeof formatEuro;
formatDollar: typeof formatDollar;
formatPound: typeof formatPound;
numberToWords: typeof numberToWords;
round: typeof round;
ordinal: typeof ordinal;
abs: typeof abs;
max: typeof max;
min: typeof min;
multiply: typeof multiply;
divide: typeof divide;
add: typeof add;
subtract: typeof subtract;
modulo: typeof modulo;
power: typeof power;
capitalize: typeof capitalize;
capitalizeWords: typeof capitalizeWords;
upper: typeof upper;
lower: typeof lower;
titleCase: typeof titleCase;
kebabCase: typeof kebabCase;
snakeCase: typeof snakeCase;
camelCase: typeof camelCase;
pascalCase: typeof pascalCase;
truncate: typeof truncate;
clean: typeof clean;
pluralize: typeof pluralize;
padStart: typeof padStart;
padEnd: typeof padEnd;
contains: typeof contains;
replaceAll: typeof replaceAll;
initials: typeof initials;
join: typeof join;
length: typeof length;
defaultVal: typeof defaultVal;
};
/**
* Combined helpers registry including both core and extension helpers
*
* This provides a unified interface to all helper functions, combining
* the Ruby-compatible core helpers with the Node.js extension helpers.
* Extension helpers take precedence over core helpers when there are conflicts.
*
* {Object} allHelpers
* @example
* ```typescript
* import { allHelpers } from '../helpers/index.js';
*
* // Access any helper function through unified interface
* const today = allHelpers.today(); // from core
* const formatted = allHelpers.formatDate(today, 'MMMM Do, YYYY'); // from extensions
* const currency = allHelpers.formatCurrency(100, 'USD'); // from extensions
* ```
*/
export declare const allHelpers: {
addYears: typeof addYears;
addMonths: typeof addMonths;
addDays: typeof addDays;
formatDate: typeof formatDate;
DateFormats: {
readonly LEGAL: "Do day of MMMM, YYYY";
readonly FORMAL: "dddd, MMMM Do, YYYY";
readonly SPANISH: "D de MMMM_ES de YYYY";
readonly US: "MM/DD/YYYY";
readonly EU: "DD/MM/YYYY";
readonly ISO: "YYYY-MM-DD";
readonly LONG: "MMMM D, YYYY";
readonly SHORT: "MMM D, YYYY";
readonly YEAR: "YYYY";
readonly MONTH_YEAR: "MMMM YYYY";
};
formatInteger: typeof formatInteger;
formatPercent: typeof formatPercent;
formatCurrency: typeof formatCurrency;
formatEuro: typeof formatEuro;
formatDollar: typeof formatDollar;
formatPound: typeof formatPound;
numberToWords: typeof numberToWords;
round: typeof round;
ordinal: typeof ordinal;
abs: typeof abs;
max: typeof max;
min: typeof min;
multiply: typeof multiply;
divide: typeof divide;
add: typeof add;
subtract: typeof subtract;
modulo: typeof modulo;
power: typeof power;
capitalize: typeof capitalize;
capitalizeWords: typeof capitalizeWords;
upper: typeof upper;
lower: typeof lower;
titleCase: typeof titleCase;
kebabCase: typeof kebabCase;
snakeCase: typeof snakeCase;
camelCase: typeof camelCase;
pascalCase: typeof pascalCase;
truncate: typeof truncate;
clean: typeof clean;
pluralize: typeof pluralize;
padStart: typeof padStart;
padEnd: typeof padEnd;
contains: typeof contains;
replaceAll: typeof replaceAll;
initials: typeof initials;
join: typeof join;
length: typeof length;
defaultVal: typeof defaultVal;
};
/**
* Extension helper function names for validation and processing
*
* List of helper function names that are part of the Node.js extension
* functionality. Used for validating template expressions and determining
* which helpers are available in extension processing.
*
* {string[]} EXTENSION_HELPER_NAMES
*/
export declare const EXTENSION_HELPER_NAMES: readonly ["addYears", "addMonths", "addDays", "formatDate", "formatInteger", "formatPercent", "formatCurrency", "formatEuro", "formatDollar", "formatPound", "numberToWords", "round", "ordinal", "abs", "max", "min", "multiply", "divide", "add", "subtract", "modulo", "power", "capitalize", "capitalizeWords", "upper", "lower", "titleCase", "kebabCase", "snakeCase", "camelCase", "pascalCase", "truncate", "clean", "pluralize", "padStart", "padEnd", "contains", "replaceAll", "initials", "join", "length", "defaultVal"];
/**
* Type definition for extension helper function names
*/
export type ExtensionHelperName = (typeof EXTENSION_HELPER_NAMES)[number];
//# sourceMappingURL=index.d.ts.map