MCPcopy
hub / github.com/shipshapecode/shepherd / autoBind

Function autoBind

shepherd.js/src/utils/auto-bind.ts:8–19  ·  view source on GitHub ↗
(self: any)

Source from the content-addressed store, hash-verified

6 */
7// eslint-disable-next-line @typescript-eslint/no-explicit-any
8export default function autoBind(self: any) {
9 const keys = Object.getOwnPropertyNames(self.constructor.prototype);
10 for (let i = 0; i < keys.length; i++) {
11 const key = keys[i] as keyof typeof self;
12 const val = self[key];
13 if (key !== 'constructor' && typeof val === 'function') {
14 self[key] = val.bind(self);
15 }
16 }
17
18 return self;
19}

Callers 3

constructorMethod · 0.85
constructorMethod · 0.85
constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected