"of" pattern

CodeMirror has an “of” pattern in many of its functions:

let syncAnnotation = Annotation.define<boolean>()
// ...

I have not encountered this pattern before and I am having trouble understanding it. What is the name of this pattern? Can you suggest a source to understand it better?

It’s just a method name used to create an instance of a given type of object. Transaction.userEvent is an annotation type. Calling .of creates an annotation with the given value.

1 Like