本文整理匯總了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;
};