# parse-string-boolean

> Parse a string representation of a boolean.

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

## Install

```sh
npm install parse-string-boolean
pnpm add parse-string-boolean
yarn add parse-string-boolean
bun add parse-string-boolean
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-03-02 |
| First published | 2018-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6 |
| Dependencies | 1 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Steven Vachon |
| Maintainers | stevenvachon |
| Keywords | boolean, convert, html, parse, string, type |

## Links

- npm: https://www.npmjs.com/package/parse-string-boolean
- Repository: https://github.com/stevenvachon/parse-string-boolean
- Homepage: https://github.com/stevenvachon/parse-string-boolean#readme
- Issues: https://github.com/stevenvachon/parse-string-boolean/issues
- npm.io page: https://npm.io/package/parse-string-boolean

## Dependencies (1)

- [is-string](https://npm.io/package/is-string.md) ^1.0.4

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2018-03-02
- 1.0.0 — 2018-02-27

## README

# parse-string-boolean [![NPM Version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Monitor][greenkeeper-image]][greenkeeper-url]

> Parse a string representation of a boolean.

* Parses "true" as `true`
* Parses "false" as `false`
* Case-insensitive
* Ignores leading and trailing whitespace
* Returns `null` (customizable) if the string does not represent a boolean
* **Throws an error if input is not a string**


## Installation

[Node.js](http://nodejs.org/) `>= 6` is required. To install, type this at the command line:
```shell
npm install parse-string-boolean
```


## Usage

`parseBoolean(string[, defaultValue])`

```js
const parseBoolean = require('parse-string-boolean');

parseBoolean('true');  //-> true
parseBoolean(' TRUE ');  //-> true
parseBoolean('false');  //-> false

parseBoolean('yes');  //-> null
parseBoolean('1');  //-> null
parseBoolean('');  //-> null
```

Optionally, you can override the default value for strings that do not represent a boolean:
```js
parseBoolean('', true);  //-> true
```


[npm-image]: https://img.shields.io/npm/v/parse-string-boolean.svg
[npm-url]: https://npmjs.com/package/parse-string-boolean
[travis-image]: https://img.shields.io/travis/stevenvachon/parse-string-boolean.svg
[travis-url]: https://travis-ci.org/stevenvachon/parse-string-boolean
[greenkeeper-image]: https://badges.greenkeeper.io/stevenvachon/parse-string-boolean.svg
[greenkeeper-url]: https://greenkeeper.io/

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