@naturalcycles/js-lib
Version:
Standard library for universal (browser + Node.js) javascript
23 lines (22 loc) • 953 B
TypeScript
import type { AnyObject } from '../types.js';
export declare class MissingValueError extends Error {
key: any;
constructor(key: any);
}
export interface PupaOptions {
/**
* By default, Pupa throws a `MissingValueError` when a placeholder resolves to `undefined`. With this option set to `true`, it simply ignores it and leaves the placeholder as is.
*/
ignoreMissing?: boolean;
/**
* Performs arbitrary operation for each interpolation. If the returned value was `undefined`, it behaves differently depending on the `ignoreMissing` option. Otherwise, the returned value will be interpolated into a string (and escaped when double-braced) and embedded into the template.
*/
transform?: (data: {
value: any;
key: string;
}) => unknown;
}
/**
* API: https://github.com/sindresorhus/pupa
*/
export declare function pupa(template: string, data: any[] | AnyObject, opt?: PupaOptions): string;