feat(pkg): Add core extensions package

This commit is contained in:
T. R. Bernstein
2025-04-21 01:46:55 +02:00
parent 7fd56d9e6c
commit 1ba1659600
6 changed files with 271 additions and 141 deletions

View File

@@ -0,0 +1,21 @@
declare global {
interface Object {
map<T, U>(
this: Record<string, T>,
callback: (value: T, key: string, obj: Record<string, T>) => U
): Record<string, U>
}
}
Object.prototype.map = function <T, U>(
this: Record<string, T>,
callback: (value: T, key: string, obj: Record<string, T>) => U
): Record<string, U> {
const result: Record<string, U> = {}
for (const [key, value] of Object.entries(this)) {
result[key] = callback(value, key, this)
}
return result
}
export {}