pax_global_header00006660000000000000000000000064137411531560014520gustar00rootroot0000000000000052 comment=eb9663c8e9cd3b4ae1b9438916d1fc29991387e0 is-plain-obj-3.0.0/000077500000000000000000000000001374115315600140045ustar00rootroot00000000000000is-plain-obj-3.0.0/.editorconfig000066400000000000000000000002571374115315600164650ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 is-plain-obj-3.0.0/.gitattributes000066400000000000000000000000231374115315600166720ustar00rootroot00000000000000* text=auto eol=lf is-plain-obj-3.0.0/.github/000077500000000000000000000000001374115315600153445ustar00rootroot00000000000000is-plain-obj-3.0.0/.github/funding.yml000066400000000000000000000001661374115315600175240ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/is-plain-obj custom: https://sindresorhus.com/donate is-plain-obj-3.0.0/.github/security.md000066400000000000000000000002631374115315600175360ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. is-plain-obj-3.0.0/.gitignore000066400000000000000000000000271374115315600157730ustar00rootroot00000000000000node_modules yarn.lock is-plain-obj-3.0.0/.npmrc000066400000000000000000000000231374115315600151170ustar00rootroot00000000000000package-lock=false is-plain-obj-3.0.0/.travis.yml000066400000000000000000000000661374115315600161170ustar00rootroot00000000000000language: node_js node_js: - '14' - '12' - '10' is-plain-obj-3.0.0/index.d.ts000066400000000000000000000010671374115315600157110ustar00rootroot00000000000000/** Check if a value is a plain object. An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`. @example ``` import isPlainObject = require('is-plain-obj'); isPlainObject({foo: 'bar'}); //=> true isPlainObject(new Object()); //=> true isPlainObject(Object.create(null)); //=> true isPlainObject([1, 2, 3]); //=> false class Unicorn {} isPlainObject(new Unicorn()); //=> false ``` */ declare function isPlainObject(value: unknown): value is Record; export = isPlainObject; is-plain-obj-3.0.0/index.js000066400000000000000000000003651374115315600154550ustar00rootroot00000000000000'use strict'; module.exports = value => { if (Object.prototype.toString.call(value) !== '[object Object]') { return false; } const prototype = Object.getPrototypeOf(value); return prototype === null || prototype === Object.prototype; }; is-plain-obj-3.0.0/index.test-d.ts000066400000000000000000000005111374115315600166570ustar00rootroot00000000000000import {expectAssignable} from 'tsd'; import isPlainObject = require('.'); const foo = 'foo'; if (isPlainObject(foo)) { expectAssignable>(foo); expectAssignable>(foo); expectAssignable>(foo); expectAssignable>(foo); } is-plain-obj-3.0.0/license000066400000000000000000000021351374115315600153520ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-plain-obj-3.0.0/package.json000066400000000000000000000012301374115315600162660ustar00rootroot00000000000000{ "name": "is-plain-obj", "version": "3.0.0", "description": "Check if a value is a plain object", "license": "MIT", "repository": "sindresorhus/is-plain-obj", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "engines": { "node": ">=10" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "object", "is", "check", "test", "type", "plain", "vanilla", "pure", "simple" ], "devDependencies": { "ava": "^2.4.0", "tsd": "^0.13.1", "xo": "^0.33.1" } } is-plain-obj-3.0.0/readme.md000066400000000000000000000023161374115315600155650ustar00rootroot00000000000000# is-plain-obj [![Build Status](https://travis-ci.com/sindresorhus/is-plain-obj.svg?branch=master)](https://travis-ci.com/github/sindresorhus/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 ```js const isPlainObject = require('is-plain-obj'); isPlainObject({foo: 'bar'}); //=> true isPlainObject(new Object()); //=> true isPlainObject(Object.create(null)); //=> true isPlainObject([1, 2, 3]); //=> false class Unicorn {} isPlainObject(new Unicorn()); //=> false ``` ## Related - [is-obj](https://github.com/sindresorhus/is-obj) - Check if a value is an object - [is](https://github.com/sindresorhus/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.
is-plain-obj-3.0.0/test.js000066400000000000000000000021131374115315600153160ustar00rootroot00000000000000import test from 'ava'; import isPlainObject from '.'; function Foo(x) { this.x = x; } function ObjectConstructor() {} ObjectConstructor.prototype.constructor = Object; test('main', t => { t.true(isPlainObject({})); t.true(isPlainObject({foo: true})); t.true(isPlainObject({constructor: Foo})); t.true(isPlainObject({valueOf: 0})); t.true(isPlainObject(Object.create(null))); t.true(isPlainObject(new Object())); // eslint-disable-line no-new-object t.false(isPlainObject(['foo', 'bar'])); t.false(isPlainObject(new Foo(1))); t.false(isPlainObject(Math)); t.false(isPlainObject(Error)); t.false(isPlainObject(() => {})); t.false(isPlainObject(/./)); t.false(isPlainObject(null)); t.false(isPlainObject(undefined)); t.false(isPlainObject(Number.NaN)); t.false(isPlainObject('')); t.false(isPlainObject(0)); t.false(isPlainObject(false)); t.false(isPlainObject(new ObjectConstructor())); (function () { t.false(isPlainObject(arguments)); // eslint-disable-line prefer-rest-params })(); const foo = new Foo(); foo.constructor = Object; t.false(isPlainObject(foo)); });