@kingjs/string-ex.join-lines

1.0.0 • Public • Published

@kingjs/string-ex.join-lines

Join lines in a string with a separator.

Usage

var assert = require('assert');
var os = require('os');
var JoinLines = require('@kingjs/string-ex.join-lines');

var EndOfLine = os.EOL;
var NewLine = '\n';
var CarriageReturn = '\r';

var lines = `foo${NewLine}bar${CarriageReturn}baz${EndOfLine}moo`;

var paragraph = lines[JoinLines]();
assert(paragraph == 'foo bar baz moo');

var fullName = lines[JoinLines]('.');
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-ex.join-lines

Source

https://repository.kingjs.net/string-ex/join-lines

License

MIT

Analytics

Readme

Keywords

none

Package Sidebar

Install

npm i @kingjs/string-ex.join-lines

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.66 kB

Total Files

5

Last publish

Collaborators

  • kingces95