UNPKG

@alwatr/package-tracer

Version:

Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.

69 lines 2.2 kB
/** * A module for tracking package information. * This module is useful for keeping track of loaded packages and their versions. * It does not prevent the same package from being added multiple times! * For that, you can use the `@alwatr/dedupe` package. * * @example * ```typescript * import { packageTracer } from './package-tracer'; * * packageTracer.add('express', '4.18.2'); * packageTracer.add('lodash', '4.17.21'); * * if (packageTracer.has('express')) { * const versions = packageTracer.get('express'); * console.log('Express versions:', versions); * } * ``` */ export declare const packageTracer: { /** * A dictionary storing package names and their corresponding versions. */ readonly list: Readonly<DictionaryOpt<readonly string[]>>; /** * Adds a package and its version to the tracker. * It does not prevent the same package from being added multiple times! * For that, you can use the `@alwatr/dedupe` package. * * @param packageName - The name of the package. * @param version - The version of the package. * * @example * ```typescript * packageTracer.add(__package_name__, __package_version__); * ``` */ readonly add: (packageName: string, version: string) => void; /** * Checks if a package exists in the tracker. * * @param packageName - The name of the package. * @returns `true` if the package exists, `false` otherwise. * * @example * ```typescript * if (packageTracer.has('axios')) { * console.log('Axios is tracked!'); * } * ``` */ readonly has: (packageName: string) => boolean; /** * Retrieves the versions of a package. * * @param packageName - The name of the package. * @returns An array of versions or `undefined` if the package doesn't exist. * * @example * ```typescript * const reactVersions = packageTracer.get('react'); * if (reactVersions) { * console.log('React versions:', reactVersions); * } * ``` */ readonly get: (packageName: string) => readonly string[] | undefined; }; //# sourceMappingURL=main.d.ts.map