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

Comparing version 4.0.0 to 4.1.0

10

index.d.ts

@@ -9,2 +9,3 @@ /**

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

@@ -20,2 +21,6 @@ isPlainObject({foo: 'bar'});

// This works across realms
isPlainObject(runInNewContext('({})'));
//=> true
isPlainObject([1, 2, 3]);

@@ -27,4 +32,7 @@ //=> false

//=> false
isPlainObject(Math);
//=> false
```
*/
export default function isPlainObject<Value>(value: unknown): value is Record<string | number | symbol, Value>;
export default function isPlainObject<Value>(value: unknown): value is Record<PropertyKey, Value>;

4

index.js
export default function isPlainObject(value) {
if (Object.prototype.toString.call(value) !== '[object Object]') {
if (typeof value !== 'object' || value === null) {
return false;

@@ -7,3 +7,3 @@ }

const prototype = Object.getPrototypeOf(value);
return prototype === null || prototype === Object.prototype;
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
}
{
"name": "is-plain-obj",
"version": "4.0.0",
"version": "4.1.0",
"description": "Check if a value is a plain object",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -17,2 +17,3 @@ # is-plain-obj

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

@@ -28,2 +29,6 @@ isPlainObject({foo: 'bar'});

// This works across realms
isPlainObject(runInNewContext('({})'));
//=> true
isPlainObject([1, 2, 3]);

@@ -35,2 +40,5 @@ //=> false

//=> false
isPlainObject(Math);
//=> false
```

@@ -37,0 +45,0 @@

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