当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript magic-string.prependLeft函数代码示例

本文整理汇总了TypeScript中magic-string.prependLeft函数的典型用法代码示例。如果您正苦于以下问题:TypeScript prependLeft函数的具体用法?TypeScript prependLeft怎么用?TypeScript prependLeft使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了prependLeft函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: render

	render(code: MagicString, options: RenderOptions) {
		if (this.argument) {
			this.argument.render(code, options);
			if (this.argument.start === this.start + 6 /* 'return'.length */) {
				code.prependLeft(this.start + 6, ' ');
			}
		}
	}
开发者ID:IvanSanchez,项目名称:rollup,代码行数:8,代码来源:ReturnStatement.ts

示例2: render

	render(code: MagicString, options: RenderOptions) {
		this.left.render(code, options);
		this.right.render(code, options);
		if (options.format === 'system' && this.left.variable && this.left.variable.exportName) {
			code.prependLeft(
				code.original.indexOf('=', this.left.end) + 1,
				` exports('${this.left.variable.exportName}',`
			);
			code.appendLeft(this.right.end, `)`);
		}
	}
开发者ID:tivac,项目名称:rollup,代码行数:11,代码来源:AssignmentExpression.ts

示例3: render

	render(
		code: MagicString,
		options: RenderOptions,
		{ renderedParentType }: NodeRenderOptions = BLANK
	) {
		super.render(code, options);
		if (
			renderedParentType === NodeType.ExpressionStatement &&
			this.callee.type === NodeType.FunctionExpression
		) {
			code.appendRight(this.start, '(');
			code.prependLeft(this.end, ')');
		}
	}
开发者ID:robbie-mac,项目名称:rollup,代码行数:14,代码来源:CallExpression.ts

示例4: render

	render (code: MagicString, options: RenderOptions) {
		if (!this.module.graph.treeshake) {
			super.render(code, options);
		} else {
			if (this.testValue === UNKNOWN_VALUE) {
				super.render(code, options);
			} else {
				const branchToRetain = this.testValue
					? this.consequent
					: this.alternate;

				code.remove(this.start, branchToRetain.start);
				code.remove(branchToRetain.end, this.end);
				if (branchToRetain.type === NodeType.SequenceExpression) {
					code.prependLeft(branchToRetain.start, '(');
					code.appendRight(branchToRetain.end, ')');
				}
				branchToRetain.render(code, options);
			}
		}
	}
开发者ID:zhyt201,项目名称:rollup,代码行数:21,代码来源:ConditionalExpression.ts

示例5: render

	render(code: MagicString, options: RenderOptions) {
		this.left.render(code, options);
		this.right.render(code, options);
		if (options.format === 'system') {
			if (this.left.variable && this.left.variable.exportName) {
				code.prependLeft(
					code.original.indexOf('=', this.left.end) + 1,
					` exports('${this.left.variable.exportName}',`
				);
				code.appendLeft(this.right.end, `)`);
			} else if ('addExportedVariables' in this.left) {
				const systemPatternExports: Variable[] = [];
				this.left.addExportedVariables(systemPatternExports);
				if (systemPatternExports.length > 0) {
					code.prependRight(
						this.start,
						`function (v) {${getSystemExportStatement(systemPatternExports)} return v;} (`
					);
					code.appendLeft(this.end, ')');
				}
			}
		}
	}
开发者ID:robbie-mac,项目名称:rollup,代码行数:23,代码来源:AssignmentExpression.ts

示例6: renderReplacedDeclarations

	private renderReplacedDeclarations(
		code: MagicString,
		options: RenderOptions,
		{ start = this.start, end = this.end, isNoStatement }: NodeRenderOptions
	) {
		const separatedNodes = getCommaSeparatedNodesWithBoundaries(
			this.declarations,
			code,
			this.start + this.kind.length,
			this.end - (code.original.charCodeAt(this.end - 1) === 59 /*";"*/ ? 1 : 0)
		);
		let actualContentEnd, renderedContentEnd;
		if (/\n\s*$/.test(code.slice(this.start, separatedNodes[0].start))) {
			renderedContentEnd = this.start + this.kind.length;
		} else {
			renderedContentEnd = separatedNodes[0].start;
		}
		let lastSeparatorPos = renderedContentEnd - 1;
		code.remove(this.start, lastSeparatorPos);
		let isInDeclaration = false;
		let hasRenderedContent = false;
		let separatorString = '',
			leadingString,
			nextSeparatorString;
		for (const { node, start, separator, contentEnd, end } of separatedNodes) {
			if (
				!node.included ||
				(isIdentifier(node.id) && isReassignedExportsMember(node.id.variable) && node.init === null)
			) {
				code.remove(start, end);
				continue;
			}
			leadingString = '';
			nextSeparatorString = '';
			if (isIdentifier(node.id) && isReassignedExportsMember(node.id.variable)) {
				if (hasRenderedContent) {
					separatorString += ';';
				}
				isInDeclaration = false;
			} else {
				if (
					options.format === 'system' &&
					node.init !== null &&
					isIdentifier(node.id) &&
					node.id.variable.exportName
				) {
					code.prependLeft(
						node.init.start,
						`exports('${node.id.variable.safeExportName || node.id.variable.exportName}', `
					);
					nextSeparatorString += ')';
				}
				if (isInDeclaration) {
					separatorString += ',';
				} else {
					if (hasRenderedContent) {
						separatorString += ';';
					}
					leadingString += `${this.kind} `;
					isInDeclaration = true;
				}
			}
			if (renderedContentEnd === lastSeparatorPos + 1) {
				code.overwrite(lastSeparatorPos, renderedContentEnd, separatorString + leadingString);
			} else {
				code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
				code.appendLeft(renderedContentEnd, leadingString);
			}
			node.render(code, options);
			actualContentEnd = contentEnd;
			renderedContentEnd = end;
			hasRenderedContent = true;
			lastSeparatorPos = separator;
			separatorString = nextSeparatorString;
		}
		if (hasRenderedContent) {
			this.renderDeclarationEnd(
				code,
				separatorString,
				lastSeparatorPos,
				actualContentEnd,
				renderedContentEnd,
				!isNoStatement
			);
		} else {
			code.remove(start, end);
		}
	}
开发者ID:IvanSanchez,项目名称:rollup,代码行数:88,代码来源:VariableDeclaration.ts


注:本文中的magic-string.prependLeft函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。