MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / getStandardLibrary

Function getStandardLibrary

src/compute-engine/library/library.ts:337–352  ·  view source on GitHub ↗
(
  categories?: LibraryCategory[] | LibraryCategory | 'all'
)

Source from the content-addressed store, hash-verified

335 * Topological sort of libraries that keeps the input order wherever the
336 * dependencies allow it.
337 *
338 * The libraries are visited in input order. Before a library is added, each
339 * library in its `requires` list is visited (and added) first, also in order.
340 * As a result, a library comes after every library listed before it in the
341 * input, unless an earlier library requires it: then it moves ahead of the
342 * first library that requires it. A caller library listed after
343 * the standard libraries, which no standard library requires, thus loads after
344 * them, even when it has no `requires` list: its definitions can use operators
345 * such as `Loop` (from `control-structures`) without declaring them.
346 *
347 * Throws on a duplicate name, a cycle or a missing dependency.
348 */
349export function sortLibraries(libs: LibraryDefinition[]): LibraryDefinition[] {
350 const byName = new Map<string, LibraryDefinition>();
351 for (const lib of libs) {
352 if (byName.has(lib.name))
353 throw new Error(`Duplicate library name: "${lib.name}"`);
354 byName.set(lib.name, lib);
355 }

Callers 3

getStandardLibraryMethod · 0.90
buildPayloadFunction · 0.85

Calls 3

sortLibrariesFunction · 0.85
findMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected