0.0.5 • Published 6 years ago

node-wraptime v0.0.5

Weekly downloads
15
License
MIT
Repository
github
Last release
6 years ago

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
0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago