2.1.1 • Published 1 year ago

putil-flattentext v2.1.1

Weekly downloads
15
License
MIT
Repository
github
Last release
1 year ago

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

2.1.1

1 year ago

2.1.0

4 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago