logical.ConsumerImporttypeno test imports ittype ConsumerImport = { readonly library: string; readonly subpath: string | undefined; readonly file: string };One import of a library of the package by a file of the consumer.
What a consumer uses of the package @intellectual-frontiers/commons (commons repoctl 0014-repoctl-usage; commons 0036-distribution FR-034): the libraries a repository imports and with which subpaths, read from its own files; the graph of the package, read from the sources of the installed copy (which library imports which, the files and bytes of each); and the answer, a pure function of the two: the libraries imported directly, those reached only through the imports of those, and those never touched, with their sizes.
The answer is the same for the same inputs and is in the order of the names of the libraries. A library the repository imports that the package does not hold is a finding and is not counted; a library reached by two paths names the one through which it is reached first, in the order of the names.
import { consumerImports, usageOf } from "./usage.ts";
consumerImports('import { ok } from "@intellectual-frontiers/commons/core";', "a.ts", "@intellectual-frontiers/commons");
// [{ library: "core", subpath: undefined, file: "a.ts" }]logical.ConsumerImporttypeno test imports ittype ConsumerImport = { readonly library: string; readonly subpath: string | undefined; readonly file: string };One import of a library of the package by a file of the consumer.
logical.PackageLibrarytypeno test imports ittype PackageLibrary = { readonly name: string; readonly imports: readonly string[]; readonly files: number; readonly bytes: number };A library of the package: the libraries its sources import, its files and its bytes.
logical.consumerImportsfunctionno test imports itfunction consumerImports(text: string, file: string, packageName: string): readonly ConsumerImport[]The libraries a file imports from the package: each specifier <package>/<library>[/<subpath>]; the bare package names no library and is left out.
logical.libraryImportsfunctionno test imports itfunction libraryImports(text: string, self: string, packageName: string, known: ReadonlySet<string>): readonly string[]The libraries of the package that a source imports: the specifiers <package>/<library>... (and @intellectual-frontiers/<library>... as the sources of a library write them), other than the library itself.
logical.Directtypeno test imports ittype Direct = { readonly library: string; readonly subpaths: readonly string[]; readonly files: number; readonly bytes: number };What the repository imports of one library.
logical.Reachedtypeno test imports ittype Reached = { readonly library: string; readonly via: string; readonly bytes: number };A library the repository reaches only through others.
logical.Untouchedtypeno test imports ittype Untouched = { readonly library: string; readonly bytes: number };A library the repository never touches.
logical.UsageReporttypeno test imports ittype UsageReport = {
readonly package: string;
readonly libraries: number;
readonly bytes: number;
readonly dire… (607 characters)type UsageReport = {
readonly package: string;
readonly libraries: number;
readonly bytes: number;
readonly direct: readonly Direct[];
readonly reached: readonly Reached[];
readonly untouched: readonly Untouched[];
readonly totals: {
readonly direct: { readonly libraries: number; readonly bytes: number };
readonly reached: { readonly libraries: number; readonly bytes: number };
readonly untouched: { readonly libraries: number; readonly bytes: number };
};
/** The libraries the repository imports that the package does not hold. */
readonly unknown: readonly string[];
};The answer.
logical.usageOffunctionno test imports itfunction usageOf(packageName: string, imports: readonly ConsumerImport[], graph: readonly PackageLibrary[]): UsageReportThe answer for the imports of a repository and the graph of a package.
logical.usageTextfunctionno test imports itfunction usageText(r: UsageReport): stringThe answer as text: the three groups with their sizes, and the libraries of each.
ConsumerImporttypeno test imports ittype ConsumerImport = { readonly library: string; readonly subpath: string | undefined; readonly file: string };One import of a library of the package by a file of the consumer.
PackageLibrarytypetype PackageLibrary = { readonly name: string; readonly imports: readonly string[]; readonly files: number; readonly bytes: number };A library of the package: the libraries its sources import, its files and its bytes.
consumerImportsfunctionfunction consumerImports(text: string, file: string, packageName: string): readonly ConsumerImport[]The libraries a file imports from the package: each specifier <package>/<library>[/<subpath>]; the bare package names no library and is left out.
libraryImportsfunctionfunction libraryImports(text: string, self: string, packageName: string, known: ReadonlySet<string>): readonly string[]The libraries of the package that a source imports: the specifiers <package>/<library>... (and @intellectual-frontiers/<library>... as the sources of a library write them), other than the library itself.
Directtypeno test imports ittype Direct = { readonly library: string; readonly subpaths: readonly string[]; readonly files: number; readonly bytes: number };What the repository imports of one library.
Reachedtypeno test imports ittype Reached = { readonly library: string; readonly via: string; readonly bytes: number };A library the repository reaches only through others.
Untouchedtypeno test imports ittype Untouched = { readonly library: string; readonly bytes: number };A library the repository never touches.
UsageReporttypeno test imports ittype UsageReport = {
readonly package: string;
readonly libraries: number;
readonly bytes: number;
readonly dire… (607 characters)type UsageReport = {
readonly package: string;
readonly libraries: number;
readonly bytes: number;
readonly direct: readonly Direct[];
readonly reached: readonly Reached[];
readonly untouched: readonly Untouched[];
readonly totals: {
readonly direct: { readonly libraries: number; readonly bytes: number };
readonly reached: { readonly libraries: number; readonly bytes: number };
readonly untouched: { readonly libraries: number; readonly bytes: number };
};
/** The libraries the repository imports that the package does not hold. */
readonly unknown: readonly string[];
};The answer.
usageOffunctionfunction usageOf(packageName: string, imports: readonly ConsumerImport[], graph: readonly PackageLibrary[]): UsageReportThe answer for the imports of a repository and the graph of a package.
usageTextfunctionfunction usageText(r: UsageReport): stringThe answer as text: the three groups with their sizes, and the libraries of each.