node package manager

p-time

p-time Build Status

Measure the time a promise takes to resolve

Install

$ npm install --save p-time

Usage

const pTime = require('p-time');
const execa = require('execa');
 
const promise = pTime(execa)('sleep', ['1']);
 
promise.then(() => {
    console.log(promise.time);
    //=> 1016 
});

API

pTime(input)

Returns a decorated version of input that when called returns a Promise with a time property of the elapsed time in milliseconds.

pTime.log(input)

Returns a decorated version of input that when called logs the elapsed time in milliseconds of the Promise.

input

Type: Function

Promise-returning/async function.

Related

License

MIT © Sindre Sorhus