modif comtabilite
This commit is contained in:
+37
-14
@@ -1,8 +1,6 @@
|
||||
Overview [](https://travis-ci.org/lydell/source-map-resolve)
|
||||
Overview [](https://travis-ci.org/lydell/source-map-resolve)
|
||||
========
|
||||
|
||||
[](https://ci.testling.com/lydell/source-map-resolve)
|
||||
|
||||
Resolve the source map and/or sources for a generated file.
|
||||
|
||||
```js
|
||||
@@ -117,9 +115,11 @@ If `code` contains no sourceMappingURL, the result is `null`.
|
||||
`callback(error, content)`. In Node.js you might want to use `fs.readFile`,
|
||||
while in the browser you might want to use an asynchronus `XMLHttpRequest`.
|
||||
- `options` is an optional object with any of the following properties:
|
||||
- `ignoreSourceRoot`: The `sourceRoot` property of source maps might only be
|
||||
relevant when resolving sources in the browser. This lets you bypass it
|
||||
when using the module outside of a browser, if needed. Defaults to `false`.
|
||||
- `sourceRoot`: Override the `sourceRoot` property of the source map, which
|
||||
might only be relevant when resolving sources in the browser. This lets you
|
||||
bypass it when using the module outside of a browser, if needed. Pass a
|
||||
string to replace the `sourceRoot` property with, or `false` to ignore it.
|
||||
Defaults to `undefined`.
|
||||
- `callback(error, result)` is a function that is invoked with either an error
|
||||
or `null` and the result.
|
||||
|
||||
@@ -128,21 +128,30 @@ The result is an object with the following properties:
|
||||
- `sourcesResolved`: The same as `map.sources`, except all the sources are
|
||||
fully resolved.
|
||||
- `sourcesContent`: An array with the contents of all sources in `map.sources`,
|
||||
in the same order as `map.sources`.
|
||||
in the same order as `map.sources`. If getting the contents of a source fails,
|
||||
an error object is put into the array instead.
|
||||
|
||||
### `sourceMapResolve.resolve(code, codeUrl, read, [options], callback)` ###
|
||||
|
||||
The arguments are identical to `sourceMapResolve.resolveSourceMap`, except that
|
||||
you may also provide the same `options` as in
|
||||
`sourceMapResolve.resolveSources`.
|
||||
you may also provide the same `options` as in `sourceMapResolve.resolveSources`.
|
||||
|
||||
This is simply a convienience method that first resolves the source map and
|
||||
then its sources. You could also do this by first calling
|
||||
This is a convenience method that first resolves the source map and then its
|
||||
sources. You could also do this by first calling
|
||||
`sourceMapResolve.resolveSourceMap` and then `sourceMapResolve.resolveSources`.
|
||||
|
||||
The result is identical to `sourceMapResolve.resolveSourceMap`, with the
|
||||
properties from `sourceMapResolve.resolveSources` merged into it.
|
||||
|
||||
There is one extra feature available, though. If `code` is `null`, `codeUrl` is
|
||||
treated as a url to the source map instead of to `code`, and will be read. This
|
||||
is handy if you _sometimes_ get the source map url from the `SourceMap: <url>`
|
||||
header (see the [Notes] section). In this case, the `sourceMappingURL` property
|
||||
of the result is `null`.
|
||||
|
||||
|
||||
[Notes]: #notes
|
||||
|
||||
### `sourceMapResolve.*Sync()` ###
|
||||
|
||||
There are also sync versions of the three previous functions. They are identical
|
||||
@@ -160,6 +169,23 @@ empty array. In other words, the sources aren’t read. You only get the
|
||||
`sourcesResolved` property. (This only supported in the synchronus version, since
|
||||
there is no point doing it asynchronusly.)
|
||||
|
||||
### `sourceMapResolve.parseMapToJSON(string, [data])` ###
|
||||
|
||||
The spec says that if a source map (as a string) starts with `)]}'`, it should
|
||||
be stripped off. This is to prevent XSSI attacks. This function does that and
|
||||
returns the result of `JSON.parse`ing what’s left.
|
||||
|
||||
If this function throws `error`, `error.sourceMapData === data`.
|
||||
|
||||
### Errors
|
||||
|
||||
All errors passed to callbacks or thrown by this module have a `sourceMapData`
|
||||
property that contain as much as possible of the intended result of the function
|
||||
up until the error occurred.
|
||||
|
||||
Note that while the `map` property of result objects always is an object,
|
||||
`error.sourceMapData.map` will be a string if parsing that string fails.
|
||||
|
||||
|
||||
Note
|
||||
====
|
||||
@@ -182,9 +208,6 @@ First off, run `npm install` to install testing modules and browser polyfills.
|
||||
|
||||
`npm test` lints the code and runs the test suite in Node.js.
|
||||
|
||||
To run the tests in a browser, run `testling` (`npm install -g testling`) or
|
||||
`testling -u`.
|
||||
|
||||
x-package.json5
|
||||
---------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user