Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

optical

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optical

Assert the optimisation status of a function in v8 given some arguments.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Optical

Assert the optimisation status of a function in v8 given some arguments.

Note: for this to work node must be run with the --allow_natives_syntax flag. See caveats.

API

optical(func, args, thisArg)

Prints the optimisation status of a function applied to the given arguments.

assertOptimized(func, args, thisArg)

Assert the optimisation status of a function applied to some arguments. Will throw an assertion error if the function is not optimised or will lkely be deoptimised.

Example

var optical = require('optical');

function myFunction(x, y) {
	return x + y;
}

optical.assertOptimized(myFunction, [10, 20]);

function notOptimized(x, y) {
	try {
       myFunction(x, y);
	} catch(e) {
    	console.log(e);
		throw e;
	}
}
// Throws assertion error, can't optimise method
// containing try/catch.
optical.assertOptimized(notOptimized, [10, 20]);

Caveats

  1. Node must be run with the --allow_natives_syntax flag.
  2. This only tests optimisation for given arguments, if your function is polymorphic you won't get a true representation of optimisation status here.

License

MIT

Keywords

FAQs

Package last updated on 08 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc