# How to calculate the changed ranges for transactions

**URL:** <https://discuss.prosemirror.net/t/how-to-calculate-the-changed-ranges-for-transactions/3771>\
**Category:** Uncategorized\
**Created:** [May 15, 2021, 9:33am UTC](https://discuss.prosemirror.net/t/how-to-calculate-the-changed-ranges-for-transactions/3771 "2021-05-15T09:33:14Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![philippkuehn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/philippkuehn/32/1820_2.png) [@philippkuehn](https://discuss.prosemirror.net/u/philippkuehn)\
**Post date:** [May 15, 2021, 10:15pm UTC](https://discuss.prosemirror.net/t/how-to-calculate-the-changed-ranges-for-transactions/3771/4 "2021-05-15T22:15:25Z")

</div>

Got it!

```auto
transaction.mapping.maps.forEach((stepMap, index) => {
  stepMap.forEach((from, to) => {
    const newStart = transaction.mapping.slice(index).map(from, -1)
    const newEnd = transaction.mapping.slice(index).map(to)
    const oldStart = transaction.mapping.invert().map(newStart, -1)
    const oldEnd = transaction.mapping.invert().map(newEnd)
  })
})

```

---

_[View the full topic](https://discuss.prosemirror.net/t/how-to-calculate-the-changed-ranges-for-transactions/3771)._
