trackable-object
v1.0.5
Published
track object changes deeply
Downloads
2
Maintainers
Readme
Trackable Object (Up your object limits 🐢)
Track object deeply 🔍 so you can check if it changed or any of it's nested properties had changed.
Installation
CDN
<script src="https://cdn.jsdelivr.net/npm/trackable-object@latest/build/trackable-object.js"></script>
NPM
npm i trackable-object
How it works?
<script src="https://cdn.jsdelivr.net/npm/trackable-object@latest/build/trackable-object.js"></script>
<script>
const parentTO = TrackableObject.create({
name:'parent_name'
});
parentTO.name = 'parent_name_updated';
console.log(trackableObject.t_changes()); // Output: {name : 'parent_name_updated'}
console.log(JSON.stringify(person)); // and you can serialize your object as well
</script>
Use Cases:
- Check if the property changed before sending another request so will save the APIs cost.
- Warning the client before leaving regarding he can loss his changes.
Notes:
- If your object property get back to the old value then will not be exists in the
t_changes()
output.
API
| Name | Description | Type | | :------: | :--------------------------------------------: | :-------------------------: | | t_changes | Get all the changed properties | function():Map<string,string> |