| 238 | * null. Undefined for a type this table does not know. |
| 239 | */ |
| 240 | export function goStdlibMethods(importPath: string | null, typeName: string): GoStdlibMethods | undefined { |
| 241 | if (importPath === null) return typeName === 'error' ? GO_ERROR_METHODS : undefined; |
| 242 | const key = `${importPath}.${typeName}`; |
| 243 | let methods = parsed.get(key); |
| 244 | if (methods === undefined) { |
| 245 | const listed = Object.prototype.hasOwnProperty.call(GO_STDLIB_METHODS, importPath) |
| 246 | ? GO_STDLIB_METHODS[importPath]![typeName] |
| 247 | : undefined; |
| 248 | methods = typeof listed === 'string' |
| 249 | ? new Map(listed.split(' ').map((entry) => entry.split(':') as [string, string])) |
| 250 | : null; |
| 251 | parsed.set(key, methods); |
| 252 | } |
| 253 | return methods ?? undefined; |
| 254 | } |