Skip to content

Instantly share code, notes, and snippets.

@AirStair
Last active November 2, 2023 14:56
Show Gist options
  • Save AirStair/3fbfcd876190d8790028906017f74856 to your computer and use it in GitHub Desktop.
Save AirStair/3fbfcd876190d8790028906017f74856 to your computer and use it in GitHub Desktop.
export const createUpdateFunction = (updateArray = (entry, index) => {}, updateObject = (entry, key) => {}) => {
Object.assign(Array.prototype, {
toString() {
for (const index in this) {
updateArray(this, index);
this?.[index]?.toString();
}
}
});
Object.assign(Object.prototype, {
toString() {
for (const key in this) {
updateObject(this, key);
this?.[key]?.toString();
}
}
});
return arg => {
for (const key in arg) {
arg?.[key]?.toString();
}
Object.assign(Array.prototype, {
toString: Array.prototype.toString
});
Object.assign(Object.prototype, {
toString: Object.prototype.toString
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment