New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@optimal/object

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

@optimal/object

Force V8 to optimize an object's properties or check its status

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@optimal/object

Build Status Dependency Status npm version Coverage Status

Force V8 to optimize an object's properties or check its status.

Use this when:

  1. the object ends up in slow mode
  2. it's not possible to refactor code to avoid slow mode (such as defining all the properties on it ahead of time and only altering their values, not adding properties, and not deleting them)
  3. an object's properties are accessed often enough to affect performance

The optimization doesn't require '--allow_natives_syntax'; only the check does.

Check if an object's property access is in optimized mode with optimize.check(). This tries to enable the flag '--allow_natives_syntax', so, use in testing and performance benchmarking. (The flag is required in order to check the optimization status.)

See V8 test

Install

npm install @optimal/object --save

Usage

// 1. optimize a an object
var optimize = require('@optimal/object')

var object = {
  key :'value',
  some:'thing',
  and :'more',
}

// trigger slow mode
delete object.and

// back to fast access
optimize(object)

// 2. test an object to know if it's optimized:
var someOtherObject = getSomeOtherObject()
result = optimize.check(someOtherObject) // returns true or false

Others

  1. @optimal/fn

MIT License

Keywords

FAQs

Package last updated on 03 Jan 2017

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