fluentfixture
ContributionCode of Conduct
  • Fluent Fixture
  • PACKAGES
    • @fluentfixture/core
      • Everything Is A Factory
      • Streams
        • Stream
        • Boolean Stream
        • Number Stream
        • String Stream
        • Date Stream
        • Array Stream
        • Object Stream
      • Generators
      • Live Demo
    • @fluentfixture/format
      • Structure
      • Pipe Functions
        • Built-In Pipes
        • Custom Pipes
      • How To Use
      • Error Handling
      • Live Demo
  • 🫂Contribution
  • 🐦Follow me on Twitter :)
Powered by GitBook
On this page
  • Introduction
  • Installation
  • Usage
Edit on GitHub
  1. PACKAGES

@fluentfixture/format

PreviousGeneratorsNextStructure

Last updated 7 months ago

Introduction

The @fluentfixture/format is a flexible string format library that provides formatting functionality with an extensible transformation capabilities.

Installation

$ npm install @fluentfixture/format

Usage

The 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"
@fluentfixture/format