@kikiki_kiki/is-object
v2.0.1
Published
Determine if the parameter is Object. Verifies if it not an array, null, function, Date, RegExp, Symbol and Class Object.
Downloads
23
Readme
isObject
function isObject(value?: unknown): value is Record<string, unknown>;
Determine if the parameter is Object ({}
). Verifies if it not an array, null
, function
, Date
, RegExp
, Symbol
and Class Object
.
:rocket: install
$ npm install @kikiki_kiki/is-object
:rabbit: usage
import isObject from '@kikiki_kiki/is-object';
:rotating_light: test
$ npm run test
isObject({});
// => true
isObject([]);
// => false
isObject(null);
// => false
isObject(undefined);
// => false
isObject(true);
// => false
isObject(false);
// => false
isObject(NaN);
// => false
isObject(1);
// => false
isObject(-1);
// => false
isObject('');
// => false
function
, Date
, RegExp
, Symbol
, Class object
return false
function
const func = function () {
return true;
};
isObject(func);
// => false
Date
const date = new Date();
isObject(date);
// => false
RegExp
const regex1 = /\w+/;
expect(isObject(regex1)).toBe(false);
// => false
const regex2 = new RegExp('\\w+');
expect(isObject(regex2)).toBe(false);
// => false
Symbol
const symbol1 = Symbol();
isObject(symbol1);
// => false
const symbol2 = Symbol({});
isObject(symbol2);
// => false
Class
class MyClass {
constructor() {}
}
const classObj = new MyClass();
isObject(classObj);
// => false