source: trip-planner-front/node_modules/webpack-sources/README.md@ 84d0fbb

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

initial commit

  • Property mode set to 100644
File size: 5.5 KB
Line 
1# webpack-sources
2
3Contains multiple classes which represent a `Source`. A `Source` can be asked for source code, size, source map and hash.
4
5## `Source`
6
7Base class for all sources.
8
9### Public methods
10
11All methods should be considered as expensive as they may need to do computations.
12
13#### `source`
14
15``` js
16Source.prototype.source() -> String | ArrayBuffer
17```
18
19Returns the represented source code as string.
20
21#### `size`
22
23``` js
24Source.prototype.size() -> Number
25```
26
27Returns the size in chars of the represented source code.
28
29#### `map`
30
31``` js
32Source.prototype.map(options: Object) -> Object | null
33```
34
35Returns the SourceMap of the represented source code as JSON. May return `null` if no SourceMap is available.
36
37The `options` object can contain the following keys:
38
39* `columns: Boolean` (default `true`): If set to false the implementation may omit mappings for columns.
40* `module: Boolean` (default `true`): If set to false the implementation may omit inner mappings for modules.
41
42#### `sourceAndMap`
43
44``` js
45Source.prototype.sourceAndMap(options: Object) -> {
46 source: String,
47 map: Object
48}
49```
50
51Returns both, source code (like `Source.prototype.source()` and SourceMap (like `Source.prototype.map()`). This method could have better performance than calling `source()` and `map()` separately.
52
53See `map()` for `options`.
54
55#### `updateHash`
56
57``` js
58Source.prototype.updateHash(hash: Hash) -> void
59```
60
61Updates the provided `Hash` object with the content of the represented source code. (`Hash` is an object with an `update` method, which is called with string values)
62
63#### `node` (optional)
64
65``` js
66Source.prototype.node(options: Object) -> SourceNode
67```
68
69This is an optional method. It may be `null` if not implemented.
70
71Returns a `SourceNode` (see source-map library) for the represented source code.
72
73See `map()` for `options`.
74
75#### `listNode` (optional)
76
77``` js
78Source.prototype.listNode(options: Object) -> SourceNode
79```
80
81This is an optional method. It may be `null` if not implemented.
82
83Returns a `SourceListMap` (see source-list-map library) for the represented source code.
84
85See `map()` for `options`.
86
87## `RawSource`
88
89Represents source code without SourceMap.
90
91``` js
92new RawSource(sourceCode: String)
93```
94
95## `OriginalSource`
96
97Represents source code, which is a copy of the original file.
98
99``` js
100new OriginalSource(
101 sourceCode: String,
102 name: String
103)
104```
105
106* `sourceCode`: The source code.
107* `name`: The filename of the original source code.
108
109OriginalSource tries to create column mappings if requested, by splitting the source code at typical statement borders (`;`, `{`, `}`).
110
111## `SourceMapSource`
112
113Represents source code with SourceMap, optionally having an additional SourceMap for the original source.
114
115``` js
116new SourceMapSource(
117 sourceCode: String,
118 name: String,
119 sourceMap: Object | String,
120 originalSource?: String,
121 innerSourceMap?: Object | String,
122 removeOriginalSource?: boolean
123)
124```
125
126* `sourceCode`: The source code.
127* `name`: The filename of the original source code.
128* `sourceMap`: The SourceMap for the source code.
129* `originalSource`: The source code of the original file. Can be omitted if the `sourceMap` already contains the original source code.
130* `innerSourceMap`: The SourceMap for the `originalSource`/`name`.
131* `removeOriginalSource`: Removes the source code for `name` from the final map, keeping only the deeper mappings for that file.
132
133The `SourceMapSource` supports "identity" mappings for the `innerSourceMap`.
134When original source matches generated source for a mapping it's assumed to be mapped char by char allowing to keep finer mappings from `sourceMap`.
135
136## `LineToLineMappedSource`
137
138Represents source code, which is mapped line by line to the original file.
139
140``` js
141new LineToLineMappedSource(
142 sourceCode: String,
143 name: String,
144 originalSource: String
145)
146```
147
148* `sourceCode`: The source code.
149* `name`: The filename of the original source code.
150* `originalSource`: The original source code.
151
152## `CachedSource`
153
154Decorates a `Source` and caches returned results of `map`, `source`, `size` and `sourceAndMap` in memory. Every other operation is delegated to the wrapped `Source`.
155
156``` js
157new CachedSource(source: Source)
158```
159
160## `PrefixSource`
161
162Prefix every line of the decorated `Source` with a provided string.
163
164``` js
165new PrefixSource(
166 prefix: String,
167 source: Source
168)
169```
170
171## `ConcatSource`
172
173Concatenate multiple `Source`s or strings to a single source.
174
175``` js
176new ConcatSource(
177 ...items?: Source | String
178)
179```
180
181### Public methods
182
183#### `add`
184
185``` js
186ConcatSource.prototype.add(item: Source | String)
187```
188
189Adds an item to the source.
190
191## `ReplaceSource`
192
193Decorates a `Source` with replacements and insertions of source code.
194
195The `ReplaceSource` supports "identity" mappings for child source.
196When original source matches generated source for a mapping it's assumed to be mapped char by char allowing to split mappings at replacements/insertions.
197
198### Public methods
199
200#### `replace`
201
202``` js
203ReplaceSource.prototype.replace(
204 start: Number,
205 end: Number,
206 replacement: String
207)
208```
209
210Replaces chars from `start` (0-indexed, inclusive) to `end` (0-indexed, inclusive) with `replacement`.
211
212Locations represents locations in the original source and are not influenced by other replacements or insertions.
213
214#### `insert`
215
216``` js
217ReplaceSource.prototype.insert(
218 pos: Number,
219 insertion: String
220)
221```
222
223Inserts the `insertion` before char `pos` (0-indexed).
224
225Location represents location in the original source and is not influenced by other replacements or insertions.
226
227#### `original`
228
229Get decorated `Source`.
230
Note: See TracBrowser for help on using the repository browser.