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

0.0.3 • Public • Published

is-plain-object

Returns true if an object was created by the Object constructor, or Object.create(null).

This project originated from is-plain-object (released under MIT license). I reimplemented it by TypeScript.

Usage

With ES modules:

import { isPlainObject } from "is-plain-object";

true when created by the Object constructor, or Object.create(null).

isPlainObject(Object.create({})); // => true
isPlainObject(Object.create(Object.prototype)); // => true
isPlainObject({ foo: "bar" }); // => true
isPlainObject({}); // => true
isPlainObject(Object.create(null)); // => true

false when not created by the Object constructor.

isPlainObject(["foo", "bar"]); // => false
isPlainObject([]); // => false
isPlainObject(new Foo()); // => false

License

The original project is released under the MIT License.

The code in this project is released under the MIT License.

Package Sidebar

Install

npm i @mogeko/is-plain-object

Weekly Downloads

3

Version

0.0.3

License

MIT

Unpacked Size

5.6 kB

Total Files

6

Last publish

Collaborators

  • mogeko