當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript sourcemap-codec.decode函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。