# @typeforce/is-function

> Determine if a value is a function

Latest version **1.0.1** (published 2018-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @typeforce/is-function
pnpm add @typeforce/is-function
yarn add @typeforce/is-function
bun add @typeforce/is-function
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-02-07 |
| First published | 2018-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | George Thomas |
| Maintainers | mgthomas99 |
| Keywords | assert, function, is |

## Links

- npm: https://www.npmjs.com/package/@typeforce/is-function
- Repository: https://github.com/Typeforce-JS/is-function
- Homepage: https://github.com/Typeforce-JS/is-function#readme
- Issues: https://github.com/Typeforce-JS/is-function/issues
- npm.io page: https://npm.io/package/@typeforce/is-function

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-02-07
- 1.0.0 — 2018-01-24

## README

[license-shield-url]: https://img.shields.io/github/license/typeforce-js/is-function.svg?style=flat-square
[license-url]: https://github.com/Typeforce-JS/is-function/blob/master/LICENSE
[npm-downloads-shield-url]: https://img.shields.io/npm/dt/@typeforce/is-function.svg?style=flat-square
[npm-version-shield-url]: https://img.shields.io/npm/v/@typeforce/is-function.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@typeforce/is-function
[unpkg-shield-url]: https://img.shields.io/badge/unpkg-up--to--date-brightgreen.svg?style=flat-square
[unpkg-url]: https://unpkg.com/@typeforce/is-function/dist/index.min.js

# is-function

[![NPM][npm-version-shield-url]][npm-url]
[![NPM][npm-downloads-shield-url]][npm-url]
[![CDN][unpkg-shield-url]][unpkg-url]
[![LICENSE][license-shield-url]][license-url]

Determine if a value is a function.

A value is a function if it is a literal `function`, or is an instance of type
`Function`.

## Usage

```shell
    npm install @typeforce/is-function --save   # Install package via NPM
```

```javascript
    import { expect } from "chai";
    import isFunction from "@typeforce/is-function";

    expect(isFunction(function () {})).to.be.true;
    expect(isFunction(() => {})).to.be.true;
    expect(isFunction(new Function())).to.be.true;

    expect(isFunction(undefined)).to.be.false;
    expect(isFunction(null)).to.be.false;
    expect(isFunction(42).to.be.false;
```

This package contains TypeScript type declarations. Furthermore, the package
uses TypeScript type guards to allow type inference to influence IntelliSense.

```typescript
    if (isFunction(x)) {
        // IntelliSense now knows `x` is a function.
        let y: Function = x;
    }
```

### Content Delivery Network (CDN)

This package can be imported via [unpkg](https://unpkg.com/#/) as demonstrated
below.

```html
    <script src="https://unpkg.com/@typeforce/is-function/dist/index.min.js"></script>
    <script type="application/javascript">
        if (isFunction(console.log)) {
            // `console.log` is a function!
        }
    </script>
```

## Build & Test

When building the project, a folder named `dist/` will be created if it does not
already exist, where the compiled code will be outputted to. Type declaration
files will also be generated and outputted to the `dist/` folder.

A minified Javascript version of the entire project will be generated and
outputted to `dist/index.min.js`.

```shell
    npm install     # Installs dependencies.
    npm run build   # Build the project.
```

This package uses [Gulp](https://gulpjs.com/) for building, and [Chai](http://chaijs.com/)
and [Mocha](https://mochajs.org/) for testing.

```shell
    npm test       # Run tests.
```

## License

Refer to the `LICENSE` file for license information.

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