mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 14:54:12 +00:00
Revert branch to cb6e80a645 (#257)
This commit is contained in:
@@ -1,56 +1,55 @@
|
||||
/** Temporary workaround until downstream consumers migrate to Map. A brittle wrapper with many flaws, but should be fine for simple maps using int indexes. */
|
||||
export class MapProxyHandler<V> implements ProxyHandler<Map<number | string, V>> {
|
||||
getOwnPropertyDescriptor(target: Map<number | string, V>, p: string | symbol): PropertyDescriptor | undefined {
|
||||
const value = this.get(target, p)
|
||||
if (value)
|
||||
return {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value
|
||||
}
|
||||
}
|
||||
getOwnPropertyDescriptor(target: Map<number | string, V>, p: string | symbol): PropertyDescriptor | undefined {
|
||||
const value = this.get(target, p)
|
||||
if (value) return {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
has(target: Map<number | string, V>, p: string | symbol): boolean {
|
||||
if (typeof p === 'symbol') return false
|
||||
has(target: Map<number | string, V>, p: string | symbol): boolean {
|
||||
if (typeof p === "symbol") return false
|
||||
|
||||
const int = parseInt(p, 10)
|
||||
return target.has(!isNaN(int) ? int : p)
|
||||
}
|
||||
const int = parseInt(p, 10)
|
||||
return target.has(!isNaN(int) ? int : p)
|
||||
}
|
||||
|
||||
ownKeys(target: Map<number | string, V>): ArrayLike<string | symbol> {
|
||||
return [...target.keys()].map((x) => String(x))
|
||||
}
|
||||
ownKeys(target: Map<number | string, V>): ArrayLike<string | symbol> {
|
||||
return [...target.keys()].map(x => String(x))
|
||||
}
|
||||
|
||||
get(target: Map<number | string, V>, p: string | symbol): any {
|
||||
// Workaround does not support link IDs of "values", "entries", "constructor", etc.
|
||||
if (p in target) return Reflect.get(target, p, target)
|
||||
if (typeof p === 'symbol') return
|
||||
get(target: Map<number | string, V>, p: string | symbol): any {
|
||||
// Workaround does not support link IDs of "values", "entries", "constructor", etc.
|
||||
if (p in target) return Reflect.get(target, p, target)
|
||||
if (typeof p === "symbol") return
|
||||
|
||||
const int = parseInt(p, 10)
|
||||
return target.get(!isNaN(int) ? int : p)
|
||||
}
|
||||
const int = parseInt(p, 10)
|
||||
return target.get(!isNaN(int) ? int : p)
|
||||
}
|
||||
|
||||
set(target: Map<number | string, V>, p: string | symbol, newValue: any): boolean {
|
||||
if (typeof p === 'symbol') return false
|
||||
set(target: Map<number | string, V>, p: string | symbol, newValue: any): boolean {
|
||||
if (typeof p === "symbol") return false
|
||||
|
||||
const int = parseInt(p, 10)
|
||||
target.set(!isNaN(int) ? int : p, newValue)
|
||||
return true
|
||||
}
|
||||
const int = parseInt(p, 10)
|
||||
target.set(!isNaN(int) ? int : p, newValue)
|
||||
return true
|
||||
}
|
||||
|
||||
deleteProperty(target: Map<number | string, V>, p: string | symbol): boolean {
|
||||
return target.delete(p as number | string)
|
||||
}
|
||||
deleteProperty(target: Map<number | string, V>, p: string | symbol): boolean {
|
||||
return target.delete(p as number | string)
|
||||
}
|
||||
|
||||
static bindAllMethods(map: Map<any, any>): void {
|
||||
map.clear = map.clear.bind(map)
|
||||
map.delete = map.delete.bind(map)
|
||||
map.forEach = map.forEach.bind(map)
|
||||
map.get = map.get.bind(map)
|
||||
map.has = map.has.bind(map)
|
||||
map.set = map.set.bind(map)
|
||||
map.entries = map.entries.bind(map)
|
||||
map.keys = map.keys.bind(map)
|
||||
map.values = map.values.bind(map)
|
||||
}
|
||||
static bindAllMethods(map: Map<any, any>): void {
|
||||
map.clear = map.clear.bind(map)
|
||||
map.delete = map.delete.bind(map)
|
||||
map.forEach = map.forEach.bind(map)
|
||||
map.get = map.get.bind(map)
|
||||
map.has = map.has.bind(map)
|
||||
map.set = map.set.bind(map)
|
||||
map.entries = map.entries.bind(map)
|
||||
map.keys = map.keys.bind(map)
|
||||
map.values = map.values.bind(map)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user