sindresorhus/p-time

Measure the time a promise takes to resolve

73

stars

22

commits

JavaScript

primary language

Nov 5, 2023

updated

README

p-time

Measure the time a promise takes to resolve

Install

npm install p-time

Usage

import pTime from 'p-time';
import {execa} from 'execa';

const promise = pTime(execa)('sleep', ['1']);

await promise;
console.log(promise.time);
//=> 1016

API

pTime(asyncFunction)

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

pTime.log(asyncFunction)

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

asyncFunction

Type: Function

Promise-returning/async function.

Contributors

sindresorhus

18 commits

BendingBender

2 commits

Richienb

1 commits

sindresorhus/p-time

Measure the time a promise takes to resolve

73

stars

22

commits

JavaScript

primary language

Nov 5, 2023

updated

README

p-time

Measure the time a promise takes to resolve

Install

npm install p-time

Usage

import pTime from 'p-time';
import {execa} from 'execa';

const promise = pTime(execa)('sleep', ['1']);

await promise;
console.log(promise.time);
//=> 1016

API

pTime(asyncFunction)

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

pTime.log(asyncFunction)

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

asyncFunction

Type: Function

Promise-returning/async function.

Contributors

sindresorhus

18 commits

BendingBender

2 commits

Richienb

1 commits

Languages

JavaScript

84.6%

TypeScript

15.4%