GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - typeis/typeis: Typeis. it's the smart and simple javaScript type checker

BranchesTags
Open more actions menu

Latest commit

 

History

28 Commits
28 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
package.json
package.json
 
 
typeis.js
typeis.js
 
 

Repository files navigation

In Javascript, "Everything is (or acts like) an Object" We need to write "typeis.js" due to a problem (type check) arised other than except the conveniences it is a providing to us.

typeis.js

Typeis. it's the smart and simple javascript type check and validation library ~226 Bytes;

Value Native Typeis.js
Undeclared variables undefined ---
undefined undefined ---
null object ---
Booleans boolean Boolean
Numbers number Number
String string String
Functions function Function
Array object Array
Object object Object
Date object Date
RegExp object RegExp

Be careful!

Everything in JavaScript acts like an object, with the only two exceptions being null and undefined. *JavaScript Garden Typeis.js acts like an property; doesn't work null and undefined types because they doesn't have properties.

Download

  • typeis.js ~813 B (413 B gzipped)
  • typeis.min.js ~305 B (226 B gzipped)

Installation

npm install typeis
bower install typeis

Usage

In Node.js:

require('typeis');

In a browser:

<script src="typeis.js"></script>

Examples

Property usage will not available after ^2.0 anymore, please use function typeis(variable, [type]) Basic type checking
variable.typeis();
// return Array, Object, RegExp, Date etc.

Multi type validation

typeis(variable, ['array', 'object']);
// if variable is Array or Object return true otherwise false

Type valition with regex

typeis(variable, 'array|object');
// if variable is Array or object return true otherwise false

typeis(variable, '.+[yep]$');
// if variable type end of "y", "e" and "p" like Array, Date, RegExp return true otherwise false

typeis(variable, '(^(?!array|object).+)[^n]$');
// if variable is Array, Object or ending "n" like Function and Boolean return false otherwise true

Real world Usage

function realWorld( options ){
    if(typeis(options, 'object')){
        //do something
    } else {
        //do another something
    }
}

Browser Support

IE9 and below also support all modern browser.

Changelog

1.1.2

Property usage warning

1.1.1

Update readme

1.1.0

Multi type validation support

variable.typeis(['array', 'object']);
// if variable is Array or Object return true otherwise false

type validation with regex support

variable.typeis('array|object');
// if variable is Array or object return true otherwise false
1.0

Typeis.js Released

About

Typeis. it's the smart and simple javaScript type checker

typeis.github.io/

Topics

javascriptsimpletype-checkertype-checkingtypeistypeof

Resources

Readme
Activity
Custom properties

Stars

93 stars

Watchers

3 watching

Forks

11 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.