mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-11 14:02:37 +08:00
24 lines
440 B
JavaScript
24 lines
440 B
JavaScript
export function range(size, startAt = 0) {
|
|
return [...Array(size).keys()].map(i => i + startAt);
|
|
}
|
|
|
|
export function hook(klass, fnName, cb) {
|
|
const fnLocation = klass;
|
|
const orig = fnLocation[fnName];
|
|
fnLocation[fnName] = (...args) => {
|
|
cb(orig, ...args);
|
|
}
|
|
}
|
|
|
|
const a = {
|
|
b: (c, d, e) => {
|
|
console.log(c, d, e);
|
|
}
|
|
}
|
|
|
|
a.b(1,2,3)
|
|
hook(a, "b", (orig, c, d, e) => {
|
|
orig(c, d, e);
|
|
})
|
|
a.b(1,2,3)
|