clean-tostring

1.0.0 • Public • Published

clean-tostring npmjs.com The MIT License

Clean function toString from code coverage mess. It can't be ideal, but it's useful in testing process.

code climate standard code style travis build status coverage status dependency status

Install

npm i clean-tostring --save

Usage

For more use-cases see the tests

const cleanTostring = require('clean-tostring')

cleanTostring

Clean coverage code of fn.toString(), but be aware of that it remains minified.

Params

  • fn {Function}
  • returns {String}

Example

var cleanup = require('clean-tostring')
var isIstanbul = process.env.running_under_istanbul
 
function fixture (a) {
  if (typeof a === 'string') {
    return a
  }
  return false
}
 
if (isIstanbul) {
  console.log(cleanup(fixture))
  // => 'function fixture(a) {if(typeof a===\'string\'){return a;}else{}return false;}'
} else {
  console.log(cleanup(fixture))
  // => 'function fixture(a) {\n    if (typeof a === \'string\') {\n      return a\n    }\n    return false\n  }'
}

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

/clean-tostring/

    Package Sidebar

    Install

    npm i clean-tostring

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • vanchoy
    • tunnckocore