本文整理汇总了TypeScript中sourcemap-codec.decode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript decode函数的具体用法?TypeScript decode怎么用?TypeScript decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: decode
.then(result => {
if (result == null) return code;
if (typeof result === 'string') {
result = {
code: result,
map: undefined
};
}
const map =
typeof result.map === 'string'
? JSON.parse(result.map)
: result.map;
if (map && typeof map.mappings === 'string') {
map.mappings = decode(map.mappings);
}
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
if (map !== null) {
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
}
return result.code;
})
开发者ID:joeldenning,项目名称:rollup,代码行数:25,代码来源:transformBundle.ts
示例2: if
const transformChunkReducer = (code: string, result: any, plugin: Plugin): string => {
if (result == null) return code;
if (typeof result === 'string') {
result = {
code: result,
map: undefined
};
} else if (!inTransformBundle && !result.map && options.sourcemap) {
throw new Error(
`${
inTransformBundle ? 'transformBundle' : 'transformChunk'
} must return a "map" sourcemap property when sourcemaps are enabled.`
);
}
const map = typeof result.map === 'string' ? JSON.parse(result.map) : result.map;
if (map && typeof map.mappings === 'string') {
map.mappings = decode(map.mappings);
}
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
if (map !== null) {
sourcemapChain.push(map || { missing: true, plugin: plugin.name });
}
return result.code;
};
开发者ID:IvanSanchez,项目名称:rollup,代码行数:28,代码来源:transformChunk.ts
示例3: extract_sourcemap
modules.forEach(module => {
if (!/\.css$/.test(module)) return;
const css = css_map.get(module);
const { code, map } = extract_sourcemap(css, module);
parts.push(code);
if (map) {
const lines = codec.decode(map.mappings);
if (combined_map.sources.length > 0 || combined_map.names.length > 0) {
lines.forEach(line => {
line.forEach(segment => {
// adjust source index
segment[1] += combined_map.sources.length;
// adjust name index
if (segment[4]) segment[4] += combined_map.names.length;
});
});
}
combined_map.sources.push(...map.sources);
combined_map.sourcesContent.push(...map.sourcesContent);
combined_map.names.push(...map.names);
mappings.push(...lines);
}
});
开发者ID:varholak-peter,项目名称:sapper,代码行数:31,代码来源:extract_css.ts
示例4:
const renderChunkReducer = (code: string, result: any, plugin: Plugin): string => {
if (result == null) return code;
if (typeof result === 'string')
result = {
code: result,
map: undefined
};
const map = typeof result.map === 'string' ? JSON.parse(result.map) : result.map;
if (map && typeof map.mappings === 'string') map.mappings = decode(map.mappings);
// strict null check allows 'null' maps to not be pushed to the chain, while 'undefined' gets the missing map warning
if (map !== null) sourcemapChain.push(map || { missing: true, plugin: plugin.name });
return result.code;
};
开发者ID:tivac,项目名称:rollup,代码行数:17,代码来源:renderChunk.ts
注:本文中的sourcemap-codec.decode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论