Last active
November 2, 2023 14:56
-
-
Save AirStair/3fbfcd876190d8790028906017f74856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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