# ternary

> Build a ternary statement

Latest version **1.0.0** (published 2015-07-13) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-07-13 |
| First published | 2015-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | ternary, code, js |

## Links

- npm: https://www.npmjs.com/package/ternary
- Repository: https://github.com/bendrucker/ternary
- Homepage: https://github.com/bendrucker/ternary#readme
- Issues: https://github.com/bendrucker/ternary/issues
- npm.io page: https://npm.io/package/ternary

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-07-13

## README

# ternary [![Build Status](https://travis-ci.org/bendrucker/ternary.svg?branch=master)](https://travis-ci.org/bendrucker/ternary)

> Build a ternary statement


## Install

```
$ npm install --save ternary
```


## Usage

```js
var ternary = require('ternary')

ternary('condition', 'whenTruthy' : 'whenFalsy')
//=> condition ? whenTruthy : whenFalsy
```

## API

#### `ternary(condition, expr1, expr2)` -> `string`

##### condition

*Required*  
Type: `string`

The ternary condition.

##### expr1

*Required*  
Type: `string`

The expression to use when the condition is truthy.

##### expr2

*Required*  
Type: `string`

The expression to use when the condition is falsy.


## License

MIT © [Ben Drucker](http://bendrucker.me)

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