Socket
Socket
Sign inDemoInstall

p-is-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

8

index.d.ts
/**
Check if `value` is a ES2015 promise.
Check if a value is a promise.

@@ -8,3 +8,3 @@ @param value - Value to be checked.

```
import isPromise = require('p-is-promise');
import isPromise from 'p-is-promise';

@@ -15,4 +15,2 @@ isPromise(Promise.resolve('🦄'));

*/
declare function pIsPromise(value: unknown): value is Promise<unknown>;
export = pIsPromise;
export default function isPromise<T>(value: unknown): value is Promise<T>;

@@ -1,13 +0,11 @@

'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'
)
);
export default function isPromise(value) {
return value instanceof Promise ||
(
isObject(value) &&
typeof value.then === 'function' &&
typeof value.catch === 'function'
);
}
{
"name": "p-is-promise",
"version": "3.0.0",
"version": "4.0.0",
"description": "Check if something is a promise",
"license": "MIT",
"repository": "sindresorhus/p-is-promise",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -37,6 +40,6 @@ "scripts": {

"devDependencies": {
"ava": "^2.1.0",
"bluebird": "^3.5.4",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"bluebird": "^3.7.2",
"tsd": "^0.14.0",
"xo": "^0.38.2"
},

@@ -43,0 +46,0 @@ "xo": {

@@ -1,2 +0,2 @@

# p-is-promise [![Build Status](https://travis-ci.org/sindresorhus/p-is-promise.svg?branch=master)](https://travis-ci.org/sindresorhus/p-is-promise)
# p-is-promise

@@ -11,3 +11,2 @@ > Check if something is a promise

## Install

@@ -19,22 +18,33 @@

## Usage
```js
const pIsPromise = require('p-is-promise');
const Bluebird = require('bluebird');
import isPromise from 'p-is-promise';
import Bluebird from 'bluebird';
pIsPromise(Promise.resolve('🦄'));
isPromise(Promise.resolve('🦄'));
//=> true
pIsPromise(Bluebird.resolve('🦄'));
isPromise(Bluebird.resolve('🦄'));
//=> true
pIsPromise('🦄');
isPromise('🦄');
//=> false
```
## Related
- [is](https://github.com/sindresorhus/is) - Type check values
- [More…](https://github.com/sindresorhus/promise-fun)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-p-is-promise?utm_source=npm-p-is-promise&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>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc