# is-it-set

> A one-liner to check if a property is set (not null, undefined or empty string).

Latest version **1.0.3** (published 2016-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-it-set
pnpm add is-it-set
yarn add is-it-set
bun add is-it-set
```

## 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.3 |
| Published | 2016-06-12 |
| First published | 2015-09-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bryce Hanscomb |
| Maintainers | brycehanscomb |
| Keywords | is, set, is_set, isset, is, it, set, is-it-set |

## Links

- npm: https://www.npmjs.com/package/is-it-set
- Repository: https://brycehanscomb@github.com/brycehanscomb/is-it-set
- Homepage: https://github.com/brycehanscomb/is-it-set#readme
- Issues: https://github.com/brycehanscomb/is-it-set/issues
- npm.io page: https://npm.io/package/is-it-set

## Dependencies (1)

- [is-not-set](https://npm.io/package/is-not-set.md) ^1.0.0

## 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.3 (latest) — 2016-06-12
- 1.0.2 — 2016-06-12
- 1.0.1 — 2016-06-12
- 1.0.0 — 2015-09-08

## README

# Is It Set

[![Build Status](https://travis-ci.org/brycehanscomb/is-it-set.svg?branch=master)](https://travis-ci.org/brycehanscomb/is-it-set)

A one-liner to check if a property is set (not `null`, `undefined` or an empty 
string).

## Installation

Run the following command to make this package available in your project:

```
npm install is-it-set --save
```

## Usage

Import this package into your script like this:

```js
const isSet = require('is-it-set');
```

Now you can run `isSet` on any input:

```js
/*
 * Empty strings, `null` and `undefined` all return `false`
 */
isSet('')        // => false
isSet(null)      // => false
isSet(undefined) // => false

/*
 * Any other input returns `true`
 */
isSet(0)         // => true
isSet(-1)        // => true
isSet(' ')       // => true
isSet(false)     // => true
isSet('Hello')   // => true
isSet(Infinity)  // => true
isSet(Date)      // => true
```

## Why does this package exist?

JavaScript [has some opinions](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) 
on what should be considered falsy, and that's great for developer convenience
when dealing with variable data. 

However, sometimes the only values that should not pass a test (like an `if()`) 
should be data types that purposefully mean "no data" -- `null`, `undefined` and
the empty string (`''`). Empty strings are often used as a no-data indicator in
JSON documents.

### A Simple Example

```js
function squareNumber(input) {
  /**
   * A simple check to make sure there's data to work with
   */
  if (isSet(input)) {
    return input * input;	  
  } else {
    throw new ReferenceError('No input given');
  }
}
```

## Versioning

This repo follows SemVer

## Tests

To run the tests for this package, clone the repo and run the following in your
terminal:

```
npm install
npm test
```

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