import { Result } from "t-result"; //#region src/partialEqual.d.ts type ComparisonsType = [type: 'strStartsWith', value: string] | [type: 'strEndsWith', value: string] | [type: 'hasType', value: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function'] | [type: 'strContains', value: string] | [type: 'strMatchesRegex', value: RegExp] | [type: 'deepEqual', value: any] | [type: 'numIsGreaterThan', value: number] | [type: 'numIsGreaterThanOrEqual', value: number] | [type: 'numIsLessThan', value: number] | [type: 'numIsLessThanOrEqual', value: number] | [type: 'numIsInRange', value: [number, number]] | [type: 'arrayContains', value: any[]] | [type: 'arrayContainsInOrder', value: any[]] | [type: 'arrayStartsWith', value: any[]] | [type: 'arrayEndsWith', value: any[]] | [type: 'arrayLength', value: number] | [type: 'arrayMinLength', value: number] | [type: 'arrayMaxLength', value: number] | [type: 'arrayIncludes', value: any] | [type: 'arrayEvery', value: ComparisonsType] | [type: 'arraySome', value: ComparisonsType] | [type: 'jsonStringHasPartial', value: any] | [type: 'partialEqual', value: any] | [type: 'custom', value: (target: unknown) => boolean | { error: string; }] | [type: 'isInstanceOf', value: new (...args: any[]) => any] | [type: 'keyNotBePresent', value: null] | [type: 'not', value: ComparisonsType] | [type: 'any', value: ComparisonsType[]] | [type: 'all', value: ComparisonsType[]] | [type: 'withNoExtraKeys', partialShape: any] | [type: 'withDeepNoExtraKeys', partialShape: any] | [type: 'noExtraDefinedKeys', partialShape: any] | [type: 'deepNoExtraDefinedKeys', partialShape: any]; type KeyComparisonPrefix = 'pqkc' | 'pqkc-not'; type KeyComparison = { any: `$${KeyComparisonPrefix}:any$`; anyOther: `$${KeyComparisonPrefix}:anyOther$`; numeric: `$${KeyComparisonPrefix}:numeric$`; startingWith: `$${KeyComparisonPrefix}:startingWith:${string}$`; endingWith: `$${KeyComparisonPrefix}:endingWith:${string}$`; contains: `$${KeyComparisonPrefix}:contains:${string}$`; matchesRegex: `$${KeyComparisonPrefix}:matchesRegex:${string}$`; }; type Comparison = { '~sc': ComparisonsType; }; type BaseMatch = { noExtraKeys: (partialShape: any) => Comparison; deepNoExtraKeys: (partialShape: any) => Comparison; noExtraDefinedKeys: (partialShape: any) => Comparison; deepNoExtraDefinedKeys: (partialShape: any) => Comparison; hasType: { string: Comparison; number: Comparison; boolean: Comparison; object: Comparison; array: Comparison; function: Comparison; }; isInstanceOf: (constructor: new (...args: any[]) => any) => Comparison; str: { contains: (substring: string) => Comparison; startsWith: (substring: string) => Comparison; endsWith: (substring: string) => Comparison; matchesRegex: (regex: RegExp) => Comparison; }; num: { isGreaterThan: (value: number) => Comparison; isGreaterThanOrEqual: (value: number) => Comparison; isLessThan: (value: number) => Comparison; isLessThanOrEqual: (value: number) => Comparison; isInRange: (value: [number, number]) => Comparison; }; array: { contains: (elements: any[]) => Comparison; containsInOrder: (elements: any[]) => Comparison; startsWith: (elements: any[]) => Comparison; endsWith: (elements: any[]) => Comparison; length: (n: number) => Comparison; minLength: (n: number) => Comparison; maxLength: (n: number) => Comparison; includes: (element: any) => Comparison; every: (matcher: Comparison) => Comparison; some: (matcher: Comparison) => Comparison; }; jsonString: { hasPartial: (value: any) => Comparison; }; equal: (value: any) => Comparison; partialEqual: (value: any) => Comparison; custom: (isEqual: (value: unknown) => boolean | { error: string; }) => Comparison; keyNotBePresent: Comparison; any: (...values: any[]) => Comparison; all: (...values: any[]) => Comparison; key: { any: KeyComparison['any']; anyOther: KeyComparison['anyOther']; numeric: KeyComparison['numeric']; startingWith: (substring: string) => KeyComparison['startingWith']; endingWith: (substring: string) => KeyComparison['endingWith']; containing: (substring: string) => KeyComparison['contains']; matchingRegex: (regex: RegExp) => KeyComparison['matchesRegex']; }; }; type Match = BaseMatch & { not: BaseMatch; }; declare const match: Match; type PartialError = { path: string; message: string; received?: any; expected?: any; }; /** * Checks if sub is a partial match of target (all properties in sub exist and * match in target). Supports special comparison matchers for flexible pattern * matching. * * @example * // Basic partial matching * partialEqual({ a: 1, b: 2 }, { a: 1 }); // true - sub is subset of target * partialEqual([1, 2, 3], [1, 2]); // true - sub array is prefix of target (default behavior) * * // Array matching (default behavior: prefix matching) * partialEqual([1, 2, 3, 4], [1, 2]); // true - checks first 2 elements * partialEqual([1, 3, 4], [1, 2]); // false - second element doesn't match * * // Advanced array matchers for flexible matching * partialEqual([1, 2, 3, 4, 5], match.array.contains([3, 1])); // true - contains elements anywhere * partialEqual([1, 2, 3, 4, 5], match.array.containsInOrder([2, 4])); // true - contains in order (non-consecutive) * partialEqual([1, 2, 3], match.array.startsWith([1, 2])); // true - explicit prefix matching * partialEqual([1, 2, 3], match.array.endsWith([2, 3])); // true - suffix matching * partialEqual([1, 2, 3], match.array.length(3)); // true - exact length * partialEqual([1, 2, 3], match.array.includes(2)); // true - includes element * partialEqual( * [10, 20, 30], * match.array.every(match.num.isGreaterThan(5)), * ); // true - all elements match * partialEqual([1, 10, 3], match.array.some(match.num.isGreaterThan(8))); // true - at least one matches * * // Special comparisons * partialEqual('hello world', match.str.contains('world')); // true * partialEqual(25, match.num.isGreaterThan(18)); // true * partialEqual( * 'test@example.com', * match.custom((v) => typeof v === 'string' && v.includes('@')), * ); // true * * // Complex nested matching * partialEqual( * { user: { name: 'John', age: 30 } }, * { * user: { * name: match.str.startsWith('J'), * age: match.num.isGreaterThan(25), * }, * }, * ); // true */ declare function partialEqual(target: any, sub: any, returnErrors: true): Result; declare function partialEqual(target: any, sub: any): boolean; //#endregion export { match, partialEqual };