依赖文件
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Zhou Hancheng (z308114274@gmail.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.
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
# objectorarray
|
||||
[![npm version][1]][0] [![downloads][2]][0]
|
||||
|
||||
Is the value an object or an array but not null or RegExp?
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ yarn add objectorarray
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import objectorarray from 'objectorarray'
|
||||
```
|
||||
|
||||
### True
|
||||
|
||||
All of the following return true:
|
||||
|
||||
```js
|
||||
objectorarray({})
|
||||
objectorarray([])
|
||||
objectorarray(Object.create({}))
|
||||
objectorarray(Object.create(Object.prototype))
|
||||
objectorarray(Object.create(null))
|
||||
objectorarray(new Foo)
|
||||
```
|
||||
|
||||
### False
|
||||
|
||||
All of the following return false:
|
||||
|
||||
```js
|
||||
objectorarray()
|
||||
objectorarray(function () {})
|
||||
objectorarray(1)
|
||||
objectorarray(/foo/)
|
||||
objectorarray(undefined)
|
||||
objectorarray(null)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
[0]: https://npmjs.org/package/objectorarray
|
||||
[1]: https://img.shields.io/npm/v/objectorarray.svg?style=flat-square
|
||||
[2]: http://img.shields.io/npm/dm/objectorarray.svg?style=flat-square
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
module.exports = (val) => {
|
||||
return val != null && typeof val === 'object' && val.constructor !== RegExp
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "objectorarray",
|
||||
"version": "1.0.5",
|
||||
"description": "Is the value an object or an array but not null?",
|
||||
"scripts": {
|
||||
"test": "tape test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ZhouHansen/objectnotnull.git"
|
||||
},
|
||||
"keywords": [
|
||||
"javascript"
|
||||
],
|
||||
"author": {
|
||||
"name": "zhouhancheng",
|
||||
"email": "z308114274@gmail.com"
|
||||
},
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ZhouHansen/objectnotnull/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ZhouHansen/objectnotnull#readme",
|
||||
"devDependencies": {
|
||||
"tape": "^4.8.0"
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
var test = require('tape')
|
||||
var objectorarray = require('./')
|
||||
|
||||
test('objectorarray', t => {
|
||||
t.plan(12)
|
||||
|
||||
t.ok(objectorarray({}))
|
||||
t.ok(objectorarray([]))
|
||||
t.ok(objectorarray(Object.create({})))
|
||||
t.ok(objectorarray(Object.create(Object.prototype)))
|
||||
t.ok(objectorarray(Object.create(null)))
|
||||
t.ok(objectorarray(new Foo))
|
||||
function Foo (bar) {
|
||||
this.bar = bar
|
||||
}
|
||||
|
||||
t.notOk(objectorarray())
|
||||
t.notOk(objectorarray(function () {}))
|
||||
t.notOk(objectorarray(1))
|
||||
t.notOk(objectorarray(/foo/))
|
||||
t.notOk(objectorarray(null))
|
||||
t.notOk(objectorarray(undefined))
|
||||
})
|
||||
Reference in New Issue
Block a user