1.0.3 • Published 7 years ago

formata v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
7 years ago

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.
1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago