# conditional-elements

> Conditional elements in array and object

Latest version **0.0.1** (published 2018-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install conditional-elements
pnpm add conditional-elements
yarn add conditional-elements
bun add conditional-elements
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2018-10-11 |
| First published | 2018-10-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ali Zhdanov |
| Maintainers | el_mako |

## Links

- npm: https://www.npmjs.com/package/conditional-elements
- Repository: https://github.com/alizhdanov/Conditionals
- Homepage: https://github.com/alizhdanov/Conditionals#readme
- Issues: https://github.com/alizhdanov/Conditionals/issues
- npm.io page: https://npm.io/package/conditional-elements

## Recent versions

- 0.0.1 (latest) — 2018-10-11

## README

# Conditionals

Conditional elements in array and object.

This npm package is filtering out `undefined` and `null` values.

## Example

```js
import conditionals from 'conditionals';

const user = {
  name: 'John',
  surname: null,
  age: undefined,
  friends: [
    {
      name: 'Jimmy',
      surname: null,
    },
  ],
};

conditionals(user);
```

Will be

```javascript
const sanitizedUser = {
  name: 'John',
  friends: [
    {
      name: 'Jimmy',
    },
  ],
};
```

In some cases null can be expected value. You can pass `options.soft` as a second parameter:

```javascript
conditionals(user, { soft: true });

const sanitizedUser = {
  name: 'John',
  surname: null,
  friends: [
    {
      name: 'Jimmy',
      surname: null,
    },
  ],
};
```

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