1.0.0 • Published 8 years ago

clean-tostring v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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