import type { PackageURL } from './package-url.js'; export type PurlInput = PackageURL | string; /** @internal Register the PackageURL class for string parsing in compare functions. */ export declare function _registerPackageURL(ctor: typeof PackageURL): void; /** * Compare two PackageURLs for equality. * * Two PURLs are considered equal if their canonical string representations match. * This comparison is case-sensitive after normalization. * * Accepts both PackageURL instances and PURL strings. Strings are parsed and * normalized before comparison. * * @param a - First PackageURL or PURL string to compare * @param b - Second PackageURL or PURL string to compare * @returns true if the PURLs are equal, false otherwise * * @example * ```typescript * const purl1 = PackageURL.fromString('pkg:npm/lodash@4.17.21') * const purl2 = PackageURL.fromString('pkg:npm/lodash@4.17.21') * * equals(purl1, purl2) // -> true * equals('pkg:npm/lodash@4.17.21', 'pkg:NPM/lodash@4.17.21') // -> true * equals(purl1, 'pkg:npm/lodash@4.17.20') // -> false * ``` */ export declare function equals(a: PurlInput, b: PurlInput): boolean; /** * Compare two PackageURLs for sorting. * * Returns a number indicating sort order: * - Negative if `a` comes before `b` * - Zero if they are equal * - Positive if `a` comes after `b` * * Comparison is based on canonical string representation (lexicographic). * * Accepts both PackageURL instances and PURL strings. Strings are parsed and * normalized before comparison. * * @param a - First PackageURL or PURL string to compare * @param b - Second PackageURL or PURL string to compare * @returns -1, 0, or 1 for sort ordering * * @example * ```typescript * compare('pkg:npm/aaa', 'pkg:npm/bbb') // -> -1 * compare('pkg:npm/bbb', 'pkg:npm/aaa') // -> 1 * * // Use with Array.sort * ['pkg:npm/bbb', 'pkg:npm/aaa'].sort(compare) * // -> ['pkg:npm/aaa', 'pkg:npm/bbb'] * ``` */ export declare function compare(a: PurlInput, b: PurlInput): -1 | 0 | 1; /** * Check if a PackageURL matches a pattern with wildcards. * * Supports glob-style wildcards: * - asterisk matches any sequence of characters within a component * - double asterisk matches any value including empty (for optional components) * - question mark matches single character * * Pattern matching is performed on normalized PURLs (after type-specific * normalization). Each component is matched independently. * * @param pattern - PURL string with wildcards * @param purl - PackageURL instance to test * @returns true if purl matches the pattern * * @example * Wildcard in name: matches('pkg:npm/lodash-star', purl) * Wildcard in namespace: matches('pkg:npm/@babel/star', purl) * Wildcard in version: matches('pkg:npm/react@18.star', purl) * Match any type: matches('pkg:star/lodash', purl) * Optional version: matches('pkg:npm/lodash@star-star', purl) * * See test/pattern-matching.test.mts for comprehensive examples. */ export declare function matches(pattern: string, purl: PackageURL): boolean; /** * Create a reusable matcher function from a pattern. * More efficient for testing multiple PURLs against the same pattern. * * The returned function can be used with Array methods like filter(), * some(), and every() for efficient batch matching operations. * * @param pattern - PURL pattern string with wildcards * @returns Function that tests PURLs against the pattern * * @example * const isBabel = createMatcher('pkg:npm/@babel/star') * packages.filter(isBabel) * * See test/pattern-matching.test.mts for comprehensive examples. */ export declare function createMatcher(pattern: string): (_purl: PackageURL) => boolean;