Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@stdlib/assert-is-plain-object
Advanced tools
@stdlib/assert-is-plain-object is a utility package that provides a function to check if a value is a plain object. A plain object is an object created by the Object constructor or with an object literal.
Check if a value is a plain object
This feature allows you to check if a given value is a plain object. In the code sample, the function `isPlainObject` is used to check if `obj` is a plain object, which returns `true`.
const isPlainObject = require('@stdlib/assert-is-plain-object');
const obj = { 'a': 1, 'b': 2 };
const result = isPlainObject(obj);
console.log(result); // true
Check if a non-object value is a plain object
This feature allows you to check if a non-object value is a plain object. In the code sample, the function `isPlainObject` is used to check if `notAnObject` is a plain object, which returns `false`.
const isPlainObject = require('@stdlib/assert-is-plain-object');
const notAnObject = 42;
const result = isPlainObject(notAnObject);
console.log(result); // false
Check if an array is a plain object
This feature allows you to check if an array is a plain object. In the code sample, the function `isPlainObject` is used to check if `arr` is a plain object, which returns `false`.
const isPlainObject = require('@stdlib/assert-is-plain-object');
const arr = [1, 2, 3];
const result = isPlainObject(arr);
console.log(result); // false
The `lodash.isplainobject` package is a utility from the Lodash library that checks if a value is a plain object. It is similar to `@stdlib/assert-is-plain-object` in functionality but is part of the larger Lodash utility library, which provides a wide range of utility functions for JavaScript.
The `is-plain-object` package is a standalone utility that checks if a value is a plain object. It is similar to `@stdlib/assert-is-plain-object` in that it focuses solely on determining if a value is a plain object, but it is a smaller, more focused package.
The `isobject` package is a utility that checks if a value is an object and not an array or null. While it is broader in scope than `@stdlib/assert-is-plain-object`, it can be used to achieve similar functionality by further checking if the object is a plain object.
Test if a value is a plain object.
npm install @stdlib/assert-is-plain-object
var isPlainObject = require( '@stdlib/assert-is-plain-object' );
Tests if a value
is a plain object
.
var bool = isPlainObject( {} );
// returns true
bool = isPlainObject( null );
// returns false
var isPlainObject = require( '@stdlib/assert-is-plain-object' );
var bool = isPlainObject( {} );
// returns true
bool = isPlainObject( Object.create( null ) );
// returns true
bool = isPlainObject( [] );
// returns false
bool = isPlainObject( null );
// returns false
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2021. The Stdlib Authors.
0.0.5 (2021-07-06)
No changes reported for this release.
</section> <!-- /.release --> <section class="release" id="v0.0.4">FAQs
Test if a value is a plain object.
The npm package @stdlib/assert-is-plain-object receives a total of 378,611 weekly downloads. As such, @stdlib/assert-is-plain-object popularity was classified as popular.
We found that @stdlib/assert-is-plain-object demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.