Skip to content
Measure the time a promise takes to resolve
JavaScript TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.npmrc
.travis.yml
index.d.ts
index.js
index.test-d.ts
license
package.json
readme.md
test.js

readme.md

p-time Build Status

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

You can’t perform that action at this time.