Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 668 Bytes

File metadata and controls

22 lines (15 loc) · 668 Bytes
description Modern alternative to the traverse package to traverse and transform objects by visiting every node on a recursive walk

Replacements for traverse

neotraverse

neotraverse is a TypeScript rewrite of traverse with no dependencies. It offers a drop‑in compatible build as well as a modern API.

import traverse from 'traverse' // [!code --]
import traverse from 'neotraverse' // [!code ++]

const obj = [5, 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }]

traverse(obj).forEach(function (x) {
  if (x < 0) this.update(x + 128)
})

console.log(obj)