0.4.1 • Published 4 years ago

source-map-url v0.4.1

Weekly downloads
18,137,926
License
MIT
Repository
github
Last release
4 years ago

Overview Build Status

browser support

Tools for working with sourceMappingURL comments.

var sourceMappingURL = require("source-map-url")

var code = [
  "!function(){...}();",
  "/*# sourceMappingURL=foo.js.map */"
].join("\n")

sourceMappingURL.existsIn(code)
// true

sourceMappingURL.getFrom(code)
// foo.js.map

code = sourceMappingURL.insertBefore(code, "// License: MIT\n")
// !function(){...}();
// // License: MIT
// /*# sourceMappingURL=foo.js.map */

code = sourceMappingURL.removeFrom(code)
// !function(){...}();
// // License: MIT

sourceMappingURL.existsIn(code)
// false

sourceMappingURL.getFrom(code)
// null

code += "//# sourceMappingURL=/other/file.js.map"
// !function(){...}();
// // License: MIT
// //# sourceMappingURL=/other/file.js.map

Installation

  • npm install source-map-url
  • bower install source-map-url
  • component install lydell/source-map-url

Works with CommonJS, AMD and browser globals, through UMD.

Usage

sourceMappingURL.getFrom(code)

Returns the url of the sourceMappingURL comment in code. Returns null if there is no such comment.

sourceMappingURL.existsIn(code)

Returns true if there is a sourceMappingURL comment in code, or false otherwise.

sourceMappingURL.removeFrom(code)

Removes the sourceMappingURL comment in code. Does nothing if there is no such comment. Returns the updated code.

sourceMappingURL.insertBefore(code, string)

Inserts string before the sourceMappingURL comment in code. Appends string to code if there is no such comment.

Lets you append something to a file without worrying about burying the sourceMappingURL comment (by keeping it at the end of the file).

sourceMappingURL.regex

The regex that is used to match sourceMappingURL comments. It matches both // and /**/ comments, thus supporting both JavaScript and CSS.

Tests

Start by running npm test, which 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.

License

The X11 (“MIT”) License.

archetype-librarycomponennenttvuedragdropuploadimagespopsmart-common-authreact-native-bluetooth2killi8n-react-native-fast-imagern-send-smsmylicensespecify-importsbabel-specify-imports@icanpm/api-mastergew-nodejs-api-client@arisageha/react-lazyload@arisageha/react-lazyload-fix@cashremit/cr-streamline-iconspg-cli-servicereact-native-template-rfbasecloud-archive-s3airscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxf@phil8795/pecuniarius-apideneme323112@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkgql_din_modbitgetreact-native-thanh-toast-library@thanhnguyen14797/react-native-thanh-toast-library@l1nyanm1ng/react-picture-viewercthpb-plugin-social@olivervorasai/sliderreact-native-printer-brothersrn-pdf-reader-offlinereact-native-shekhar-bridge-testasterjswilscanner@oiti/documentoscopy-react-nativejs4cytoscape@mink-opn/build-tokensquoc-testreact-native-slider-kf@saaspe/components@postmates/html-webpack-inline-source-pluginplginexpand-react-bridge@everything-registry/sub-chunk-2800ondjoyer-cli-demogriffin-ui-librarycordova-plugin-amplify-paycordova-plugin-amplify-paymentcordova-plugin-newplugincolomboconnex-kakilangconnex_ram00nezcpcs6_loggercpm-8cpm-9cpm-defcpm-10cpm-11cpm-12cpm-13cpm-14cpm-15cpm-16cpm-17cpm-18cpm-19cpm-20cpm-21cpm-5cpm-6cpm-7cr7-excotrader-dex-sdkcourse-vue-tplcssesc-wbgcss-to-js-sourcemap-coredataormcscg-product-cardevanutilsember-webpack-hot-reloadeditorjs-alerticonses-react-bridgeex-ikon-components-libraryfahad-redux-axios-midlewarefastlion-picture-viewerfast-sourcemap-concatfenglin-uploadereasyplayer-myearpodearpods
0.4.1

4 years ago

0.4.0

9 years ago

0.3.0

10 years ago

0.2.0

11 years ago

0.1.0

11 years ago