JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q32750F
  • License MIT

Pure JavaScript utility functions

Package Exports

  • phane-js-utils
  • phane-js-utils/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (phane-js-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

DataTypeCheck

Data Check helpers.

DataTypeCheck.checkIsNumber(userInput) ⇒ boolean | undefined

Check if the user input is a number or not.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if number, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsNumber(37) => true

checkIsNumber("hello") => false

checkIsNumber() => undefined

checkIsNumber(null) => undefined

DataTypeCheck.checkIsString(userInput) ⇒ boolean | undefined

Check if the user input is a string or not.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if string, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsString(37) => false

checkIsString("hello") => true

checkIsString() => undefined

checkIsString(null) => undefined

DataTypeCheck.checkIsBoolean(userInput) ⇒ boolean | undefined

Check if the user input is a boolean or not.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if boolean, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsBoolean(37) => false

checkIsBoolean("hello") => false

checkIsBoolean(false) => true

checkIsBoolean() => undefined

checkIsBoolean(null) => undefined

DataTypeCheck.checkIsBigint(userInput) ⇒ boolean | undefined

Check if the user input is a Bigint or not.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if bigint, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsBigint(37n) => true

checkIsBigint("hello") => false

checkIsBigint(37) => false

checkIsBigint() => undefined

checkIsBigint(null) => undefined

DataTypeCheck.checkIsFunction(userInput) ⇒ boolean | undefined

Check if the user input is a function.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if function, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsFunction(function() {}) => true

checkIsFunction(() => {}) => true

checkIsFunction(42) => false

checkIsFunction(null) => undefined

checkIsFunction()  => undefined

DataTypeCheck.checkIsObject(userInput) ⇒ boolean | undefined

Check if the user input is an object.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if object, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsObject({}) => true

checkIsObject({ a: 1 }) => true

checkIsObject([]) => true (arrays are objects in JavaScript)

checkIsObject(null) => undefined

checkIsObject(42) => false

DataTypeCheck.checkObjectLength(userInput) ⇒ number | undefined

Get the number of key-value pairs in an object.

Kind: static method of DataTypeCheck
Returns: number | undefined - Number of entries if object, undefined otherwise

Param Type Description
userInput * Any value to check

Example

checkObjectLength({ a: 1, b: 2 }) => 2

checkObjectLength({}) => 0

checkObjectLength([]) => 0 (arrays are objects in JavaScript)

checkObjectLength(null) => undefined

checkObjectLength(42) => undefined

DataTypeCheck.checkIsArray(userInput) ⇒ boolean | undefined

Check if the user input is an array.

Kind: static method of DataTypeCheck
Returns: boolean | undefined - Returns true if array, false if not, undefined if input is null/undefined

Param Type Description
userInput * Any value to check

Example

checkIsArray([1, 2, 3]) => true

checkIsArray([]) => true

checkIsArray({})  => false

checkIsArray(null) => undefined

checkIsArray(42) => false

DataTypeCheck.checkArrayLength(userInput) ⇒ number | undefined

Get the length of an array.

Kind: static method of DataTypeCheck
Returns: number | undefined - Length of the array if input is an array, undefined otherwise

Param Type Description
userInput * Any value to check

Example

checkArrayLength([1, 2, 3])  => 3

checkArrayLength([]) => 0

checkArrayLength({}) => undefined

checkArrayLength(null) => undefined

checkArrayLength(42) => undefined