# function-formatter

> Format function to a compact form

Latest version **0.1.0** (published 2017-11-24) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install function-formatter
pnpm add function-formatter
yarn add function-formatter
bun add function-formatter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-11-24 |
| First published | 2017-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Homa Wong |
| Maintainers | unional |

## Links

- npm: https://www.npmjs.com/package/function-formatter
- Repository: https://github.com/unional/function-formatter
- Issues: https://github.com/unional/function-formatter/issues
- npm.io page: https://npm.io/package/function-formatter

## Recent versions

- 0.1.0 (latest) — 2017-11-24

## README

# function-formatter

[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/unional/function-formatter.svg)](https://greenkeeper.io/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/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).

```ts
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

```sh
# 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.

```sh
# 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

[npm-image]: https://img.shields.io/npm/v/function-formatter.svg?style=flat
[npm-url]: https://npmjs.org/package/function-formatter
[downloads-image]: https://img.shields.io/npm/dm/function-formatter.svg?style=flat
[downloads-url]: https://npmjs.org/package/function-formatter
[travis-image]: https://img.shields.io/travis/unional/function-formatter/master.svg?style=flat
[travis-url]: https://travis-ci.org/unional/function-formatter?branch=master
[coveralls-image]: https://coveralls.io/repos/github/unional/function-formatter/badge.svg
[coveralls-url]: https://coveralls.io/github/unional/function-formatter

---
_Source: https://npm.io/package/function-formatter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
