This commit is contained in:
Lev
2021-06-16 19:39:43 -05:00
parent 2dc386e7fd
commit 51ce0e142a
2210 changed files with 263077 additions and 0 deletions

View File

@ -0,0 +1,29 @@
/**
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 isPlainObj(value: unknown): value is object;
export = isPlainObj;

View File

@ -0,0 +1,10 @@
'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;
};

View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.

View File

@ -0,0 +1,70 @@
{
"_from": "is-plain-obj@^2.1.0",
"_id": "is-plain-obj@2.1.0",
"_inBundle": false,
"_integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
"_location": "/is-plain-obj",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "is-plain-obj@^2.1.0",
"name": "is-plain-obj",
"escapedName": "is-plain-obj",
"rawSpec": "^2.1.0",
"saveSpec": null,
"fetchSpec": "^2.1.0"
},
"_requiredBy": [
"/yargs-unparser"
],
"_resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
"_shasum": "45e42e37fccf1f40da8e5f76ee21515840c09287",
"_spec": "is-plain-obj@^2.1.0",
"_where": "C:\\Files\\Repositories\\UoL\\CM2010 Software Design and Development\\Topic 4\\8.3.1\\node_modules\\yargs-unparser",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/is-plain-obj/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Check if a value is a plain object",
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"engines": {
"node": ">=8"
},
"files": [
"index.js",
"index.d.ts"
],
"homepage": "https://github.com/sindresorhus/is-plain-obj#readme",
"keywords": [
"object",
"is",
"check",
"test",
"type",
"plain",
"vanilla",
"pure",
"simple"
],
"license": "MIT",
"name": "is-plain-obj",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/is-plain-obj.git"
},
"scripts": {
"test": "xo && ava && tsd"
},
"version": "2.1.0"
}

View File

@ -0,0 +1,54 @@
# is-plain-obj [![Build Status](https://travis-ci.org/sindresorhus/is-plain-obj.svg?branch=master)](https://travis-ci.org/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
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-is-plain-obj?utm_source=npm-is-plain-obj&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>