Comment on page
@fluentfixture/format
A flexible string format library that is a part of the @fluentfixture project. Provides formatting and compiling functionalities with extensible transformation capabilities.
$ npm install @fluentfixture/format
The @fluentfixture/format utilities can be used with global
format
and compile
methods or a new Formatter
instance. The following code snippet shows an example usage of global compile
method.import { compile } from '@fluentfixture/format';
const template = compile('${name:capitalCase()}, ${age:default("N/A")} >> ${colors:join("+")}');
template.format({
name: 'john',
age: 32,
colors: ['red', 'black']
});
// "John, 32 >> red+black"
template.format({
name: 'john',
surname: 'doe'
});
// "John, N/A >> "
template.format({
name: 'john',
admin: false,
age: 11,
colors: ['blue']
});
// "John, 11 >> blue"
Last modified 9mo ago