sindresorhus / P Time
Licence: mit
Measure the time a promise takes to resolve
Stars: ✭ 60
Programming Languages
javascript
184084 projects - #8 most used programming language
p-time
Measure the time a promise takes to resolve
Install
$ npm install p-time
Usage
const pTime = require('p-time');
const execa = require('execa');
(async () => {
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.
Related
License
MIT © Sindre Sorhus
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].