0.0.5 • Published 4 years ago

concatenater v0.0.5

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

concatenater Build Status

Usage

const concatenater = require('concatenater');

append

concatenater('foo')
	.append('-bar')
	.toString();
//=> foo-bar

concatenater('foo')
	.append('-bar', '-one', '-two')
	.toString();
//=> foo-bar-one-two

concatenater('foo')
	.append('-bar', null, '-two', '-three') // null ignored
	.toString();
//=> foo-bar-two-three

concatenater('foo')
	.append('-bar', undefined, '-two', '-three') // undefiend ignored
	.toString();
//=> foo-bar-two-three

concatenater('foo')
	.append('-bar', false, '-two', '-three') // false ignored and breaks
	.toString();
//=> foo-bar

concatenater('foo')
	.append('-bar', true, '-two', '-three') // true ignored and continue
	.toString();
//=> foo-bar

prepend

concatenater('bar')
	.prepend('foo,')
	.toString();
//=> foo,bar

surround

concatenater('foo,bar')
	.surround('{{', '}}')
	.toString();
//=> {{foor,bar}}

frame

concatenater('foo,bar')
	.frame('((...))')
	.toString();
//=> ((foor,bar))

set

concatenater()
	.set('foo')
	.toString();
//=> foo

replace

concatenater('foo, bar')
	.replace('bar', '--') // 2 inputs
	.toString();
//=> foo, --

concatenater('foo, bar, one, anyKey')
	.replace({ // 1 input
		bar: '----',
		one: 1,
		anyKey: 'anyValue'
	})
	.toString();
//=> foo, ----, 1, anyValue

source

concatenater()
	.source({
		one: 1,
		two: 2
	})
	.set('foo, {one}, {two}')
	.toString();
//=> foo, 1, 2

appendFormat

concatenater()
	.appendFormat('Hello [0] [1] [0]', 'foo', 'bar')
	.toString()
//=> 'Hello foo bar foo'

n

test('newline', t => {
		concatenater()
		.append('Hello')
		.n()
		.append('foo')
		.n(2)
		.append('bar')
		.toString()
		// =>
`Hello
foo

bar`
0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

2.0.0

4 years ago