Skip to content
This repository was archived by the owner on Feb 10, 2018. It is now read-only.

Commit 4847ec5

Browse files
committed
initial release
1 parent ebc7496 commit 4847ec5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
var xregexp = require("xregexp");
2+
var _ = require("lodash");
3+
14
module.exports = function (source, map) {
2-
// TODO
5+
if (this.cacheable) {
6+
this.cacheable();
7+
}
8+
9+
var funcRegex = /XRegExp\((.*)\)/gi;
10+
11+
var matches = [];
12+
var replaced = source;
13+
while (matches = funcRegex.exec(source)) {
14+
var innerRegex = matches[1].replace(/['"]+/g, '');
15+
replaced = replaced.replace(new RegExp(funcRegex), xregexp(innerRegex));
16+
}
17+
18+
this.callback(null, replaced, map);
319
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
},
2121
"homepage": "https://github.com/code-chris/xregexp-loader#readme",
2222
"dependencies": {
23-
"xregexp": "~3.2.0"
23+
"lodash": "^4.17.4",
24+
"xregexp": "^3.2.0"
2425
}
2526
}

0 commit comments

Comments
 (0)