https://github.com/writetome51/basic-data-handling
JavaScript functions that check if the passed argument meets a data type requirement.
https://github.com/writetome51/basic-data-handling
data-types is-finite-number is-string isarray isfloat isinteger javascript logic-err type-checking typescript
Last synced: 5 months ago
JSON representation
JavaScript functions that check if the passed argument meets a data type requirement.
- Host: GitHub
- URL: https://github.com/writetome51/basic-data-handling
- Owner: writetome51
- License: mit
- Created: 2018-09-13T03:53:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-14T22:45:08.000Z (almost 7 years ago)
- Last Synced: 2025-08-09T02:24:31.297Z (6 months ago)
- Topics: data-types, is-finite-number, is-string, isarray, isfloat, isinteger, javascript, logic-err, type-checking, typescript
- Language: JavaScript
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# basic-data-handling
This package contains functions that simply check if the passed argument meets a
data type requirement.
## To use any one of the functions below...
If using TypeScript, include the function's import statement
(commented below each function).
If using plain JavaScript, turn that 'import' statement into a
'require' statement like so:
```
import {functionName} from 'basic-data-handling/fileContainingFunction'
becomes this:
var functionName = require('basic-data-handling/fileContainingFunction').functionName;
```
## Functions that throw Error if `arg` is not
required type (they all return void)
checkTypeOf(arg, expectedType)
`// Performs typeof check on arg. If arg is not expectedType, throws Error.`
`// import {checkTypeOf} from 'basic-data-handling/checkTypeOf' `
errorIfNotArray(arg)
`// import {errorIfNotArray} from 'basic-data-handling/errorIfNotArray' `
errorIfNotBoolean(arg)
`// import {errorIfNotBoolean} from 'basic-data-handling/errorIfNotBoolean' `
errorIfNotDefined(arg)
`// errors if arg is undefined or null.`
`// import {errorIfNotDefined} from 'basic-data-handling/errorIfNotDefined' `
errorIfNotFloat(arg)
`// import {errorIfNotFloat} from 'basic-data-handling/errorIfNotFloat' `
errorIfNotFunction(arg)
`// import {errorIfNotFunction} from 'basic-data-handling/errorIfNotFunction' `
errorIfNotInteger(arg)
`// import {errorIfNotInteger} from 'basic-data-handling/errorIfNotInteger' `
errorIfNotIntegerZeroOrGreater(arg)
`// import {errorIfNotIntegerZeroOrGreater} from 'basic-data-handling/errorIfNotIntegerZeroOrGreater' `
errorIfNotNumber(arg)
`// errors if arg is not finite number.`
`// import {errorIfNotNumber} from 'basic-data-handling/errorIfNotNumber' `
errorIfNotObject(arg)
`// errors if arg is string, boolean, number, function, null, or undefined.`
`// import {errorIfNotObject} from 'basic-data-handling/errorIfNotObject' `
errorIfNotPrimitive(arg)
`// import {errorIfNotPrimitive} from 'basic-data-handling/errorIfNotPrimitive' `
errorIfNotString(arg)
`// import {errorIfNotString} from 'basic-data-handling/errorIfNotString' `
## Functions that return boolean
isArray(arg)
`// import {isArray} from 'basic-data-handling/isArray_notArray' `
notArray(arg)
`// import {notArray} from 'basic-data-handling/isArray_notArray' `
isObject(arg)
`// Arrays ARE considered objects. `
`// Does NOT consider null an object. `
`// Does NOT consider functions objects. `
`// import {isObject} from 'basic-data-handling/isObject_notObject' `
notObject(arg)
`// Returns true if arg is string, boolean, number, function, null, or undefined.`
`// import {notObject} from 'basic-data-handling/isObject_notObject' `
isString(arg)
`// import {isString} from 'basic-data-handling/isString_notString' `
notString(arg)
`// import {notString} from 'basic-data-handling/isString_notString' `
isFiniteNumber(arg)
`// import {isFiniteNumber} from 'basic-data-handling/isFiniteNumber' `
notFiniteNumber(arg)
`// import {notFiniteNumber} from 'basic-data-handling/isFiniteNumber' `
isInteger(arg)
`// import {isInteger} from 'basic-data-handling/isInteger_isFloat' `
notInteger(arg)
`// import {notInteger} from 'basic-data-handling/isInteger_isFloat' `
isFloat(arg)
`// import {isFloat} from 'basic-data-handling/isInteger_isFloat' `
isEmpty(arrayOrString)
`// import {isEmpty} from 'basic-data-handling/isEmpty_notEmpty' `
notEmpty(arrayOrString)
`// import {notEmpty} from 'basic-data-handling/isEmpty_notEmpty' `
isDefined(arg)
`// returns true if arg is not undefined or null.`
`// import {isDefined} from 'basic-data-handling/isDefined_notDefined' `
notDefined(arg)
`// returns true if arg is undefined or null.`
`// import {notDefined} from 'basic-data-handling/isDefined_notDefined' `
## Installation
`npm i basic-data-handling`