1.0.5 • Published 1 year ago

@fluentfixture/format v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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 Use section.

import { format } from '@fluentfixture/format';

const source = {
  name: 'john',
  surname: 'doe',
  birthdate: new Date(1_617_258_460_000), // GMT: Thursday, 1 April 2021 06:27:40
};

// format() returns a formatted string immediately.
console.log(
  format('${surname:upperCase()}, ${name:capitalCase()} BIRTH_DATE=${birthdate:date("MM-DD-YYYY")}', source),
);

// compile() returns a pre-compiled template for reusing.
const template = compile('${name:capitalCase()}, ${age:default("N/A")} >> ${colors:join("+")}');

console.log(
  template.format({
    name: 'john',
    age: 32,
    colors: ['red', 'black']
  })
);

Documentation

To check out the guide, visit https://docs.fluentfixture.com/

License

@fluentfixture is MIT licensed.

1.0.5

1 year ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.3

2 years ago

0.0.0-rc.10

2 years ago

0.0.0-rc.9

2 years ago

0.0.0-rc.8

2 years ago

0.0.0-rc.7

2 years ago

0.0.0-rc.6

2 years ago

0.0.0-rc.5

2 years ago

0.0.0-rc.4

2 years ago

0.0.0-rc.3

2 years ago

0.0.0-rc.2

2 years ago