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

akuku

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akuku

Small timing counter utility.

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

NPM version Build Status Dependency Status Dev Dependency Status

akuku

Small timing counter utility. Uses process.hrtime to collect all time intervals between start and stop.

Install

$ npm install --save akuku

Usage

let tm = require('akuku')('module name'); // kind of like debug

let countSomething = tm.counter('something');

tm.start();
// do something

countSomething();

tm.stop();

next = tm.start(next);

doSomethingAsync(function() {

  countSomething(5); // you can optionally pass a bigger counter

  next();
});

// later

tm.dump(); // will print sum of times between start and stop, and all associated counters

Environment

The AKUKU environment variable has to be set to 1, on, or true to enable akuku timers and counters.

AKUKU=1 node myapp

When AKUKU is not defined or set to a falsy value akuku API is implemented using empty stubs.

API

start(next = undefined, count = 1)

Starts counting time - returns the stop function. If next is specified returns wrapped version of next that stops timer before calling next.

stop()

Stops counting time.

toString()

Displays formatted internal state - something like:

toObject()

Raw state:

  • active - sum of all intervals between start and stop as [ seconds, nano ] pair
  • counter - number of times start was called
  • activeNow - true if between start and stop when called
  • counters - additional counters as name => values object

counter(name)

Creates additional named counter. Returns counter function, which - whenever called - will increment internal counter named name Its value will become part of the state.

License

ICS © Damian Krzeminski

Keywords

FAQs

Package last updated on 03 Jun 2020

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