npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

hlpr

v1.0.19

Published

Javascript helper functions

Downloads

4

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}]