string-true-oneline
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

string-true-oneline

Build Status Coverage Status

This module is written on typescript, and contains the .d.ts file.
If you write on typescript: just use it in your project and definitions will be automatically uploaded.

npm i -S string-true-oneline

About

This module transforms a string to a oneline string considering escape sequences.

Warning!

This module does not supported an ANSI escape codes. And simply removes them before forming line.

const so = require('string-true-oneline')
const inspect = require('util').inspect
const assert = require('assert')
const chalk = require('chalk')
 
const actColor = so(chalk.blue('\nhello') + ' ' + chalk.blue('world!\n'))
const actClear = so('\nhello world!\n')
const exp = 'hello world!'
assert.equal(actColor, exp)
assert.equal(actClear, exp)

Examples

const so = require('string-true-oneline')
const inspect = require('util').inspect
const assert = require('assert')
 
var act = so('   \n   hello   world!   \n   ')
var exp = 'hello world!'
assert.equal(act, exp)
 
var act = so('h\ve\vl\rl\f\b\nw\no\r\v\r\vr\v\rl\nd !')
var exp = 'h e l l o w o r l d !'
assert.equal(act, exp)

Related

Package Sidebar

Install

npm i string-true-oneline

Weekly Downloads

8

Version

1.0.0

License

MIT

Last publish

Collaborators

  • nskazki