Wrap mutant. Utils
Object mutation is easy and extremelly fast. But such libraries like react make us to rebuild objects on every their change. It's not a problem on simple and small objects. When your object is a big array, your application become slow. When you are trying to handle complicated deeply nested object, it becomes a brain cancer.
Solution is in wrapping that big or complex objects into Proxy object.
Examples
reactflow example [demo | repo]
pravosleva's substring-highlight-sample [demo | repo]
This package contains utility toolbox created to simplify your life and this library usage and solve some regular problems
bindCallables
import { bindCallables } from "@wrap-mutant/utils";
Unfortunally there is a negative effect of wrapping objects into Proxy object -- the wrapped object's methods loose their's this
. So, if you have wrapped the object and got an error like this is undefined
-- just bind the callables. Avoid to bind callables of your target more then once
API reference:
-
Required target:
any extends Object
. It may be anArray
or its subclass, any kind ofObject
, anyfunction
, anyclass
constructor or instance
Any questions?
Don't be afraid to open this library source code -- it's really small. Also we have Telegram Community