Skip to content

Check Utilities

Collection of validation and check utilities.

isArray

Checks if a value is an array.

Signature:

typescript
export declare const isArray: <T>(value: T) => boolean;

Example:

typescript
import { isArray } from "easy-kit-utils";

isArray([1, 2]); // true
isArray("abc"); // false

isBlankArray

Checks if a value is an array and is empty.

Signature:

typescript
export declare const isBlankArray: <T>(value: T[]) => boolean;

Example:

typescript
import { isBlankArray } from "easy-kit-utils";

isBlankArray([]); // true
isBlankArray([1]); // false

isBoolean

Checks if value is classified as a boolean primitive or object.

Signature:

typescript
export declare const isBoolean: (value: unknown) => value is boolean;

Example:

typescript
import { isBoolean } from "easy-kit-utils";

isBoolean(false); // true
isBoolean(null); // false

isDefined

Checks if value is defined (not undefined).

Signature:

typescript
export declare const isDefined: <T>(value: T | undefined) => value is T;

Example:

typescript
import { isDefined } from "easy-kit-utils";

isDefined(undefined); // false
isDefined(0); // true

isEmptyString

Checks if a value is an empty string.

Signature:

typescript
export declare const isEmptyString: <T>(value: T) => boolean;

Example:

typescript
import { isEmptyString } from "easy-kit-utils";

isEmptyString(""); // true
isEmptyString("  "); // true (if trimmed check included)
isEmptyString("abc"); // false

isFunction

Checks if a value is a function.

Signature:

typescript
export declare const isFunction: <T>(value: T) => boolean;

Example:

typescript
import { isFunction } from "easy-kit-utils";

isFunction(() => {}); // true
isFunction(123); // false

isNull

Checks if value is null.

Signature:

typescript
export declare const isNull: (value: unknown) => value is null;

Example:

typescript
import { isNull } from "easy-kit-utils";

isNull(null); // true
isNull(undefined); // false

isNumber

Checks if a value is a number and not NaN.

Signature:

typescript
export declare const isNumber: <T>(value: T) => boolean;

Example:

typescript
import { isNumber } from "easy-kit-utils";

isNumber(123); // true
isNumber(NaN); // false
isNumber("123"); // false

isObject

Checks if value is object-like. A value is object-like if it's not null and has a typeof result of "object".

Signature:

typescript
export declare const isObject: <T>(value: T) => boolean;

Example:

typescript
import { isObject } from "easy-kit-utils";

isObject({}); // true
isObject([1, 2, 3]); // true
isObject(null); // false

isPromise

Checks if value is a Promise.

Signature:

typescript
export declare const isPromise: <T = any>(
  value: unknown
) => value is Promise<T>;

Example:

typescript
import { isPromise } from "easy-kit-utils";

isPromise(new Promise(() => {})); // true
isPromise({ then: () => {} }); // true

isString

Checks if value is classified as a String primitive or object.

Signature:

typescript
export declare const isString: (value: unknown) => value is string;

Example:

typescript
import { isString } from "easy-kit-utils";

isString("abc"); // true
isString(1); // false

isTrue

Checks if something is true.

Signature:

typescript
export declare const isTrue: (value: unknown) => value is true;

Example:

typescript
import { isTrue } from "easy-kit-utils";

isTrue(true); // true
isTrue(false); // false
isTrue(1); // false

isTrueFormat

Checks if the provided value matches the specified MIME type format.

Signature:

typescript
export declare const isTrueFormat: <T>(value: T, format: Format) => boolean;

Example:

typescript
import { isTrueFormat, Format } from "easy-kit-utils";

isTrueFormat("image/png", Format.PNG); // true (assuming Format enum/type)