p-is-promise
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -1,23 +0,16 @@ | ||
declare const pIsPromise: { | ||
/** | ||
Check if `input` is a ES2015 promise. | ||
/** | ||
Check if `value` is a ES2015 promise. | ||
@param input - Value to be checked. | ||
@param value - Value to be checked. | ||
@example | ||
``` | ||
import isPromise = require('p-is-promise'); | ||
@example | ||
``` | ||
import isPromise = require('p-is-promise'); | ||
isPromise(Promise.resolve('🦄')); | ||
//=> true | ||
``` | ||
*/ | ||
(input: unknown): input is Promise<unknown>; | ||
isPromise(Promise.resolve('🦄')); | ||
//=> true | ||
``` | ||
*/ | ||
declare function pIsPromise(value: unknown): value is Promise<unknown>; | ||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function pIsPromise(input: unknown): input is Promise<unknown>; | ||
// export = pIsPromise; | ||
default: typeof pIsPromise; | ||
}; | ||
export = pIsPromise; |
18
index.js
'use strict'; | ||
const isPromise = input => ( | ||
input instanceof Promise || | ||
const isObject = value => value !== null && | ||
(typeof value === 'object' || typeof value === 'function'); | ||
module.exports = value => ( | ||
value instanceof Promise || | ||
( | ||
input !== null && | ||
typeof input === 'object' && | ||
typeof input.then === 'function' && | ||
typeof input.catch === 'function' | ||
isObject(value) && | ||
typeof value.then === 'function' && | ||
typeof value.catch === 'function' | ||
) | ||
); | ||
module.exports = isPromise; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = isPromise; |
{ | ||
"name": "p-is-promise", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Check if something is a promise", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
@@ -38,7 +38,12 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"ava": "^2.1.0", | ||
"bluebird": "^3.5.4", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"promise/prefer-await-to-then": "off" | ||
} | ||
} | ||
} |
@@ -39,6 +39,1 @@ # p-is-promise [![Build Status](https://travis-ci.org/sindresorhus/p-is-promise.svg?branch=master)](https://travis-ci.org/sindresorhus/p-is-promise) | ||
- [More…](https://github.com/sindresorhus/promise-fun) | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
3312
23
39