# "of" pattern

**URL:** https://discuss.codemirror.net/t/of-pattern/8073
**Category:** Uncategorized
**Created:** [April 1, 2024, 9:49am UTC](https://discuss.codemirror.net/t/of-pattern/8073 "2024-04-01T09:49:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cihad](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/cihad/32/3988_2.png) [@cihad](https://discuss.codemirror.net/u/cihad)
#### Post date: [April 1, 2024, 9:49am UTC](https://discuss.codemirror.net/t/of-pattern/8073/1 "2024-04-01T09:49:08Z")

</div>

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

```auto
let syncAnnotation = Annotation.define<boolean>()
syncAnnotation.of(true)
// ...
Transaction.userEvent.of(userEvent)

```

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?

---

<div class="post-metadata">

### Author: ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)
#### Post date: [April 1, 2024, 11:40am UTC](https://discuss.codemirror.net/t/of-pattern/8073/2 "2024-04-01T11:40:45Z")

</div>

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.
