formata

1.0.3 • Public • Published

npm formata package

Jens Hjalmarsson

index or keyword arguments, but not combined.

var format = require('formata');
var indexes = 'The quick {1} {2} jumps over the lazy {3}.';
var keywords = 'The quick {color} {animal} jumps over the lazy {lazyanimal}.';

Arguments

indexes.format(1, 'dog', 'fox');
// or
format(indexes, 1, 'dog', 'fox');

// output:
// The quick 1 dog jumps over the lazy fox.

Array

indexes.format([1, 'fox', 'cat']);
// or
format(indexes, [1, 'fox', 'cat']);

// output:
// The quick 1 fox jumps over the lazy cat.

Keywords

keywords.format({color: 'blue', animal: 'rabbit', lazyanimal: 'fox'});
// or
format(keywords, {color: 'blue', animal: 'rabbit', lazyanimal: 'fox'});

// output:
// The quick blue rabbit jumps over the lazy fox.

Missing arguments

indexes.format('blue', 'rabbit');
// or
keywords.format({color: 'blue', animal: 'rabbit'});

// output:
// The quick blue fox jumps over the lazy {3}.
// The quick blue fox jumps over the lazy {lazyanimal}.

Invalid arguments

indexes.format('colored', {}, ['values', 'inside', 'array']);

// output:
// The quick colored [object Object] jumps over the lazy values,inside,array.

Readme

Keywords

Package Sidebar

Install

npm i formata

Weekly Downloads

1

Version

1.0.3

License

ISC

Last publish

Collaborators

  • jensilaijnen