caoge c760052ff9 机车状态修改 | 8 months ago | |
---|---|---|
.. | ||
node_modules | 8 months ago | |
LICENSE | 8 months ago | |
README.md | 8 months ago | |
index.js | 8 months ago | |
package.json | 8 months ago |
Replace extraneous newlines with a single newline, or pass a specified number of newlines to use.
Install with npm:
$ npm install condense-newlines --save
var condense = require('condense-newlines');
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n'));
//=> '\na\nb\nc\nd\n';
Specify the separator to use
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n', {sep: '\n\n'}));
//=> '\n\na\n\nb\n\nc\n\nd\n\n';
The minimum number of consecutive newlines to condense.
Default
: 2
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n', {min: 2}));
//=> '\n\na\n\nb\n\nc\n\nd\n\n';
Don't treat whitespace-only lines as newlines.
console.log(condense('\n\na\n\n \nb\nc\r\n\r\nd\n\n\n', {
keepWhitespace: true, sep: '\n\n'
}));
//=> '\n\na\n\n \nb\n\nc\n\nd\n\n';
You might also be interested in these projects:
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Install dev dependencies:
$ npm install -d && npm test
Jon Schlinkert
Copyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb, v0.9.0, on April 23, 2016.