putil-flattentext
TypeScript icon, indicating that this package has built-in type declarations

2.1.1 • Public • Published

putil-flattentext

NPM Version NPM Downloads Build Status Test Coverage Dependencies DevDependencies

Simple utility that manipulates \t \b \r characters and converts it to space characters, or ignores them and results single line text. Very useful for pretty printing support.

Installation

  • npm install putil-flattentext --save

Usage

flattentext(str, options)

const flattenText = require('./');
let text =
    'aaa\n'+
    '\tbbb\n'+
    '\t\tccc\n'+
    '\bddd\r'+
    'eee';
console.log(flattenText(text, {
  indent: 2, // default
  noWrap: false, // default
}));

Result output

aaa
  bbb
      ccc
    ddd
eee
const flattenText = require('./');
let text =
    'select \n\t(\n\t'+
    'name,\n'+
    'address\n'+
    '\b) from x \r'+
    'where ...';
console.log(flattenText(text, {
  noWrap: true, // default
}));

Result output

select (name, address) from x where ...

Node Compatibility

  • node >= 6.x;

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i putil-flattentext

Weekly Downloads

16

Version

2.1.1

License

MIT

Unpacked Size

6.41 kB

Total Files

5

Last publish

Collaborators

  • erayhanoglu