0.1.0 • Published 6 years ago

function-formatter v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

function-formatter

NPM version NPM downloads Build status Coverage Status Greenkeeper badge semantic-release

Format function to a compact form.

The toString() of function may result in a multiline string.

This library will return a single line instead. If the function is too long, it will be trimmed (default to 120).

import { formatFunction } from 'function-formatter'

// () => 'foo'
formatFunction(() => 'foo')

// function (x, y) { return x + y; }
formatFunction(function (x, y) { return x + y })

// Change result to 80 character long.
// result will have `...` to indicate info missing.
formatFunction(..., { maxLength: 80 })

Contribute

# right after fork
npm install

# begin making changes
git checkout -b <branch>
npm run watch

# edit `webpack.config.dev.js` to exclude dependencies for the global build.

# after making change(s)
git commit -m "<commit message>"
git push

# create PR

Npm Commands

There are a few useful commands you can use during development.

# Run tests (and lint) automatically whenever you save a file.
npm run watch

# Run tests with coverage stats (but won't fail you if coverage does not meet criteria)
npm run test

# Manually verify the project.
# This will be ran during 'npm preversion' so you normally don't need to run this yourself.
npm run verify

# Build the project.
# You normally don't need to do this.
npm run build

# Run tslint
# You normally don't need to do this as `npm run watch` and `npm version` will automatically run lint for you.
npm run lint

Generated by generator-unional@0.0.1

TODO

  • work on browser