Initial commit
This commit is contained in:
commit
e49726988c
5445 files changed
+1089914
No files matched your search
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
Check if `value` is a ES2015 promise.
|
||||
|
||||
@param value - Value to be checked.
|
||||
|
||||
@example
|
||||
```
|
||||
import isPromise = require('p-is-promise');
|
||||
|
||||
isPromise(Promise.resolve('🦄'));
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
declare function pIsPromise(value: unknown): value is Promise<unknown>;
|
||||
|
||||
export = pIsPromise;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
const isObject = value => value !== null &&
|
||||
(typeof value === 'object' || typeof value === 'function');
|
||||
|
||||
module.exports = value => (
|
||||
value instanceof Promise ||
|
||||
(
|
||||
isObject(value) &&
|
||||
typeof value.then === 'function' &&
|
||||
typeof value.catch === 'function'
|
||||
)
|
||||
);
|
||||
+9
@@ -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.
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "p-is-promise",
|
||||
"version": "3.0.0",
|
||||
"description": "Check if something is a promise",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/p-is-promise",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"is",
|
||||
"detect",
|
||||
"check",
|
||||
"kind",
|
||||
"type",
|
||||
"thenable",
|
||||
"es2015",
|
||||
"async",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"bluebird": "^3.5.4",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"promise/prefer-await-to-then": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
# p-is-promise [](https://travis-ci.org/sindresorhus/p-is-promise)
|
||||
|
||||
> Check if something is a promise
|
||||
|
||||
Why not [`is-promise`](https://github.com/then/is-promise)? That module [checks for a thenable](https://github.com/then/is-promise/issues/6), not an ES2015 promise. This one is stricter.
|
||||
|
||||
You most likely don't need this. Just pass your value to `Promise.resolve()` and let it handle it.
|
||||
|
||||
Can be useful if you need to create a fast path for a synchronous operation.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install p-is-promise
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const pIsPromise = require('p-is-promise');
|
||||
const Bluebird = require('bluebird');
|
||||
|
||||
pIsPromise(Promise.resolve('🦄'));
|
||||
//=> true
|
||||
|
||||
pIsPromise(Bluebird.resolve('🦄'));
|
||||
//=> true
|
||||
|
||||
pIsPromise('🦄');
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [More…](https://github.com/sindresorhus/promise-fun)
|
||||
Reference in new issue
Block a user