@kikiki_kiki/is-object
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

NPM version Build Status coverage MIT License

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.

🚀 install

$ npm install @kikiki_kiki/is-object

🐰 usage

import isObject from '@kikiki_kiki/is-object';

🚨 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

Readme

Keywords

Package Sidebar

Install

npm i @kikiki_kiki/is-object

Weekly Downloads

2

Version

2.0.1

License

MIT

Unpacked Size

23.8 kB

Total Files

15

Last publish

Collaborators

  • kikiki_kiki