clean-tostring
Clean function
toString
from code coverage mess. It can't be ideal, but it's useful in testing process.
Install
npm i clean-tostring --save
Usage
For more use-cases see the tests
const cleanTostring =
cleanTostring
Clean coverage code of
fn.toString()
, but be aware of that it remains minified.
Params
fn
{Function}returns
{String}
Example
var cleanup = var isIstanbul = processenvrunning_under_istanbul { if typeof a === 'string' return a return false} if isIstanbul console // => 'function fixture(a) {if(typeof a===\'string\'){return a;}else{}return false;}' else console // => 'function fixture(a) {\n if (typeof a === \'string\') {\n return a\n }\n return false\n }'
Related
- bind-context: Bind context to a function and preserves her name. Can be used… more | homepage
- function-arguments: Get arguments of a function, useful for and used in dependency injectors.… more | homepage
- get-fn-name: Get function name with strictness and correctness in mind. Also works for… more | homepage
- is-bound-function: Check if given function is bound or not. | homepage
- parse-function: Parse a function, arrow function or string to object with name, args,… more | homepage
- rename-function: Rename a given function. Tries to be cross-platform and guaranteed. Useful when… more | homepage
- smart-bind: Smarter binding of function with some context. It uses .apply instead of… more | homepage
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.