MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / dispose

Function dispose

packages/agent-core/src/di/lifecycle.ts:138–168  ·  view source on GitHub ↗
(
  arg: T | Iterable<T> | undefined,
)

Source from the content-addressed store, hash-verified

136 disposables: ReadonlyArray<T>,
137): ReadonlyArray<T>;
138export function dispose<T extends IDisposable>(
139 arg: T | Iterable<T> | undefined,
140): unknown {
141 if (arg === undefined || arg === null) return arg;
142 if (isIterable<T>(arg)) {
143 const errors: unknown[] = [];
144 for (const d of arg) {
145 if (d) {
146 try {
147 d.dispose();
148 } catch (error) {
149 errors.push(error);
150 }
151 }
152 }
153
154 if (errors.length === 1) {
155 throw errors[0];
156 }
157 if (errors.length > 1) {
158 throw new AggregateError(
159 errors,
160 'Encountered errors while disposing of store',
161 );
162 }
163
164 return Array.isArray(arg) ? [] : arg;
165 }
166 (arg).dispose();
167 return arg;
168}
169
170function isIterable<T>(arg: unknown): arg is Iterable<T> {
171 return (

Callers 15

disposeMethod · 0.90
createServicesFunction · 0.90
removePathsMethod · 0.90
forgetConnectionMethod · 0.90
disposeIfDisposableFunction · 0.70
combinedDisposableFunction · 0.70
clearMethod · 0.70
clearAndDisposeAllMethod · 0.70
clearAndDisposeAllMethod · 0.70
dance.test.tsFile · 0.50

Calls 6

isIterableFunction · 0.85
markAsDisposedFunction · 0.85
disposeMethod · 0.65
deleteMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected