Function sourcemap::decode

source ·
pub fn decode<R: Read>(rdr: R) -> Result<DecodedMap>
Expand description

Decodes a sourcemap or sourcemap index from a reader

This supports both sourcemaps and sourcemap indexes unless the specialized methods on the individual types.

Examples found in repository?
examples/read.rs (line 8)
7
8
9
10
11
12
13
14
15
16
17
18
fn load_from_reader<R: Read>(mut rdr: R) -> SourceMap {
    match decode(&mut rdr).unwrap() {
        DecodedMap::Regular(sm) => sm,
        DecodedMap::Index(idx) => idx
            .flatten_and_rewrite(&RewriteOptions {
                load_local_source_contents: true,
                ..Default::default()
            })
            .unwrap(),
        _ => panic!("unexpected sourcemap format"),
    }
}
More examples
Hide additional examples
examples/rewrite.rs (line 25)
24
25
26
27
28
29
30
31
32
33
34
35
fn load_from_reader<R: Read>(mut rdr: R) -> SourceMap {
    match decode(&mut rdr).unwrap() {
        DecodedMap::Regular(sm) => sm,
        DecodedMap::Index(idx) => idx
            .flatten_and_rewrite(&RewriteOptions {
                load_local_source_contents: true,
                ..Default::default()
            })
            .unwrap(),
        _ => panic!("unexpected sourcemap format"),
    }
}