Acme.BookStore.HttpApi.Host/node_modules/vinyl-sourcemap/lib/helpers.js
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var nal = require('now-and-later');
var File = require('vinyl');
var convert = require('convert-source-map');
var removeBOM = require('remove-bom-buffer');
var appendBuffer = require('append-buffer');
var normalizePath = require('normalize-path');
var urlRegex = /^(https?|webpack(-[^:]+)?):\/\//;
function isRemoteSource(source) {
return source.match(urlRegex);
}
function parse(data) {
try {
return JSON.parse(removeBOM(data));
} catch (err) {
// TODO: should this log a debug?
}
}
function loadSourceMap(file, state, callback) {
// Try to read inline source map
state.map = convert.fromSource(state.content);
if (state.map) {
state.map = state.map.toObject();
// Sources in map are relative to the source file
state.path = file.dirname;
state.content = convert.removeComments(state.content);
// Remove source map comment from source
file.contents = new Buffer(state.content, 'utf8');
return callback();
}
// Look for source map comment referencing a source map file
var mapComment = convert.mapFileCommentRegex.exec(state.content);
var mapFile;
if (mapComment) {
mapFile = path.resolve(file.dirname, mapComment[1] || mapComment[2]);
state.content = convert.removeMapFileComments(state.content);
// Remove source map comment from source
file.contents = new Buffer(state.content, 'utf8');
} else {
// If no comment try map file with same name as source file
mapFile = file.path + '.map';
}
// Sources in external map are relative to map file
state.path = path.dirname(mapFile);
fs.readFile(mapFile, onRead);
function onRead(err, data) {
后面还有 183 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
