Socket
Socket
Sign inDemoInstall

p-is-promise

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

p-is-promise

Check if something is a promise

    4.0.0latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
5,914,692
increased by2.01%

Weekly downloads

Package description

What is p-is-promise?

The p-is-promise npm package is a simple utility that allows you to check if a value is a Promise. This can be particularly useful when dealing with asynchronous operations in JavaScript, where you might need to differentiate between promises and other types of values.

What are p-is-promise's main functionalities?

Check if a value is a Promise

This feature allows you to easily determine whether a given value is a Promise. It's useful for conditional logic where the handling of a value depends on whether it's asynchronous (a Promise) or synchronous.

const pIsPromise = require('p-is-promise');

console.log(pIsPromise(Promise.resolve())); // true
console.log(pIsPromise('not a promise')); // false

Other packages similar to p-is-promise

Readme

Source

p-is-promise

Check if something is a promise

Why not is-promise? That module checks for a thenable, 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

import isPromise from 'p-is-promise';
import Bluebird from 'bluebird';

isPromise(Promise.resolve('🦄'));
//=> true

isPromise(Bluebird.resolve('🦄'));
//=> true

isPromise('🦄');
//=> false
  • is - Type check values
  • More…

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 16 Apr 2021

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

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