Skip to content

Commit

Permalink
refactor(utils)!: rename isEffectOfType -> matchEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 10, 2023
1 parent b50b367 commit 4e91959
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .yarn/versions/89e28851.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
"@codemirror-toolkit/extensions": patch
"@codemirror-toolkit/utils": minor
12 changes: 6 additions & 6 deletions packages/utils/src/immutableSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export const ImmutableSetUtils = /*#__PURE__*/ Object.freeze({
if (set.has(value)) {
return set
}
const newSet = new Set(set)
newSet.add(value)
return newSet
const result = new Set(set)
result.add(value)
return result
},
delete: <T>(set: Set<T>, value: T): Set<T> => {
if (!set.has(value)) {
return set
}
const newSet = new Set(set)
newSet.delete(value)
return newSet
const result = new Set(set)
result.delete(value)
return result
},
clear: <T>(set: Set<T>): Set<T> => {
if (!set.size) {
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/state.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { StateEffect, StateEffectType } from '@codemirror/state'

export function isEffectOfType<T>(type: StateEffectType<T>) {
export function matchEffect<T>(type: StateEffectType<T>) {
return (effect: StateEffect<unknown>): effect is StateEffect<T> => effect.is(type)
}

Expand All @@ -21,5 +21,5 @@ export function filterEffects<T>(
effects: readonly StateEffect<unknown>[],
type: StateEffectType<T>,
): StateEffect<T>[] {
return effects.filter(isEffectOfType(type))
return effects.filter(matchEffect(type))
}

0 comments on commit 4e91959

Please sign in to comment.