Links

@fluentfixture/format

Introduction

A flexible string format library that is a part of the @fluentfixture project. Provides formatting and compiling functionalities with extensible transformation capabilities.

Installation

$ npm install @fluentfixture/format

Usage

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.
The more example can be found on How To Usesection.
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"