1.0.1 • Published 5 years ago
@kingjs/string.join-lines v1.0.1
@kingjs/string.join-lines
Join lines in a string with a separator.
Usage
var assert = require('assert');
var os = require('os');
var joinLines = require('@kingjs/string.join-lines');
var EndOfLine = os.EOL;
var NewLine = '\n';
var CarriageReturn = '\r';
var lines = `foo${NewLine}bar${CarriageReturn}baz${EndOfLine}moo`;
var paragraph = joinLines.call(lines);
assert(paragraph == 'foo bar baz moo');
var fullName = joinLines.call(lines, '.');
assert(fullName == 'foo.bar.baz.moo');
API
joinLines(this[, separator])
Parameters
this
: The string of newlines to join.separator
: The separator to join the newlines with.
Returns
Returns the string with newlines replaced with the separator.
Remarks
Adjacent empty lines are replaced with a single separator.
Install
With npm installed, run
$ npm install @kingjs/string.join-lines
Source
https://repository.kingjs.net/string/join-lines
License
MIT