Socket
Socket
Sign inDemoInstall

is-plain-obj

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-plain-obj

Check if a value is a plain object


Version published
Maintainers
1
Install size
3.98 kB
Created

Package description

What is is-plain-obj?

The is-plain-obj package is a simple and lightweight npm package used to check if a given object is a plain object, that is, an object created by the Object constructor or one with a null prototype.

What are is-plain-obj's main functionalities?

Check if an object is a plain object

This feature allows you to verify if a given object is a plain object. It returns true for objects created by the Object constructor or with a null prototype and false for all other types of objects, such as instances of custom classes or built-in JavaScript objects like Map.

const isPlainObj = require('is-plain-obj');

console.log(isPlainObj({foo: 'bar'})); // true
console.log(isPlainObj(new Map())); // false

Other packages similar to is-plain-obj

Readme

Source

is-plain-obj

Check if a value is a plain object

An object is plain if it's created by either {}, new Object(), or Object.create(null).

Install

$ npm install is-plain-obj

Usage

import isPlainObject from 'is-plain-obj';
import {runInNewContext} from 'node:vm';

isPlainObject({foo: 'bar'});
//=> true

isPlainObject(new Object());
//=> true

isPlainObject(Object.create(null));
//=> true

// This works across realms
isPlainObject(runInNewContext('({})'));
//=> true

isPlainObject([1, 2, 3]);
//=> false

class Unicorn {}
isPlainObject(new Unicorn());
//=> false

isPlainObject(Math);
//=> false
  • is-obj - Check if a value is an object
  • is - Type check values

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 15 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc