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

contimer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contimer

Routines to measure time in the context of an object.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
438
decreased by-19.04%
Maintainers
1
Weekly downloads
 
Created
Source

contimer

var timer = require('contimer'),
    connect = require('connect');

connect(
    function (req, res, next) {
        timer.start(req, 'total');
        next();
    },
    function (req, res, next) {
        var time = timer.stop(req, 'total').time;

        res.end('Response processing time: ' + time + 'ms');
    }
).listen(8080);

Methods

hook()

hook(handler) → {Object}

  • {Function} handler — callback with signature function(id, time).

Setups the handler as the callback for the stop() method.

start()

start(context, label) → {Function}

  • {Object} context — Object, which will be used as context;
  • {String} label — Timed identifier, must be unique in the context.

Creates new timer in the context.

Be aware, that start() creates non-enumerable property __sw_timers in the context object to store timestamps.

Method returns function, which can be used to stop created timer without passing any arguments to it. Or you can call the stop() method with the same arguments to stop timer.

stop()

stop(context, label) → {{ label: String, time: Number }}

Keywords

FAQs

Package last updated on 09 Jul 2014

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