Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | // Copyright 2014 Simon Lydell
|
---|
2 | // X11 (“MIT”) Licensed. (See LICENSE.)
|
---|
3 |
|
---|
4 | void (function(root, factory) {
|
---|
5 | if (typeof define === "function" && define.amd) {
|
---|
6 | define(factory)
|
---|
7 | } else if (typeof exports === "object") {
|
---|
8 | module.exports = factory()
|
---|
9 | } else {
|
---|
10 | root.sourceMappingURL = factory()
|
---|
11 | }
|
---|
12 | }(this, function() {
|
---|
13 |
|
---|
14 | var innerRegex = /[#@] sourceMappingURL=([^\s'"]*)/
|
---|
15 |
|
---|
16 | var regex = RegExp(
|
---|
17 | "(?:" +
|
---|
18 | "/\\*" +
|
---|
19 | "(?:\\s*\r?\n(?://)?)?" +
|
---|
20 | "(?:" + innerRegex.source + ")" +
|
---|
21 | "\\s*" +
|
---|
22 | "\\*/" +
|
---|
23 | "|" +
|
---|
24 | "//(?:" + innerRegex.source + ")" +
|
---|
25 | ")" +
|
---|
26 | "\\s*"
|
---|
27 | )
|
---|
28 |
|
---|
29 | return {
|
---|
30 |
|
---|
31 | regex: regex,
|
---|
32 | _innerRegex: innerRegex,
|
---|
33 |
|
---|
34 | getFrom: function(code) {
|
---|
35 | var match = code.match(regex)
|
---|
36 | return (match ? match[1] || match[2] || "" : null)
|
---|
37 | },
|
---|
38 |
|
---|
39 | existsIn: function(code) {
|
---|
40 | return regex.test(code)
|
---|
41 | },
|
---|
42 |
|
---|
43 | removeFrom: function(code) {
|
---|
44 | return code.replace(regex, "")
|
---|
45 | },
|
---|
46 |
|
---|
47 | insertBefore: function(code, string) {
|
---|
48 | var match = code.match(regex)
|
---|
49 | if (match) {
|
---|
50 | return code.slice(0, match.index) + string + code.slice(match.index)
|
---|
51 | } else {
|
---|
52 | return code + string
|
---|
53 | }
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | }));
|
---|
Note:
See
TracBrowser
for help on using the repository browser.