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

defer-promise

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defer-promise

Isomorphic function returning a deferred promise. Uses native `Promise.defer` if available, else polyfills.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.8K
decreased by-81.85%
Maintainers
1
Weekly downloads
 
Created
Source

view on npm npm module month Build Status Dependency Status js-standard-style

defer-promise

Isomorphic function returning a deferred promise with resolve and reject methods. If the global Promise.defer() method exists it will use that, else polyfill.

const defer = require('defer-promise')
const deferred = defer()

doSomething((result, err) => {
  if (err) {
    deferred.reject(err)
  } else {
    deferred.resolve(result)
  }
})

return deferred.promise;

Load anywhere

This library can be loaded anywhere, natively without transpilation.

Node.js:

const defer = require('defer-promise')

Node.js with ECMAScript Module support enabled:

import defer from 'defer-promise'

Modern browser ECMAScript Module:

import defer from './node_modules/defer-promise/index.mjs'

Old browser (adds window.defer):

<script nomodule src="./node_modules/defer-promise/dist/index.js"></script>

© 2015-18 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Keywords

FAQs

Package last updated on 14 Dec 2018

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