This package has been deprecated

Author message:

Deprecated in favor of 'fjl'. All 0.2X.X versions and above contain all the 'is' methods along with newer implementations and more additions.


1.0.1 • Public • Published

Build Status GitHub version NPM version Dependencies


Is type checkers (isType, isBoolean etc.). All type checkers return a boolean indicating if passed in value matches given type or not.


  • npm install fjl-is or
  • yarn add fjl-is

Including module

  • Module exported for es6 and commonjs modules by way of package.json by default.
// Es6/2015
import {isNumber, isType} from 'fjl-is';

// CommonJs
const {isNumber, isType} = require('fjl-is');
  • Module is also exported to other formats available via './dist' folder. Other formats here are:
  • iife, umd, and amd as well as the other two mentioned above (es6-module and cjs).


import {isType, isNumber} from 'fjl-is';

// Filter an array by your type
[...].filter(isType(MyType)) // Filtering using `isType`'s curriable nature

// Checking with constructor name and/or actual constructor
isType('Array', []) === true; // Uses `(value)` behind the scenes via `fjl-typeof` module.
isType(Array, []) === true; // ""
// Check for true `Number` (not `NaN` being reported as `Number`).
isNumber(0 / 0) === `false` // `0 / 0` is `NaN` 

// Check for `string`
isString('') === `true`

// etc..

Note: All checkers are strict; E.g., they do not check for instance-of/inheritance except for isFunction (this one uses instanceof (more useful)) and isArray (which is actually just Array.isArray).


isType (Type, value) (curried)


  • Type - A type's name or the Type constructor itself.
    Returns a boolean indicating whether value matches given type or not.
  • value - Value to check.



_isType (Type, value) (un-curried)

Same is isType but un-curried.

isArray (value)

Returns a boolean indicating whether value matches type or not.

isBoolean (value)


isFunction (value)


isNumber (value)


isObject (value)


isString (value)


isset (value)

Returns a boolean indicating whether value is not null and not undefined or not; E.g. useful for places where you need explicit not null and not undefined values (like when allowing 0 or empty string but not allowing null or undefined from a function/statement).


Needed some stronger type-checking for javascript that didn't do any of the older hacks ( and worked for all values and types (including null, undefined, and NaN); Example:

// Old hack etc. 
const isType = (Type, x) => {
    if (x === null || Type === 'Null') {
        return 'Null';
    else if (x === undefined || Type === 'Undefined') {
        return 'Undefined';
    const typeName = (Type instanceof Function) ? : Type,
        typeDump =, // === "[object Number]" // part of
        foundTypeName = typeDump.substring(8, typeDump.length - 1);  
    return (foundTypeName === 'Number' && isNaN(Number)) ?
        'NaN' === typeName : foundTypeName === typeName;

// Note: Old hack from above is still pretty good though it is even easier to get a constructor's `name` property
(x) // which runs behind the scenes in the code below (after it's behind the scenes null checks and all..)

// New way (`typeOf` comes from `fjl-typeof` which does the type name getting part from above in a more modern way
const isType = (type, obj) => typeOf(obj) === (isFunction(type) ? : type);


BSD 3 Clause




Package Sidebar


npm i fjl-is

Weekly Downloads






Last publish


  • elycruz