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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nn-validate

v1.2.5

Published

Validation functions.

Downloads

2

Readme

nn-validate

Common validation functions.

Usage

import { getType } from 'nn-validate';
import { isDef } from 'nn-validate';
import { isVoid } from 'nn-validate';
import { isUndefined } from 'nn-validate';
import { isNull } from 'nn-validate';
import { isBoolean } from 'nn-validate';
import { isInteger } from 'nn-validate';
import { isNumber } from 'nn-validate';
import { isInfinity } from 'nn-validate';
import { isString } from 'nn-validate';
import { isPrimitive } from 'nn-validate';
import { isArray } from 'nn-validate';
import { isObject } from 'nn-validate';
import { isObjectExArray } from 'nn-validate';
import { isDate } from 'nn-validate';
import { isDateValid } from 'nn-validate';
import { isFunction } from 'nn-validate';
import { isSymbol } from 'nn-validate';
import { isEmpty } from 'nn-validate';
import { isArrayEmpty } from 'nn-validate';
import { isObjectEmpty } from 'nn-validate';
import { isPrimitive } from 'nn-validate';
import { isPromiseLike } from 'nn-validate';

const value = 'Some value';

// Get value type.
getType( value ) // Returns "[object String]"

// Checks if value is not undefined or null.
isDef( value ) // Returns true

// Checks if value is undefined or null.
isVoid( value ) // Returns false, same as !isDef( value )

// Checks if value is undefined.
isUndefined( value ) // Returns false

// Checks if value is null.
isNull( value ) // Returns false

// Checks if value is a boolean.
isBoolean( value ) // Returns false

// Checks if value is an integer.
isInteger( value ) // Returns false

// Checks if value is an number.
isNumber( value ) // Returns false

// Checks if value is infinity or -infinity.
isInfinity( value ) // Returns false

// Checks if value is a string.
isString( value ) // Returns true

// Checks if value is an array.
isArray( value ) // Returns false

// Checks if value is an object.
isObject( value ) // Returns false

// Checks if value is an object but not an array.
isObjectExArray( [] ) // Returns false
isObjectExArray( {} ) // Returns true

// Checks if value is date.
isDate( 0 ) // Returns false
isDate( new Date( 1970, 0, 1, 0, 0, 0, 0 ) ) // Returns true

// Checks if value is valid date.
isDateValid( new Date( 'Abc' ) ) // Returns false
isDateValid( new Date( 1970, 0, 1, 0, 0, 0, 0 ) ) // Returns true

// Checks if value is function.
isFunction( value ) // Returns false

// Checks if value is a symbol.
isSymbol( Symbol() ) // Returns true

// Checks if value is empty. A value is considered empty if it is: undefined, null, empty string,
// empty array, object without any keys (e.g. {}).
isEmpty( value ) // Returns false

// Checks if value is an empty array.
isArrayEmpty( value ) // Returns false

// Checks if value is an empty object (i.e. object without any keys).
isObjectEmpty( value ) // Returns false

// Checks if value is undefined, null, boolean, number, infinity, string, or symbol.
isPrimitive( value ) // Returns true

// Checks if value is like a promise (i.e. must have 'then' and 'catch' functions).
isPromiseLike( new Promise( ( resolve, reject ) => resolve() ) ) // Returns true