Skip to content

Commit

Permalink
refactor(utils): extract constant
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 7, 2023
1 parent 5196167 commit 5f43eb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .yarn/versions/82ee3d52.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
"@codemirror-toolkit/extensions": patch
"@codemirror-toolkit/utils": patch
5 changes: 2 additions & 3 deletions packages/utils/src/rangeSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export function mapRangeSetToArray<T extends RangeValue, U>(
): U[] {
const values = new Array<U>(rangeSet.size)
if (values.length) {
const cursor = rangeSet.iter()
let index = 0
for (const cursor = rangeSet.iter(); cursor.value !== null; cursor.next()) {
for (; cursor.value !== null; cursor.next()) {
values[index++] = callbackfn(cursor.value, cursor.from, cursor.to)
}
}
Expand Down Expand Up @@ -59,8 +60,6 @@ export function reduceRangeSet<T extends RangeValue, U extends {}>(
const cursor = rangeSet.iter()
let accumulator: T | U
if (initialValue == null) {
// rangeSet.size is already checked
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
accumulator = cursor.value!
cursor.next()
} else {
Expand Down

0 comments on commit 5f43eb9

Please sign in to comment.