@optimal/object
Force V8 to optimize an object's properties or check its status.
Use this when:
- the object ends up in slow mode
- 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)
- 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
var optimize = require('@optimal/object')
var object = {
key :'value',
some:'thing',
and :'more',
}
delete object.and
optimize(object)
var someOtherObject = getSomeOtherObject()
result = optimize.check(someOtherObject)
Others
- @optimal/fn
MIT License