Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-promise-like

Package Overview
Dependencies
Maintainers
2
Versions
505
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-promise-like

Identifies a Promise or an object with a Promise-like interface

  • 1.0.33
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by71.43%
Maintainers
2
Weekly downloads
 
Created
Source

IsPromiseLike

Usage

import {
  isPromise,
  isPromiseLike
} from 'is-promise-like'

isPromise identifies instances of the global Promise class.

isPromiseLike identifies instances of the global Promise class or other objects which are like them.

Examples: isPromise

Returns true:

const p = new Promise(() => {})

isPromise(p) // true
const p = Promise.resolve({})

isPromise(p) // true
const p = Promise.all([])

isPromise(p) // true

Anything else should return false.

Examples: isPromiseLike

All of the preceding examples returning true. In addition:

class S {
  static then () {}
}

isPromiseLike(S) // true
class S {
  then () {}
}

const s = new S()

isPromiseLike(s) // true
const o = {}
o.then = () => {}

isPromiseLike(o) // true
const a = []
a.then = () => {}

isPromiseLike(a) // true

And similar constructions for other types. Anything else should return false.

FAQs

Package last updated on 31 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc