This package has been deprecated

Author message:

Not useful. use || operator instead

js-candy

1.0.3 • Public • Published

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:

    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:

    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:

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

Importing to your code

    // 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';
 

Package Sidebar

Install

npm i js-candy

Weekly Downloads

1

Version

1.0.3

License

ISC

Last publish

Collaborators

  • joaokrejci