# hasbin

> Check whether a binary exists in the PATH environment variable

Latest version **1.2.3** (published 2016-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install hasbin
pnpm add hasbin
yarn add hasbin
bun add hasbin
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2016-05-27 |
| First published | 2015-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/hasbin) |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Nature Publishing Group |
| Maintainers | dotcode, moddular, rowanmanning |
| Keywords | bin, check, path |

## Links

- npm: https://www.npmjs.com/package/hasbin
- Repository: https://github.com/springernature/hasbin
- Issues: https://github.com/springernature/hasbin/issues
- npm.io page: https://npm.io/package/hasbin

## Dependencies (1)

- [async](https://npm.io/package/async.md) ~1.5

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.2.3 (latest) — 2016-05-27
- 1.2.2 — 2016-05-04
- 1.2.1 — 2016-02-09
- 1.2.0 — 2016-01-06
- 1.1.3 — 2015-11-09
- 1.1.2 — 2015-09-09
- 1.1.1 — 2015-09-08
- 1.1.0 — 2015-07-06
- 1.0.0 — 2015-06-23
- 0.2.1 — 2015-05-19
- 0.2.0 — 2015-05-14
- 0.1.0 — 2015-05-14

## README

HasBin
======

Check whether a binary exists in the `PATH` environment variable.

[![NPM version][shield-npm]][info-npm]
[![Node.js version support][shield-node]][info-node]
[![Build status][shield-build]][info-build]
[![Dependencies][shield-dependencies]][info-dependencies]
[![MIT licensed][shield-license]][info-license]

```js
var hasbin = require('hasbin');

// Check if a binary exists
hasbin('node', function (result) {
    // result === true
});
hasbin('wtf', function (result) {
    // result === false
});

// Check if all binaries exist
hasbin.all(['node', 'npm'], function (result) {
    // result === true
});

// Check if at least one binary exists
hasbin.some(['node', 'wtf'], function (result) {
    // result === true
});

// Find the first available binary
hasbin.first(['node', 'npm'], function (result) {
    // result === 'node'
});
```


Table Of Contents
-----------------

- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)


Install
-------

Install HasBin with [npm][npm]:

```sh
npm install hasbin
```


Usage
-----

### `hasbin(binaryName, callback)`

Check whether a binary exists on one of the paths in `process.env.PATH`. Calls back with `true` if it does.

```js
// Arguments
binaryName = String
callback = Function(Boolean)
```

```js
// Example
hasbin('node', function (result) {
    // result === true
});
```

### `hasbin.sync(binaryName)`

Synchronous `hasbin`.

```js
// Arguments
binaryName = String
return Boolean
```

```js
// Example
result = hasbin.sync('node');
```

### `hasbin.all(binaryNames, callback)`

Check whether all of a set of binaries exist on one of the paths in `process.env.PATH`. Calls back with `true` if all of the binaries do. Aliased as `hasbin.every`.

```js
// Arguments
binaryNames = Array(String)
callback = Function(Boolean)
```

```js
// Example
hasbin.all(['node', 'npm'], function (result) {
    // result === true
});
```

### `hasbin.all.sync(binaryNames)`

Synchronous `hasbin.all`. Aliased as `hasbin.every.sync`.

```js
// Arguments
binaryNames = Array(String)
return Boolean
```

```js
// Example
result = hasbin.all.sync(['node', 'npm']);
```

### `hasbin.some(binaryNames, callback)`

Check whether at least one of a set of binaries exists on one of the paths in `process.env.PATH`. Calls back with `true` if at least one of the binaries does. Aliased as `hasbin.any`.

```js
// Arguments
binaryNames = Array(String)
callback = Function(Boolean)
```

```js
// Example
hasbin.some(['node', 'npm'], function (result) {
    // result === true
});
```

### `hasbin.some.sync(binaryNames)`

Synchronous `hasbin.some`. Aliased as `hasbin.any.sync`.

```js
// Arguments
binaryNames = Array(String)
return Boolean
```

```js
// Example
result = hasbin.some.sync(['node', 'npm']);
```

### `hasbin.first(binaryNames, callback)`

Checks the list of `binaryNames` to find the first binary that exists on one of the paths in `process.env.PATH`. Calls back with the name of the first matched binary if one exists and `false` otherwise.

```js
// Arguments
binaryNames = Array(String)
callback = Function(String|false)
```

```js
// Example
hasbin.first(['node', 'npm'], function (result) {
    // result === 'node'
});
```

### `hasbin.first.sync(binaryNames)`

Synchronous `hasbin.first`.

```js
// Arguments
binaryNames = Array(String)
return String|false
```

```js
// Example
result = hasbin.first.sync(['node', 'npm']);
```


Contributing
------------

To contribute to HasBin, clone this repo locally and commit your code on a separate branch.

Please write unit tests for your code, and check that everything works by running the following before opening a pull-request:

```sh
make ci
```


License
-------

HasBin is licensed under the [MIT][info-license] license.  
Copyright &copy; 2015, Springer Nature



[npm]: https://npmjs.org/
[info-coverage]: https://coveralls.io/github/springernature/hasbin
[info-dependencies]: https://gemnasium.com/springernature/hasbin
[info-license]: LICENSE
[info-node]: package.json
[info-npm]: https://www.npmjs.com/package/hasbin
[info-build]: https://travis-ci.org/springernature/hasbin
[shield-coverage]: https://img.shields.io/coveralls/springernature/hasbin.svg
[shield-dependencies]: https://img.shields.io/gemnasium/springernature/hasbin.svg
[shield-license]: https://img.shields.io/badge/license-MIT-blue.svg
[shield-node]: https://img.shields.io/badge/node.js%20support-0.10–6-brightgreen.svg
[shield-npm]: https://img.shields.io/npm/v/hasbin.svg
[shield-build]: https://img.shields.io/travis/springernature/hasbin/master.svg

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