Skip to content

paz-raon/node-wraptime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-wraptime

This package measures the execution time of a function.

Usage

const wrapAsync = require('node-wraptime').wrapAsync;

async function f() { return 1; }

wrapAsync(null, f)();

or

class Klass {
    constructor() {
        this.f = wrapAsync(this, this.f);
    }

    async f() { return 1; };
}

var k = new Klass();
k.f();

wrapAsync(thisArg, func, [customLoggingFunc])

Parameters

thisArg
    The value of this provided for the call to func.

func
    The function you want to measure.

customLoggingFunc

    ** example **
    ({ thisArg, func, result, args, time }) => {
        // thisArgs: arguments[0] of wrapAsync
        // func: arguments[1] of wrapAsync
        // result: return value of func
        // args: arguments of func
        // time: execution time
    }

Return value
    return value of func

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published