Open
Description
Problem
When comparing two text nodes with Text.equals()
, currently only text is omitted from the object when loose: true
is provided. I want to compare two text nodes that will always have unique ids.
type TextNode = {
id: string
text: string
bold?: boolean
italic?: boolean
underline?: boolean
}
Solution
I'm thinking of two possible solutions depending on the appetite of everyone.
- expose the
isDeepEqual
function from utils underlying theText.equals
check and let me roll my own equality function
or
- add an additional prop to the
Text.equals
function allowing me to pass in my own omission function something like
const omitTextAndIds = (obj: TextNode) => {
const { text, id, ...rest } = obj
return rest
}
Text.equals(nodeA, nodeB, {loose: true, omitFunc: omitTextAndIds})
Alternatives
I just run my own omit
function on the nodes before I pass them into the equals
function 🤔