| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 1 1 4 4 3 3 3 3 5 3 1 1 2 1 | 'use strict';
module.exports = imports;
function imports(str, fn) {
if (str instanceof Buffer) str = str.toString();
if (fn) return map(str, fn);
var re = /@import *url\(['"]([^'"]+)['"]\);/g;
var ret = [];
var m;
while (m = re.exec(str)) {
ret.push({
string: m[0],
path: m[1],
index: m.index
});
}
return ret;
}
function map(str, fn) {
imports(str).forEach(function(r){
str = str.replace(r.string, fn(r));
});
return str;
}
|