npm.io
0.3.4 • Published 3 weeks ago

tinyest

Licence
MIT
Version
0.3.4
Deps
0
Size
26 kB
Vulns
0
Weekly
0

tinyest

Tiny Embeddable Syntax Tree - GitHub

A compact, fast, and embeddable JavaScript AST for transpilation.

Source mapping

Tinyest supports source mapping. Use embedSourceMap function to obtain a new node with the source map embedded. Use stripSourceMap function to restore the original node and source map.

Note that both functions create a new AST instead of modifying the existing one:

const node: Identifier = [NodeTypeCatalog.identifier, 'ident'];
const sourceMap: SourceMap = new Map([[node, [1, 2]]]);

const sourceMappedNode = embedSourceMap(node, sourceMap);
const [restoredNode, restoredSourceMap] = stripSourceMap(sourceMappedNode);

console.log(restoredNode); // [9, 'ident'];
console.log(restoredSourceMap.get(restoredNode)); // [1, 2];

console.log(node === restoredNode); // false
console.log(restoredSourceMap.get(node)); // undefined

Projects using tinyest

  • TypeGPU - A TypeScript library that enhances the WebGPU API, allowing resource management in a type-safe way.

tinyest is created by Software Mansion

swm

Since 2012 Software Mansion is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – Hire us.

Keywords