# js-candy

> Some JS syntax-sugar for heavily used expressions

Latest version **1.0.3** (published 2017-12-14) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install js-candy
pnpm add js-candy
yarn add js-candy
bun add js-candy
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-12-14 |
| First published | 2017-07-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | João Krejci |
| Maintainers | joaokrejci |
| Keywords | syntax-sugar, capitalise, if-exists, exists, js-candy, expressions, ternary, ternary-operator-simplifier, simplify |

## Links

- npm: https://www.npmjs.com/package/js-candy
- Repository: https://github.com/joaokrejci/js-candy
- Homepage: https://github.com/joaokrejci/js-candy#readme
- Issues: https://github.com/joaokrejci/js-candy/issues
- npm.io page: https://npm.io/package/js-candy

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.0.3 (latest) — 2017-12-14
- 1.0.2 — 2017-10-09
- 1.0.1-R2 — 2017-08-02
- 1.0.1 — 2017-08-01
- 1.0.0 — 2017-07-21

## README

# js-candy
Some JS syntax-sugar for heavily used expressions

## if-exists
The method checks if the variable has a value, essentialy for you to don't use them without it on critical parts, make a cleaner and readable code or/and don't pass a null parameter were it simply doesn't need to be.
### Variables
Shortcut for:
``` javascript
    variable ? variable : null
```
### Objects
Here's the gold. The method checks if each one of the values exists and returns to you an object with only the values that exists

Usage:

```javascript
    var objectThatIWant = exists(receivedObject);
```

Also, it makes simpler to use the `{...object}` ES syntax without having to worry about "falsey" values.

PS: Boolean 'false' values are kept, as they are, in the object (As they are intended to be there).

## capital-first
Capitalize the first letter of the string.

### The allFirsts parameter
Use the allFirsts parameter if you want to capitalize all the letters after a blank space.

E.g:

``` javascript
    capitalFirst("my string", true); //My String
    capitalFirst("my other string", false); //My other string
    capitalFirst("another string"); //Another string
```


## Importing to your code

``` javascript
    // require module:
    var capitalFirst = require("js-candy/capital-first");
    var exists = require("js-candy/if-exists");
    
    // or with ES6 import
    import capitalFirst from 'js-candy/capital-first';
    import exists from 'js-candy/if-exists';

```

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