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

debug-promise

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debug-promise

Debug output outstanding promises, progress, errors, and resolution times.

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

debug-promise

debug-promise consumes promises and outputs logs showing their progress, their resolution or rejection, and makes state dumps showing all promises that have not settled.

How?

debug-promise can consume any type of promises, but for the sake of this example we'll use one from Kriskowal's Q Library.

var Q = require('Q');
var debug = require('debug-promise')('test-logger');
var defer = Q.defer();
debug(defer.promise, 'arbitrary promise name for logging');

// sometime in the future resolve that promise
setTimeout(function () {
  defer.resolve();
}, 10000);

debug-promise returns the original promise so you can easily chain like so:

debug(Q.resolve('value'), 'value promise').then(function (res) {
    // res === 'value'
});

Example output

  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 1		0 seconds

----------------------------

 +0ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 1		0.002 seconds
arbitrary promise label 2		0.001 seconds

----------------------------

 +3ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 1		0.003 seconds
arbitrary promise label 2		0.001 seconds
arbitrary promise label 3		0 seconds

----------------------------

 +0ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 1		0.003 seconds
arbitrary promise label 2		0.001 seconds
arbitrary promise label 3		0 seconds
arbitrary promise label 4		0 seconds

----------------------------

 +0ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 1		0.003 seconds
arbitrary promise label 2		0.001 seconds
arbitrary promise label 3		0 seconds
arbitrary promise label 4		0 seconds
arbitrary promise label 5		0.001 seconds

----------------------------

 +1ms
  debug-promise:test-logger progress (100): arbitrary promise label 1		0.004
 +0ms
  debug-promise:test-logger progress (undefined): arbitrary promise label 1		0.004
 +1ms
  debug-promise:test-logger resolved (undefined): arbitrary promise label 1		1.006
 +1s
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 2		1.004 seconds
arbitrary promise label 3		1.003 seconds
arbitrary promise label 4		1.003 seconds
arbitrary promise label 5		1.003 seconds

----------------------------

 +0ms
  debug-promise:test-logger rejected (undefined): arbitrary promise label 2		2.007
 +1s
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 3		2.006 seconds
arbitrary promise label 4		2.006 seconds
arbitrary promise label 5		2.006 seconds

----------------------------

 +0ms
  debug-promise:test-logger resolved (undefined): arbitrary promise label 3		3.001
 +995ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 4		3.002 seconds
arbitrary promise label 5		3.002 seconds

----------------------------

 +1ms
  debug-promise:test-logger rejected ('asdf'): arbitrary promise label 4		4.001
 +1s
  debug-promise:test-logger rejected ('asdf'): arbitrary promise label 5		4.002
 +0ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---

arbitrary promise label 5		4.002 seconds

----------------------------

 +0ms
  debug-promise:test-logger 
--- OUTSTANDING PROMISES ---


----------------------------

 +0ms

Keywords

FAQs

Package last updated on 07 Dec 2015

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