UNPKG

@alwatr/package-tracer

Version:

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

66 lines (64 loc) 1.71 kB
/* @alwatr/package-tracer v5.5.10 */ // src/main.ts var packageTracer = { /** * A dictionary storing package names and their corresponding versions. */ list: {}, /** * 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__); * ``` */ add(packageName, version) { this.list[packageName] ??= []; this.list[packageName].push(version); }, /** * 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!'); * } * ``` */ has(packageName) { const exist = Object.prototype.hasOwnProperty.call(this.list, packageName); return exist; }, /** * 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); * } * ``` */ get(packageName) { return this.list[packageName]; } }; __dev_mode__: packageTracer.add("@alwatr/package-tracer", "5.5.10"); export { packageTracer }; //# sourceMappingURL=main.mjs.map