Skip to main content

Lang Methods

is

Since: 0.1.0

Arguments

ParamTypeDescription
objectanyThe object (constructor) to used for comparison
valueanyThe value to compare

Returns

TypeDescription
booleanRetruns true if the value is object, else false

Declaration

declare const is: <T extends ConstructorObject>(
object: T,
value: unknown
) => value is T;

Examples

is(String, 'str'); // true
is(Boolean, true); // true
is(Boolean, 'true'); // false

isArray

Check value is array

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is any[]Retruns true if value is array, else false

Declaration

declare const isArray: <T = any>(value: unknown) => value is T[];

Examples

isArray([1, 2, 3]); // true
isArray(new Array()); // true
isArray(1); // false

isArrayLike

Check value is array-like

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is TRetruns true if value is array-like, else false

Declaration

declare const isArrayLike: <T extends ArrayLike<any>>(value: any) => value is T;

Examples

isArrayLike([1, 2, 3]); // true
isArrayLike('string'); // true
isArrayLike(1); // false

isBlank

Check value is blank

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value.length is falsy, else false

Declaration

declare const isBlank: (value: unknown) => boolean;

Examples

isBlank(''); // true
isBlank(undefined); // true
isBlank('a'); // false

isBoolean

Check value is boolean

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is booleanRetruns true if value is boolean, else false

Declaration

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

Examples

isBoolean(true); // true
isBoolean('true'); // false

isDate

Check value is date

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is DateRetruns true if value is date, else false

Declaration

declare const isDate: (value: unknown) => value is Date;

Examples

isDate(new Date()); // true
isDate('2024-01-01'); // false

isDateLike

Check value is date-like

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is date-like, else false

Declaration

declare const isDateLike: <T = unknown>(value: T) => boolean;

Examples

isDateLike(new Date()); // true
isDateLike('2024-01-01'); // true
isDateLike(100000000); // true
isDateLike('string'); // false

isElement

Check value is element

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is ElementRetruns true if value is element, else false

Declaration

declare const isElement: (value: unknown) => value is Element;

Examples

isElement(document.body); // true
isElement('<div></div>'); // false

isEmpty

Check value is empty

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is empty, else false

Declaration

declare const isEmpty: (value: unknown) => boolean;

Examples

isEmpty([]); // true
isEmpty({}); // true
isEmpty(new Set()); // true
isEmpty(false); // false

isEqual

Check values are equal

Since: 0.1.0

Arguments

ParamTypeDescription
valuanyvalue
comparanycompare

Returns

TypeDescription
booleanRetruns true if the values are equal, else false

Declaration

declare const isEqual: (value: any, compare: any) => boolean;

Examples

const obj = { a: 1 };

isEqual(obj, obj); // true
isEqual(obj, { a: 1 }); // true

isError

Check value is Error

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is ErrorRetruns true if value is error, else false

Declaration

declare const isError: (value: unknown) => value is Error;

Examples

isError(new Error()); // true
isError('error'); // false

isFunction

Check value is function

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is FunctionRetruns true if value is function, else false

Declaration

declare const isFunction: (value: unknown) => value is (...arg: any[]) => any;

Examples

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

isMap

Check value is Map

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is Map, else false

Declaration

declare const isMap: <T = Map<any, any>>(value: unknown) => value is T;

Examples

isMap(new Map()); // true
isMap({ a: 1, b: 2 }); // false

isNull

Check value is null

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is nullRetruns true if value is null, else false

Declaration

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

Examples

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

isNullish

Check value is nullish

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is null or undefined, else false

Declaration

declare const isNullish: (value: unknown) => value is null | undefined;

Examples

isNullish(null); // true
isNullish(undefined); // true
isNullish(0); // false

isNumber

Check value is number

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is numberRetruns true if value is number, else false

Declaration

declare const isNumber: (value: unknown) => value is number;

Examples

isNumber(123); // true
isNumber('123'); // false

isObject

Check value is object-like

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is object-like, else false

Declaration

declare const isObject: <T extends object = Dictionary<any>>(
value: unknown
) => value is T;

Examples

isObject({}); // true
isObject(() => false); // true
isObject([]); // true
isObject(1); // false

isPlainObject

Check value is plain object

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is plain object, else false

Declaration

declare const isPlainObject: <T extends Object = Dictionary<any> & Object>(
value: unknown
) => value is T;

Examples

isPlainObject({}); // true
isPlainObject(new Map()); // false
isPlainObject(1); // false

isRegExp

Check value is RegExp

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is RegExpRetruns true if value is RegExp, else false

Declaration

declare const isRegExp: (value: unknown) => value is RegExp;

Examples

isRegExp(/\d/gi); // true
isRegExp(new RegExp()); // true
isRegExp('d'); // false

isSet

Check value is Set

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is Set, else false

Declaration

declare const isSet: <T extends Set<any> = Set<any>>(
value: unknown
) => value is T;

Examples

isSet(new Set()); // true
isSet([1, 2, 3]); // false

isString

Check value is string

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is stringRetruns true if value is string, else false

Declaration

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

Examples

isString('is this string?'); // true
isString(0); // false

isSymbol

Check value is symbol

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is symbolRetruns true if value is symbol, else false

Declaration

declare const isSymbol: (value: unknown) => value is symbol;

Examples

isSymbol(Symbol('a')); // true
isSymbol('a'); // false

isUndefined

Check value is undefined

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
value is undefinedRetruns true if value is undefined, else false

Declaration

declare const isUndefined: (value: unknown) => value is undefined;

Examples

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

isWeakMap

Check value is WeakMap

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is WeakMap, else false

Declaration

declare const isWeakMap: <T extends WeakMap<any, any> = WeakMap<any, any>>(
value: unknown
) => value is T;

Examples

isWeakMap(new WeakMap()); // true
isWeakMap(new Map()); // false

isWeakSet

Check value is WeakSet

Since: 0.1.0

Arguments

ParamTypeDescription
valueanyThe value to check

Returns

TypeDescription
booleanRetruns true if value is WeakSet, else false

Declaration

declare const isWeakSet: <T extends WeakSet<any> = WeakSet<any>>(
value: unknown
) => value is T;

Examples

isWeakSet(new WeakSet()); // true
isWeakSet(new Set()); // false

tagType

Get Object.prototype.toString() type of value

Since: 0.1.0

Arguments

ParamTypeDescription
valuanyThe value to check type

Returns

TypeDescription
stringThe prototype of value

Declaration

declare const tagType: (value: any) => string;

Examples

tagType({}); // 'Object'
tagType(1); // 'Number'