@risan/is-plain-obj

1.0.7 • Public • Published

Is Plain Object

Build Status Test Covarage Greenkeeper Latest Version

Check if a value is a plain JavaScript object

Installation

$ npm install @risan/is-plain-obj

CDN

The library is available over a CDN:

<script src="https://unpkg.com/@risan/is-plain-obj@latest/dist/is-plain-obj.umd.js"></script>

<!-- Or the minified version -->
<script src="https://unpkg.com/@risan/is-plain-obj@latest/dist/is-plain-obj.umd.min.js"></script>

Usage

const isPlainObj = require("@risan/is-plain-obj");

// The following statements will return TRUE:
isPlainObj({});
isPlainObj({ foo: "bar" });
isPlainObj(new Object());
isPlainObj(Object.create(null));
isPlainObj(Object.create({}));

// The following statements will return FALSE:
isPlainObj(undefined);
isPlainObj(null);
isPlainObj(true);
isPlainObj(3.14);
isPlainObj(NaN);
isPlainObj(Infinity);
isPlainObj("foo");
isPlainObj([1, 2, 3]);
isPlainObj(new Date());
isPlainObj(new Set([1, 2, 3]));
isPlainObj(new Map());
isPlainObj(new WeakMap());
isPlainObj(parseInt);

class Person {}
isPlainObj(new Person()); // FALSE

const myFunction = () => "foo";
isPlainObj(myFunction); // FALSE

If you load the library directly on the browser, it's available under the isPlainObj name.

window.isPlainObj({ foo: "bar" }); // TRUE

window.isPlainObj(new Date()); // FALSE

License

MIT © Risan Bagja Pradana

Package Sidebar

Install

npm i @risan/is-plain-obj

Weekly Downloads

135

Version

1.0.7

License

MIT

Unpacked Size

6.71 kB

Total Files

6

Last publish

Collaborators

  • risan