# hlpr

> Javascript helper functions

Latest version **1.0.19** (published 2022-04-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install hlpr
pnpm add hlpr
yarn add hlpr
bun add hlpr
```

## 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.19 |
| Published | 2022-04-09 |
| First published | 2022-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | lept |
| Maintainers | lept |
| Keywords | javascript, helper, functions |

## Links

- npm: https://www.npmjs.com/package/hlpr
- Repository: https://github.com/lept-github/hlpr
- Homepage: https://github.com/lept-github/hlpr#readme
- npm.io page: https://npm.io/package/hlpr

## 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.19 (latest) — 2022-04-09
- 1.0.18 — 2022-04-04
- 1.0.17 — 2022-03-30
- 1.0.16 — 2022-03-22
- 1.0.15 — 2022-03-21
- 1.0.14 — 2022-03-21
- 1.0.13 — 2022-03-21
- 1.0.12 — 2022-03-18
- 1.0.11 — 2022-03-18
- 1.0.10 — 2022-03-18
- 1.0.9 — 2022-03-17
- 1.0.8 — 2022-03-17
- 1.0.7 — 2022-03-12
- 1.0.6 — 2022-03-09
- 1.0.5 — 2022-03-08
- … 5 more at https://npm.io/package/hlpr/versions

## README

HelperJS is a collection of javascript functions and utilities to help developers code faster, bigger and better apps. It does not have dependencies, it is written entirely in vanilla javascript, so it will not install unnecessary packages and libraries increasing your project's bundle size.

## Installation

`npm install hlpr`

or

`yarn add hlpr`

## Import or Require

```
const hlpr = require('hlpr');
console.log(hlpr.isArray([1,2,3])); // true
```

or

```
import { isArray } from 'hlpr';
console.log(isArray([1,2,3])); // true
```

## Validation Functions

### isArray

It determines if the given value is an array.

`isArray(val, strictMode)`

| Parameter  | Description                                                                                       |
|------------|---------------------------------------------------------------------------------------------------|
| val        | Required. The value to be tested.                                                                 |
| strictMode | Optional. Defaults to true. Validation strategy, it determines if an empty array is valid or not. |

### isBinary

It determines if the given value is one of the following: `true|false|0|1`.

`isBinary(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isBoolean

It determines if the given value is boolean.

`isBoolean(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isDate

It determines if the given value is a date.

`isDate(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isDecimal

It determines if the given value is decimal or float.

`isDecimal(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isEmail

It determines if the given value is an email.

`isEmail(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isEmpty

It determines if the given value is an empty/blank string.

`isEmpty(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isEven

It determines if the given value is an even number.

`isEven(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isFalse

It determines if the given value is FALSE.

`isFalse(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isFunction

It determines if the given value is a function.

`isFunction(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isInteger

It determines if the given value is integer.

`isInteger(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isJson

It determines if the given value is a valid JSON.

`isJson(val, strictMode)`

| Parameter        | Description                                                                                             |
|------------------|---------------------------------------------------------------------------------------------------------|
| val              | Required. The value to be tested.                                                                       |
| strictMode       | Optional. Defaults to true. Validation strategy, it determines if an empty JSON object is valid or not. |

### isNull

It determines if the given value is NULL.

`isNull(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isNumber

It determines if the given value is numeric.

`isNumber(val, strictMode)`

| Parameter  | Description                                                                                            |
|------------|--------------------------------------------------------------------------------------------------------|
| val        | Required. The value to be tested.                                                                      |
| strictMode | Optional. Defaults to true. Validation strategy, it determines if numbers as strings are valid or not. |

### isObject

It determines if the given value is an object. It will return false for `Array` and `Date`.

`isObject(val, strictMode)`

| Parameter  | Description                                                                                        |
|------------|----------------------------------------------------------------------------------------------------|
| val        | Required. The value to be tested.                                                                  |
| strictMode | Optional. Defaults to true. Validation strategy, it determines if an empty object is valid or not. |

### isOdd

It determines if the given value is an odd number.

`isOdd(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isSet

It determines if the given value has been set/declare as a string, number, date, array, object, etc.

`isSet(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isSsn

It determines if the given value is a valid format social security number. `000-00-0000`.

`isSsn(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isString

It determines if the given value is a string.

`isString(val, strictMode)`

| Parameter        | Description                                                                                        |
|------------------|----------------------------------------------------------------------------------------------------|
| val              | Required. The value to be tested.                                                                  |
| strictMode       | Optional. Defaults to true. Validation strategy, it determines if an empty string is valid or not. |

### isTrue

It determines if the given value is TRUE.

`isTrue(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isType

It returns the data type of the given value, number, string, array, etc.

`isType(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

### isUndefined

It determines if the given value UNDEFINED.

`isUndefined(val)`

| Parameter | Description                       |
|-----------|-----------------------------------|
| val       | Required. The value to be tested. |

## Other Validation Functions

### isNotArray
### isNotBoolean
### isNotDate
### isNotFunction
### isNotJson
### isNotNull
### isNotNumber
### isNotObject
### isNotSet
### isNotString
### isNotUndefined

## Array Sorting Functions

### ascending

It sorts arrays ascendingly.

- `[1,3,4,2].sort(ascending) // [1,2,3,4]`

- `['c','d','a','b'].sort(ascending) // ['a','b','c','d']`

It also sorts array of objects, but it requires the property name to be sorted by.

`[{p:3}, {p:1}, {p:2}].sort(ascending('p')) // [{p:1}, {p:2}, {p:3}]`

### descending

It sorts arrays descendingly.

- `[1,3,4,2].sort(descending) // [4,3,2,1]`

- `['c','d','a','b'].sort(descending) // ['d','c','b','a']`

It also sorts array of objects, but it requires the property name to be sorted by.

`[{p:3}, {p:1}, {p:2}].sort(ascending('p')) // [{p:3}, {p:2}, {p:1}]`

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