1.0.1 • Published 4 years ago

opti-status v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

opti-status

NPM version

Get the optimization status of a function from the point of view of V8 engine.

Installation

$ npm install opti-status

Usage

const optiStatus = require("opti-status");

const myFunc = () => {
    // ...
};

console.log(optiStatus(myFunc).message);

API

optiStatus(func, [...args])

The main function accept a function or a string as first argument and as many additional arguments as you want. The passed function will be called with the additional arguments as parameters. Return an object containing the original status code, the passed function and a human readable message explaining the status.

example:

{
    status: 49,
    function: [Function],
    message: "This is a function, optimized and turbo-fanned.",
}

optiStatus.statuses

The set of possible statuses according to V8. You need to use a bitwise comparison of the status code to know if each flag is active or not.

example:

if (optiStatus(func).status & optiStatus.statuses.isOptimized) {
    console.log("Great work!");
}

License

MIT