1.7.0 • Published 12 months ago

whichtype v1.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

whichtype

whichtype is a small JavaScript/TypeScript library for checking the type of your variables, written in TypeScript. It has no dependencies.

I felt the need for whichtype when I was working on josn.

I am using readmix for generating this README. You can view the source file here.

Table of contents

Installation

You can install whichtype with the following command:

npm i whichtype

Now, you can import whichtype in your project as follows.

const whichtype = require("whichtype");
whichtype.isNumber(100);    // true

Documentation

whichtype exports the following functions. Each of these functions accept a single argument and return true or false.

FunctionDescription
Basics
isArray(arg)Returns true only if arg is an Array.
isBoolean(arg)Returns true only if arg is a Boolean.
isChar(arg)Returns true only if arg is a Char.
isNumber(arg)Returns true only if arg is a Number.
isObject(arg)Returns true only if arg is an Object.
isString(arg)Returns true only if arg is a String.
isNull(arg)Returns true only if arg is null.
isUndefined(arg)Returns true only if arg is undefined.
isPrimitive(arg)Returns true only if arg is a Primitive value.
isReference(arg)Returns true only if arg is a Reference value.
isSimple(arg)Alias for isPrimitive.
isComplex(arg)Alias for isReference.
Inverses
isNotArray(arg)Returns true only if arg is NOT an Array.
isNotBoolean(arg)Returns true only if arg is NOT a Boolean.
isNotChar(arg)Returns true only if arg is NOT a Char.
isNotNumber(arg)Returns true only if arg is NOT a Number.
isNotObject(arg)Returns true only if arg is NOT an Object.
isNotString(arg)Returns true only if arg is NOT a String.
isNotNull(arg)Returns true only if arg is NOT null.
isNotUndefined(arg)Returns true only if arg is NOT undefined.
isNotPrimitive(arg)Returns true only if arg is NOT a Primitive value.
isNotReference(arg)Returns true only if arg is NOT a Reference value.
isNotSimple(arg)Alias for isNotPrimitive.
isNotComplex(arg)Alias for isNotReference.
Arg FunctionsFor checking the type of command line arguments.
hasAColon(arg)Returns true only if arg contains a colon.
isNumeric(arg)Returns true only if arg is a numeric string.
isArrayIndex(arg)Returns true only if arg is an Array Index.
isObjectKey(arg)Returns true only if arg is an Object Key.
isFlag(arg)Returns true only if arg is a flag.
isNotFlag(arg)Returns true only if arg is NOT a flag.
isSingleFlag(arg)Returns true only if arg is a single flag.
isDoubleFlag(arg)Returns true only if arg is a double flag.
isTripleFlag(arg)Returns true only if arg is a triple flag.
Array FunctionsFor checking the type of Arrays.
isEmptyArray(arg)Returns true only if arg is an empty Array.
isNonEmptyArray(arg)Returns true only if arg is a non-empty Array.
isArrayOfArrays(arg)Returns true only if arg is an Array of Arrays.
isArrayOfBooleans(arg)Returns true only if arg is an Array of Boolean values.
isArrayOfChars(arg)Returns true only if arg is an Array of Char values.
isArrayOfNumbers(arg)Returns true only if arg is an Array of Numbers.
isArrayOfObjects(arg)Returns true only if arg is an Array of Objects.
isArrayOfStrings(arg)Returns true only if arg is an Array of Strings.
isArray2D(arg)Alias for isArrayOfArrays.
isGrid(arg)Alias for isArrayOfArrays.
isTable(arg)Alias for isArrayOfObjects.
Object FunctionsFor checking the type of Objects
isEmptyObject(arg)Returns true only if arg is an empty Object.
isNonEmptyObject(arg)Returns true only if arg is a non-empty Object.
isObjectOfArrays(arg)Returns true only if arg is an Object only containing Array values.
isObjectOfBooleans(arg)Returns true only if arg is an Object only containing Boolean values.
isObjectOfChars(arg)Returns true only if arg is an Object only containing Char values.
isObjectOfNumbers(arg)Returns true only if arg is an Object only containing Number values.
isObjectOfObjects(arg)Returns true only if arg is an Object only containing Object values.
isObjectOfStrings(arg)Returns true only if arg is an Object only containing String values.
isHashTable(arg)Alias for isObjectOfArrays.
isObject2D(arg)Alias for isObjectOfObjects.

Package details

NameValue
Namewhichtype
DescriptionWhichtype is a small JavaScript library for checking the type of your variables.
Version1.7.0
Authoriaseth
Homepagehttps://github.com/iaseth/whichtype
Repositoryiaseth/whichtype
LicenseMIT
Dependencies0

Dependencies

This package has no dependencies.

Dev dependencies

PackageVersion
1@types/jest^29.5.1
2jest^29.5.0

License

MIT License

Copyright (c) Ankur Seth.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Credit

This file was generated using readmix.

1.7.0

12 months ago

1.6.0

12 months ago

1.5.0

12 months ago

1.4.0

12 months ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.10.0

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago

0.8.0

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago