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

callback-timer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-timer

Helper method to wrap callback for logging timing info

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

callback-timer

  var wrap = require('callback-timer').wrap;

  var myWrappedCallback = wrap({
    tag: 'myModule',
    methodName: 'myAsynchronousCall',
    maxTimeWarning: 500
  }, myOriginalCallback);

  //output timing info to console.warn when myAsynchronousCall takes over 500 ms
  myModule.myAsynchronousCall(myWrappedCallback);
  //[myModule] Call (myAsynchronousCall) took longer than 0.5 seconds - 0.671 seconds

wrap ( config, callback ): Function

Wrap a callback function to add timing and logging asyncronous calls

Parameters:

  • config: Object
    • Configuration for the logging and callback
      • context: Object
        • Context to run the callback function in
        • default: null
      • logger: Object
        • Logging utility with a warn method
        • default: console
      • maxTimeWarning: Number
        • Time in ms to determine if a call is too slow. Will not log if call is faster. Will always log if 0.
        • default: 0
      • tag: Array | String
        • Value to show in [] before log message.
        • default ''
      • methodName: String
        • Name of the method to display in the log
        • default: ''
      • useRelativeTime: Boolean
        • Display the time in (X minutes Y seconds) or (X.YYY) seconds.
        • Default: true
    • callback: Function
      • Function to wrap

Returns: Function

  • Wrapped Callback

FAQs

Package last updated on 30 Nov 2019

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