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

confirm-data

v1.0.0

Published

This package is for confirming data that will take arguments to verify its value and type.

Downloads

16

Readme

confirm data

A collection of useful utilities for conditioning.

Install with npm like this ↓

$ npm install confirm-data

Usage

Only get a specific collection

const { keyword /** example: isEqual, isNull, ... */ } = require('confirm-data');

Also you can use it within typescript, like this ↓

import { keyword /** example: isEqual, isNull, ... */ } from 'confirm-data';

Keyword means the function provided by confirm-data packages.

API

isEqual

Make sure whether value 1 and value 2 are equal.

Params

  • any {any}: validation
  • any {any}: validation
  • returns {Boolean}: true if value 1 and value 2 are equal, else false.

Example

isEqual('test', 'test')
//=> true
isEqual(1, 1)
//=> true

isNull

Make sure whether value is null.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is null, else false.

Example

isNull(null)
//=> true

isUndefined

Make sure whether type of value is undefined.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is null, else false.

Example

isUndefined(undefined)
//=> true

isNotExist

Make sure whether value is null or undefined, therefore "not exist".

Params

  • any {any}: validation
  • returns {Boolean}: true if value is null or undefined, else false.

Example

isNotExist(null)
//=> true
isNotExist(undefined)
//=> true

isExist

Make sure whether value is not null and not undefined, therefore "exist"

Params

  • any {any}: validation
  • returns {Boolean}: true if value is not null and not undefined, else false.

Example

isExist('test')
//=> true

isBoolean

Make sure whether value is of type Boolean.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Boolean, else false.

Example

isBoolean(false)
//=> true

isArray

Make sure whether value is of type Array.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Array, else false.

Example

isArray([1, 'test'])
//=> true

isObject

Make sure whether value is of type Object.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Object, else false.

Example

isObject({ prop: 'test' })
//=> true

isString

Make sure whether value is of type String.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type String, else false.

Example

isString('test')
//=> true

isNumber

Make sure whether value is of type Number.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Number, else false.

Example

isNumber(123)
//=> true

isDigit

Make sure whether value is of consist of Digit only.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is consist of Digit only, else false.

Example

isDigit('123')
//=> true
isDigit(123)
//=> true

isFunction

Make sure whether value is of type Function.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Function, else false.

Example

isFunction(() => console.log('test'))
//=> true

isEmptyString

Make sure whether value is of type String, and has 0 characters.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type String and has 0 characters, else false.

Example

isEmptyString('')
//=> true

isNonEmptyString

Make sure whether value is of type String, and has at least 1 character.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type String and has at least 1 character, else false.

Example

isNonEmptyString('test')
//=> true

isEmptyArray

Make sure whether value is of type Array and has no elements.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Array and has no elements, else false.

Example

isEmptyArray([])
//=> true

isNonEmptyArray

Make sure whether value is of type Array and has at least one element.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Array and has at least one element, else false.

Example

isNonEmptyArray([])
//=> true

isEmptyObject

Make sure whether value is of type Object and has no keys, including non-enumerable properties, and symbols.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Object and is "empty", else false.

Example

isEmptyObject([])
//=> true

isTrue

Make sure whether value is of type Boolean and is true.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Boolean and is true, else false.

Example

isTrue(true)
//=> true

isFalse

Make sure whether value is of type Boolean and is false

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Boolean and is false, else false.

Example

isFalse(false)
//=> true

isInteger

Make sure whether value is of type Number and is Integer.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is of type Number, else false.

Example

isInteger(123)
//=> true

isPositiveInteger

Make sure whether value is an Integer and greater than 0.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is an Integer and greater than 0, else false. Example
isPositiveInteger(123)
//=> true

isNonNegativeInteger

Make sure whether value is an Integer and greater or equal to 0.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is an Integer and greater or equal to 0, else false.

Example

isNonNegativeInteger(0)
//=> true

hasOneItem

Make sure whether value is an Array and its length is 1.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is an Array and its length is 1, else false.

Example

hasOneItem([1])
//=> true

hasMultipleItems

Make sure whether value is an Array and its length is more than 1.

Params

  • any {any}: validation
  • returns {Boolean}: true if value is an Array and its length is greater than 1, else false.

Example

hasMultipleItems([1, 2, 3])
//=> true

Author

Muhammad Sulton

License

Copyright © 2020 Muhammad Sulton Released under the MIT license.