Node.js's util module for all engines providing cross-platform utility functions for formatting, type checking, inheritance, promises, and debugging.
—
Comprehensive type validation system with both basic JavaScript type checking and advanced type detection for modern JavaScript features.
Fundamental type checking functions for JavaScript primitives and common objects.
/**
* Checks if value is an array
* @param {any} ar - Value to check
* @returns {boolean} True if value is an array
*/
function isArray(ar): boolean;
/**
* Checks if value is a boolean
* @param {any} arg - Value to check
* @returns {boolean} True if value is a boolean
*/
function isBoolean(arg): boolean;
/**
* Checks if value is null
* @param {any} arg - Value to check
* @returns {boolean} True if value is null
*/
function isNull(arg): boolean;
/**
* Checks if value is null or undefined
* @param {any} arg - Value to check
* @returns {boolean} True if value is null or undefined
*/
function isNullOrUndefined(arg): boolean;
/**
* Checks if value is a number
* @param {any} arg - Value to check
* @returns {boolean} True if value is a number
*/
function isNumber(arg): boolean;
/**
* Checks if value is a string
* @param {any} arg - Value to check
* @returns {boolean} True if value is a string
*/
function isString(arg): boolean;
/**
* Checks if value is a symbol
* @param {any} arg - Value to check
* @returns {boolean} True if value is a symbol
*/
function isSymbol(arg): boolean;
/**
* Checks if value is undefined
* @param {any} arg - Value to check
* @returns {boolean} True if value is undefined
*/
function isUndefined(arg): boolean;
/**
* Checks if value is a regular expression
* @param {any} re - Value to check
* @returns {boolean} True if value is a RegExp
*/
function isRegExp(re): boolean;
/**
* Checks if value is an object (not null)
* @param {any} arg - Value to check
* @returns {boolean} True if value is an object and not null
*/
function isObject(arg): boolean;
/**
* Checks if value is a Date object
* @param {any} d - Value to check
* @returns {boolean} True if value is a Date
*/
function isDate(d): boolean;
/**
* Checks if value is an Error object
* @param {any} e - Value to check
* @returns {boolean} True if value is an Error
*/
function isError(e): boolean;
/**
* Checks if value is a function
* @param {any} arg - Value to check
* @returns {boolean} True if value is a function
*/
function isFunction(arg): boolean;
/**
* Checks if value is a primitive type
* @param {any} arg - Value to check
* @returns {boolean} True if value is null, boolean, number, string, symbol, or undefined
*/
function isPrimitive(arg): boolean;
/**
* Checks if value is a Buffer (Node.js/browser compatible)
* @param {any} arg - Value to check
* @returns {boolean} True if value is a Buffer
*/
function isBuffer(arg): boolean;Usage Examples:
const util = require('util');
// Basic type checks
util.isString('hello'); // true
util.isNumber(42); // true
util.isArray([1, 2, 3]); // true
util.isFunction(() => {}); // true
util.isObject({}); // true
util.isNull(null); // true
util.isUndefined(undefined); // true
// Date and RegExp
util.isDate(new Date()); // true
util.isRegExp(/pattern/); // true
// Error checking
util.isError(new Error('message')); // true
util.isError(new TypeError('type error')); // true
// Primitives
util.isPrimitive('string'); // true
util.isPrimitive(42); // true
util.isPrimitive({}); // falseAdvanced type detection for modern JavaScript features including collections, typed arrays, and boxed primitives.
const types: {
// Collection Types
isMap(value): boolean;
isSet(value): boolean;
isWeakMap(value): boolean;
isWeakSet(value): boolean;
// Array Buffer Types
isArrayBuffer(value): boolean;
isSharedArrayBuffer(value): boolean;
isArrayBufferView(value): boolean;
isDataView(value): boolean;
isAnyArrayBuffer(value): boolean;
// Typed Arrays
isTypedArray(value): boolean;
isUint8Array(value): boolean;
isUint8ClampedArray(value): boolean;
isUint16Array(value): boolean;
isUint32Array(value): boolean;
isInt8Array(value): boolean;
isInt16Array(value): boolean;
isInt32Array(value): boolean;
isFloat32Array(value): boolean;
isFloat64Array(value): boolean;
isBigInt64Array(value): boolean;
isBigUint64Array(value): boolean;
// Boxed Primitives
isNumberObject(value): boolean;
isStringObject(value): boolean;
isBooleanObject(value): boolean;
isBigIntObject(value): boolean;
isSymbolObject(value): boolean;
isBoxedPrimitive(value): boolean;
// Function Types
isGeneratorFunction(value): boolean;
isAsyncFunction(value): boolean;
isGeneratorObject(value): boolean;
// Iterator Types
isMapIterator(value): boolean;
isSetIterator(value): boolean;
// Other Types
isArgumentsObject(value): boolean;
isPromise(value): boolean;
isWebAssemblyCompiledModule(value): boolean;
// Aliases
isDate(value): boolean;
isRegExp(value): boolean;
isNativeError(value): boolean;
// Unsupported (throw errors)
isProxy(): never;
isExternal(): never;
isModuleNamespaceObject(): never;
};Usage Examples:
const util = require('util');
// Collections
util.types.isMap(new Map()); // true
util.types.isSet(new Set()); // true
util.types.isWeakMap(new WeakMap()); // true
// Typed Arrays
util.types.isUint8Array(new Uint8Array()); // true
util.types.isFloat32Array(new Float32Array()); // true
util.types.isTypedArray(new Int16Array()); // true
// Array Buffers
util.types.isArrayBuffer(new ArrayBuffer(16)); // true
util.types.isDataView(new DataView(new ArrayBuffer(16))); // true
// Boxed Primitives
util.types.isNumberObject(new Number(42)); // true
util.types.isStringObject(new String('hello')); // true
util.types.isBoxedPrimitive(new Boolean(true)); // true
// Functions
util.types.isAsyncFunction(async () => {}); // true
util.types.isGeneratorFunction(function* () {}); // true
// Promises
util.types.isPromise(Promise.resolve()); // true
util.types.isPromise({ then: () => {}, catch: () => {} }); // true
// Arguments object
function example() {
return util.types.isArgumentsObject(arguments); // true
}Install with Tessl CLI
npx tessl i tessl/npm-util