question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can transformations be immutable?

See original GitHub issue

Is it possible to modify nodes in an immutable way? eg,

// Redact all text nodes
node = visit(node, (child) => {
  if (child.type === 'text') {
    return { ...child, value: '[redacted]' }
  }
})

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
wooormcommented, Dec 15, 2020

unist-util-visit is almost always good enough, and unist-util-visit-parents (used in the former) if you need to access all parents

1reaction
wooormcommented, Dec 15, 2020

Yes, I do. Plugins are always the slowest in the unified process. Copying a syntax-tree for 1mb of say markdown is a gigantically slow operation. Mutating a couple of things is faster.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transformation for Class Immutability - Fredrik Kjolstad
If a class is class immutable, none of its instances can be transitively mutated. Examples in Java include String and the classes in...
Read more >
Declarative and Immutable Pipeline of Transformations
Well, as much as it's possible. Let's say you have a document, and you have a collection of transformations, each of which will...
Read more >
Model Transformation with Immutable Data - CWI Amsterdam
Abstract. Mainstream model transformation tools operate on graph structured models which are described by class-based meta-models. In the traditional gram-.
Read more >
The 4 Immutable Laws of Transformation - Impruver.com
It turns out that there's a science to transformation, which have been codified into 4 laws. This article will discuss this science and...
Read more >
The Four Immutable Laws of Transformation - LinkedIn
It turns out that there's a science to transformation, which have been codified into 4 laws. This article will discuss this science and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found