Skip to content

Commit

Permalink
feat: add prop surrounds with range (ianstormtaylor#5729)
Browse files Browse the repository at this point in the history
* feat: add prop surrounds with range

* Create small-carrots-jam.md

* fix: docx about range.included

---------

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
  • Loading branch information
electroluxcode and dylans authored Sep 26, 2024
1 parent 575bd54 commit 0158e63
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/interfaces/range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export interface RangeInterface {
*/
includes: (range: Range, target: Path | Point | Range) => boolean

/**
* Check if a range includes another range.
*/
surrounds: (range: Range, target: Range) => boolean

/**
* Get the intersection of a range with another.
*/
Expand Down Expand Up @@ -124,6 +129,14 @@ export const Range: RangeInterface = {
)
},

surrounds(range: Range, target: Range): boolean {
const intersectionRange = Range.intersection(range, target)
if (!intersectionRange) {
return false
}
return Range.equals(intersectionRange, target)
},

includes(range: Range, target: Path | Point | Range): boolean {
if (Range.isRange(target)) {
if (
Expand Down

0 comments on commit 0158e63

Please sign in to comment.