Skip to content

Simple JavaScript type checking module. Returns a Boolean or type name for each type check.

License

Notifications You must be signed in to change notification settings

smartFlash/qatype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qatype.js

node Build Status npm npm Github file size

A Simple JavaScript type checking module for JavaScript that returns a Boolean or type name for each type check. It's small (< 0.6kb gzip)

Usage

qatype.isArray([1,2]); // true
qatype.isObject({a:1}); // true
qatype.isString('test string'); // true
qatype.isDate(new Date()); // true
qatype.isRegExp(/^qatype/i); // true
qatype.isFunction(function () {}); // true
qatype.isBoolean(true); // true
qatype.isNumber(8); // true
qatype.isNull(null); // true
qatype.isUndefined(); // true
qatype.isZero(0); // true
qatype.isPromise((new Promise(resolve,reject)=>{resolve(true)}); // true

// Usage the similar with above code
qatype.type({}); //Object,It will return type name for object

Install

npm install qatype.js

CDN

Manual installation

Ensure you're using the files from the dist directory (contains compiled production-ready code). Ensure you place the script before the closing </body> tag.

<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
	    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	    <title>qatype.js</title>
	</head>
	<body>
	  <script type="text/javascript" src="dist/qatype.min.js"></script>
	  <script type="text/javascript" >
	  // qatype.js module available
	  </script>
	</body>
</html>

Became a Contributor

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

About

Simple JavaScript type checking module. Returns a Boolean or type name for each type check.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published