# @webther/util

> Util JavaScript Helper Functions.

Latest version **1.0.14** (published 2018-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webther/util
pnpm add @webther/util
yarn add @webther/util
bun add @webther/util
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.14 |
| Published | 2018-08-30 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jay Chen |
| Maintainers | webther |
| Keywords | Util, JavaScript, Helper Functions |

## Links

- npm: https://www.npmjs.com/package/@webther/util
- npm.io page: https://npm.io/package/@webther/util

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.10

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.14 (latest) — 2018-08-30
- 1.0.13 — 2018-08-30
- 1.0.12 — 2018-08-30
- 1.0.11 — 2018-08-30
- 1.0.10 — 2018-08-30
- 1.0.9 — 2018-08-30
- 1.0.8 — 2018-08-30
- 1.0.7 — 2018-08-30
- 1.0.6 — 2018-08-30
- 1.0.5 — 2018-08-28
- 1.0.4 — 2018-08-16
- 1.0.3 — 2018-08-16
- 1.0.2 — 2018-07-22
- 1.0.1 — 2018-07-22
- 1.0.0 — 2018-07-22

## README

# Util JavaScript Functions

#### List of functions

Validator
* isBlank()
* isBoolean()
* usEmail()
* isJson()

Array
* getEleByKeys()

String
* toLowerCase()
* toUpperCase()
* toCamelCase()
* toPascalCase()
* toSlugCase()

#### Setup the node module

Install the node module to your project.
```
$ cd PATH_TO_YOUR_PROJECT
$ npm i @webther/util
```
Load the '@webther/util' module.
```
var util = require("@webther/util");
```
or
```
import util from '@webther/util';
```

#### Validator functions usage

* isBlank()
```
util.isBlank(); // true
util.isBlank(''); // true
util.isBlank(null); // true
util.isBlank(undefined); // true
util.isBlank([]); // true
util.isBlank({}); // true

util.isBlank('0'); // false
util.isBlank('1'); // false
util.isBlank(0); // false
util.isBlank(1); // false
util.isBlank(true); // false
util.isBlank(false); // false

util.isBlank([1, 2, 3]); // false
util.isBlank({name: 'Jay'}); // false
util.isBlank(function() {}); // false
```

* isBoolean()
```
util.isBoolean(); // false
util.isBoolean(''); // false
util.isBoolean(null); // false
util.isBoolean(undefined); // false

util.isBoolean(true); // true
util.isBoolean(false); // true
util.isBoolean('true', true); // true
util.isBoolean('false', true); // true
util.isBoolean('true', false); // false
util.isBoolean('false', false); // false

util.isBoolean(1); // false
util.isBoolean(0); // false
```

* isEmail()
```
util.isEmail(); // false
util.isEmail(''); // false
util.isEmail(null); // false
util.isEmail(undefined); // false

util.isEmail('@gmail.com'); // false
util.isEmail('abc@gmail'); // false
util.isEmail('abc..abc@gmail.com'); // false
util.isEmail('.abc@gmail.com'); // false
util.isEmail('abc.@gmail.com'); // false

util.isEmail('abc@gmail.com'); // true
```

* isJson()
```
util.isJson(); // false
util.isJson(''); // false
util.isJson(null); // false
util.isJson(undefined); // false
util.isJson('[ [ "name": "Jay" ] ]'); // false
util.isJson('{ { "name": "Jay" } }'); // false

util.isJson('""'); // true
util.isJson('[]'); // true
util.isJson('{}'); // true
util.isJson('[{"name": "Jay"}]'); // true
util.isJson('{"name": "Jay"}'); // true
```

#### Array functions usage

* getEleByKeys()
```
var person = {
  name: 'Jay',
  gender: 'Male',
  skills: [
    'JavaScript',
    'Angular',
    'Vuejs'
  ],
  ssn: '111-11-1111'
};
util.getEleByKeys(person, 'name'); // Jay
util.getEleByKeys(person, 'gender'); // Male
util.getEleByKeys(person, 'skills'); // ['JavaScript', 'Angular', 'Vuejs']
util.getEleByKeys(person, 'skills|0'); // JavaScript

util.getEleByKeys(person, 'age'); // ''
util.getEleByKeys(person, 'skills|10'); // ''
```
```
var people = [{
  name: 'Jay',
  gender: 'Male'
}];
for (var i = 0; i < people.length; i++) {
  util.getEleByKeys(people[i], 'name'); // Jay
  util.getEleByKeys(people[i], 'gender'); // Male
}

util.getEleByKeys(people, '0|name'); // Jay
util.getEleByKeys(people, '0|gender'); // Male
```

#### String functions usage

* toLowerCase()
```
util.toLowerCase('Hello World'); // hello world
util.toLowerCase('123'); // 123
util.toLowerCase(123); // 123
util.toLowerCase(0.25); // 0.25
```

* toUpperCase()
```
util.toUpperCase('Hello World'); // HELLO WORLD
util.toUpperCase('123'); // 123
util.toUpperCase(123); // 123
util.toUpperCase(0.25); // 0.25
```

* toCamelCase()
```
util.toCamelCase(''); // ''
util.toCamelCase(null); // ''
util.toCamelCase(undefined); // ''

util.toCamelCase(123); // 123
util.toCamelCase('123 45 6789'); // 123456789
util.toCamelCase('123 abc 6789'); // 123Abc6789
util.toCamelCase('123 45 abc'); // 12345Abc

util.toCamelCase('a'); // a
util.toCamelCase('HELLOWORLD'); // helloworld
util.toCamelCase('HELLOWorld'); // helloWorld
util.toCamelCase('HelloWorld'); // helloWorld
util.toCamelCase('helloWORLD'); // helloWorld

util.toCamelCase('Hello World'); // helloWorld
util.toCamelCase('--Hello--World--'); // helloWorld
util.toCamelCase('__Hello__World__'); // helloWorld
```

* toPascalCase()
```
util.toPascalCase(); // ''
util.toPascalCase(''); // ''
util.toPascalCase(null); // ''
util.toPascalCase(undefined); // ''

util.toPascalCase(123); // 123
util.toPascalCase('123 45 6789'); // 123456789
util.toPascalCase('123 abc 6789'); // 123Abc6789
util.toPascalCase('123 45 abc'); // 12345Abc

util.toPascalCase('a'); // A
util.toPascalCase('HELLOWORLD'); // Helloworld
util.toPascalCase('HELLOWorld'); // HelloWorld
util.toPascalCase('HelloWorld'); // HelloWorld
util.toPascalCase('helloWORLD'); // HelloWorld

util.toPascalCase('Hello World'); // HelloWorld
util.toPascalCase('--Hello--World--'); // HelloWorld
util.toPascalCase('__Hello__World__'); // HelloWorld
```

* toSlugCase()
```
util.toSlugCase('123 45 6789'); // 123456789
util.toSlugCase('Hello World'); // hello-world
util.toSlugCase('--hello--world--'); // hello-world
util.toSlugCase('..hello..world..'); // hello-world
util.toSlugCase('  hello  world  '); // hello-world
util.toSlugCase('helloWorld'); // hello-world
util.toSlugCase('HelloWorld'); // hello-world
```

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