本文整理汇总了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;
})
示例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;
};
示例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);
}
});
示例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;
};