- Cache getters and property descriptors using weakmaps to reduce property lookup overhead.
- Log a warning message on the console if it tries to set a Sakota wrapped object as value.
- Fix an issue where proxied object does not have any methods from
Object.prototype
- Add support for javascript getters, previously it used to get called using original values.
const proxy = Sakota.create({
x: 1,
get xx() {
return Math.pow(this.x, 2);
},
})
proxy.x = 10;
console.log(proxy.xx) // 100
- Add a method
cloneProxy
to clone a sakota proxy.
const proxy = Sakota.create({ foo: 'bar' })
const clone = proxy.__sakota__.cloneProxy();
- Allow changs to be filtered with a regular expression in
getChanges
and hasChanges
methods.
const proxy = Sakota.create({ foo: 'bar' })
proxy.x = 100;
proxy.y = 200;
proxy.z = 400;
proxy.__sakota__.hasChanges(/x/) // true
proxy.__sakota__.getChanges(/(x|y)/) // { $set: { x: 100, y: 200 } }
- Fixed a bug with
getChanges
method result cache used when the prefix changes.
- Added a
hasChanges
method to check whether the proxy has any changes
const proxy = Sakota.create({ foo: 'bar' })
proxy.x = 100;
proxy.__sakota__.hasChanges(/x/) // true
proxy.__sakota__.hasChanges(/y/) // false
- Cached
getChanges
method result to improve performance
const proxy = Sakota.create({ foo: 'bar' })
proxy.x = 100;
proxy.__sakota__.getChanges(/x/) // { $set: { x: 100 } }
proxy.__sakota__.getChanges(/y/) // {}
- Fixed a bug with tracking changes when deleting newly added property
- Removed the
Sakota.changes
method. It used to be the only way to get changes from the proxy.
- The handler can be accessed with the string key
__sakota__
the handler has a getChanges
method.
- Added the type
Proxied<T>
which will add the __sakota__
property to the proxied object type.