source: trip-planner-front/node_modules/convert-source-map/README.md@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.1 KB
Line 
1# convert-source-map [![build status](https://secure.travis-ci.org/thlorenz/convert-source-map.svg?branch=master)](http://travis-ci.org/thlorenz/convert-source-map)
2
3Converts a source-map from/to different formats and allows adding/changing properties.
4
5```js
6var convert = require('convert-source-map');
7
8var json = convert
9 .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
10 .toJSON();
11
12var modified = convert
13 .fromComment('//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIn0=')
14 .setProperty('sources', [ 'SRC/FOO.JS' ])
15 .toJSON();
16
17console.log(json);
18console.log(modified);
19```
20
21```json
22{"version":3,"file":"build/foo.min.js","sources":["src/foo.js"],"names":[],"mappings":"AAAA","sourceRoot":"/"}
23{"version":3,"file":"build/foo.min.js","sources":["SRC/FOO.JS"],"names":[],"mappings":"AAAA","sourceRoot":"/"}
24```
25
26## API
27
28### fromObject(obj)
29
30Returns source map converter from given object.
31
32### fromJSON(json)
33
34Returns source map converter from given json string.
35
36### fromBase64(base64)
37
38Returns source map converter from given base64 encoded json string.
39
40### fromComment(comment)
41
42Returns source map converter from given base64 encoded json string prefixed with `//# sourceMappingURL=...`.
43
44### fromMapFileComment(comment, mapFileDir)
45
46Returns source map converter from given `filename` by parsing `//# sourceMappingURL=filename`.
47
48`filename` must point to a file that is found inside the `mapFileDir`. Most tools store this file right next to the
49generated file, i.e. the one containing the source map.
50
51### fromSource(source)
52
53Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was found.
54
55### fromMapFileSource(source, mapFileDir)
56
57Finds last sourcemap comment in file and returns source map converter or returns null if no source map comment was
58found.
59
60The sourcemap will be read from the map file found by parsing `# sourceMappingURL=file` comment. For more info see
61fromMapFileComment.
62
63### toObject()
64
65Returns a copy of the underlying source map.
66
67### toJSON([space])
68
69Converts source map to json string. If `space` is given (optional), this will be passed to
70[JSON.stringify](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/JSON/stringify) when the
71JSON string is generated.
72
73### toBase64()
74
75Converts source map to base64 encoded json string.
76
77### toComment([options])
78
79Converts source map to an inline comment that can be appended to the source-file.
80
81By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would
82normally see in a JS source file.
83
84When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
85
86### addProperty(key, value)
87
88Adds given property to the source map. Throws an error if property already exists.
89
90### setProperty(key, value)
91
92Sets given property to the source map. If property doesn't exist it is added, otherwise its value is updated.
93
94### getProperty(key)
95
96Gets given property of the source map.
97
98### removeComments(src)
99
100Returns `src` with all source map comments removed
101
102### removeMapFileComments(src)
103
104Returns `src` with all source map comments pointing to map files removed.
105
106### commentRegex
107
108Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments.
109
110### mapFileCommentRegex
111
112Provides __a fresh__ RegExp each time it is accessed. Can be used to find source map comments pointing to map files.
113
114### generateMapFileComment(file, [options])
115
116Returns a comment that links to an external source map via `file`.
117
118By default, the comment is formatted like: `//# sourceMappingURL=...`, which you would normally see in a JS source file.
119
120When `options.multiline == true`, the comment is formatted like: `/*# sourceMappingURL=... */`, which you would find in a CSS source file.
Note: See TracBrowser for help on using the repository browser.