CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-is-type-of

Complete type checking utility library for Node.js with TypeScript support and type guards

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

primitive-types.mddocs/

Primitive Type Checking

Complete type checking for JavaScript primitive types including strings, numbers, booleans, symbols, null, undefined, and bigint. Also includes specialized number checkers for integers, safe integers, and doubles.

Capabilities

String Type Checking

Returns true if value is a string primitive (not String object).

/**
 * Returns true if val is string, not String object
 * @param val - Value to check
 * @returns Type guard indicating if value is string
 */
function isString(val?: unknown): val is string;

Usage Example:

import { isString } from "is-type-of";

isString("hello");        // => true
isString(new String("hello"));  // => false
isString(42);             // => false

Number Type Checking

Returns true if value is a number primitive (not Number object).

/**
 * Returns true if val is number, not Number object
 * @param val - Value to check
 * @returns Type guard indicating if value is number
 */
function isNumber(val?: unknown): val is number;

Usage Example:

import { isNumber } from "is-type-of";

isNumber(42);             // => true
isNumber(new Number(42)); // => false
isNumber("42");           // => false

Boolean Type Checking

Returns true if value is a boolean primitive (not Boolean object).

/**
 * Returns true if val is boolean, not Boolean object
 * @param val - Value to check
 * @returns Type guard indicating if value is boolean
 */
function isBoolean(val?: unknown): val is boolean;

Symbol Type Checking

Returns true if value is a symbol.

/**
 * Returns true if val is symbol
 * @param val - Value to check
 * @returns Type guard indicating if value is symbol
 */
function isSymbol(val?: unknown): val is symbol;

Undefined Type Checking

Returns true if value is undefined.

/**
 * Returns true if val is undefined
 * @param val - Value to check
 * @returns Type guard indicating if value is undefined
 */
function isUndefined(val?: unknown): val is undefined;

Null Type Checking

Returns true if value is null.

/**
 * Returns true if val is null
 * @param val - Value to check
 * @returns Type guard indicating if value is null
 */
function isNull(val?: unknown): val is null;

BigInt Type Checking

Returns true if value is a bigint.

/**
 * Returns true if val is bigint
 * @param val - Value to check
 * @returns Type guard indicating if value is bigint
 */
function isBigInt(val?: unknown): val is bigint;

Nullable Type Checking

Returns true if value is null or undefined.

/**
 * Returns true if val is null or undefined
 * @param val - Value to check
 * @returns Type guard indicating if value is null or undefined
 */
function isNullable(val?: unknown): val is Nullable;

Usage Example:

import { isNullable } from "is-type-of";

isNullable(null);      // => true
isNullable(undefined); // => true
isNullable(0);         // => false
isNullable("");        // => false

Primitive Type Checking

Returns true if value is any primitive type.

/**
 * Returns true if val is primitive
 * @param val - Value to check
 * @returns Type guard indicating if value is primitive
 */
function isPrimitive(val?: unknown): val is Primitive;

Usage Example:

import { isPrimitive } from "is-type-of";

isPrimitive("hello");  // => true
isPrimitive(42);       // => true
isPrimitive(true);     // => true
isPrimitive({});       // => false
isPrimitive([]);       // => false

Number Specializations

Integer Type Checking

Returns true if value is an integer.

/**
 * Returns true if val is integer
 * @param val - Value to check
 * @returns Type guard indicating if value is integer
 */
function isInteger(val?: unknown): val is number;

Usage Example:

import { isInteger } from "is-type-of";

isInteger(42);    // => true
isInteger(42.5);  // => false
isInteger("42");  // => false

32-bit Integer Type Checking

Returns true if value is an integer between -2^31 and 2^31-1.

/**
 * Returns true if val is integer, and between -2 ** 31 and 2 ** 31 - 1
 * @param val - Value to check
 * @returns Type guard indicating if value is 32-bit integer
 */
function isInteger32(val?: unknown): val is number;

Usage Example:

import { isInteger32 } from "is-type-of";

isInteger32(42);                    // => true
isInteger32(Math.pow(2, 31) - 1);   // => true
isInteger32(Math.pow(2, 31));       // => false

Long Integer Type Checking

Returns true if value is an integer outside the 32-bit range.

/**
 * Returns true if val is integer, and < -2 ** 31, and > 2 ** 31 - 1
 * @param val - Value to check
 * @returns Type guard indicating if value is long integer
 */
function isLong(val?: unknown): val is number;

Usage Example:

import { isLong } from "is-type-of";

isLong(Math.pow(2, 33));  // => true
isLong(42);               // => false

Safe Integer Type Checking

Returns true if value is a safe integer (within JavaScript's safe integer range).

/**
 * Returns true if val is integer, and between -(2 ** 53 - 1) and 2 ** 53 - 1
 * @param val - Value to check
 * @returns Type guard indicating if value is safe integer
 */
function isSafeInteger(val?: unknown): val is number;

Double Type Checking

Returns true if value is a floating-point number (has decimal part).

/**
 * Returns true if val is Double
 * @param val - Value to check
 * @returns Type guard indicating if value is double
 */
function isDouble(val?: unknown): val is number;

Usage Example:

import { isDouble } from "is-type-of";

isDouble(42.5);   // => true
isDouble(42);     // => false
isDouble("42.5"); // => false

NaN Type Checking

Returns true if value is NaN.

/**
 * Returns true if val is NaN
 * @param val - Value to check
 * @returns Boolean indicating if value is NaN
 */
function isNaN(val?: unknown): boolean;

Finite Type Checking

Returns true if value is a finite number.

/**
 * Returns true if val is finite
 * @param val - Value to check
 * @returns Type guard indicating if value is finite number
 */
function isFinite(val?: unknown): val is number;

Usage Example:

import { isFinite } from "is-type-of";

isFinite(42);         // => true
isFinite(Infinity);   // => false
isFinite(NaN);        // => false

Type Definitions

type Primitive = string | number | bigint | boolean | symbol | null | undefined;
type Nullable = null | undefined;

docs

external-objects.md

index.md

node-objects.md

primitive-types.md

standard-objects.md

tile.json