( subset: OrderBy | undefined, superset: OrderBy | undefined, )
| 713 | * @returns true if subset is satisfied by superset |
| 714 | */ |
| 715 | export function isOrderBySubset( |
| 716 | subset: OrderBy | undefined, |
| 717 | superset: OrderBy | undefined, |
| 718 | ): boolean { |
| 719 | // No ordering requirement is always satisfied |
| 720 | if (!subset || subset.length === 0) { |
| 721 | return true |
| 722 | } |
| 723 | |
| 724 | // If there's no superset ordering but subset requires ordering, not satisfied |
| 725 | if (!superset || superset.length === 0) { |
| 726 | return false |
| 727 | } |
| 728 | |
| 729 | // Check if subset is a prefix of superset with matching expressions and compare options |
| 730 | if (subset.length > superset.length) { |
| 731 | return false |
| 732 | } |
| 733 | |
| 734 | for (let i = 0; i < subset.length; i++) { |
| 735 | const subClause = subset[i]! |
| 736 | const superClause = superset[i]! |
| 737 | |
| 738 | // Check if expressions match |
| 739 | if (!areExpressionsEqual(subClause.expression, superClause.expression)) { |
| 740 | return false |
| 741 | } |
| 742 | |
| 743 | // Check if compare options match |
| 744 | if ( |
| 745 | !areCompareOptionsEqual( |
| 746 | subClause.compareOptions, |
| 747 | superClause.compareOptions, |
| 748 | ) |
| 749 | ) { |
| 750 | return false |
| 751 | } |
| 752 | } |
| 753 | |
| 754 | return true |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Check if one limit is a subset of another. |
no test coverage detected