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


TypeScript util.member函数代码示例

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


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

示例1: getMember

function getMember(
	object: Expression,
	gotName: string,
	isLazy: boolean,
	isModule: boolean): Expression {
	return isLazy ?
		msCall('lazyProp', object, new LiteralString(gotName)) :
		isModule && compileOptions.checks ?
		msCall('get', object, new LiteralString(gotName)) :
		member(object, gotName)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:11,代码来源:transpileLocals.ts

示例2: transpileMember

export function transpileMember(object: Expression, memberName: MemberName): MemberExpression {
	return typeof memberName === 'string' ?
		member(object, memberName) :
		new MemberExpressionComputed(object, transpileVal(memberName))
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:5,代码来源:transpileMemberName.ts

示例3: transpileBlock

		const body = () => transpileBlock(block, {lead, opReturnType})
		const argAsts = args.map(transpileLocalDeclare)
		const id = opMap(verifyResults.opName(_), identifier)

		switch (kind) {
			case Funs.Async: {
				const plainBody = transpileBlock(block, {opReturnType})
				const genFunc = new FunctionExpression(null, [], plainBody, {generator: true})
				const ret = new ReturnStatement(msCall('async', genFunc))
				return new FunctionExpression(id, argAsts, new BlockStatement(cat(lead, ret)))
			}
			case Funs.Generator:
				return new FunctionExpression(id, argAsts, body(), {generator: true})
			case Funs.Plain:
				// TODO:ES6 Should be able to use rest args in arrow function
				return id === null && opDeclareThis === null && opDeclareRest === null ?
					new ArrowFunctionExpression(argAsts, body()) :
					new FunctionExpression(id, argAsts, body())
			default:
				throw new Error(String(kind))
		}
	})
}

const arraySliceCall = member(member(new ArrayExpression([]), 'slice'), 'call')
const idArguments = new Identifier('arguments')

function focusFun(value: Expression): Expression {
	return new ArrowFunctionExpression([idFocus], value)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:30,代码来源:transpileFun.ts

示例4: msMember

export function msMember(name: string): Expression {
	return member(idMs, name)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:3,代码来源:ms.ts

示例5: msCall

export function msCall(name: string, ...args: Array<Expression>): Expression {
	return new CallExpression(member(idMs, name), args)
}
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:3,代码来源:ms.ts

示例6: Identifier

import Identifier from 'esast/lib/Identifier'
import {LiteralNull, LiteralNumber} from 'esast/lib/Literal'
import ObjectExpression from 'esast/lib/ObjectExpression'
import {ExpressionStatement, ReturnStatement} from 'esast/lib/Statement'
import {member} from 'esast-create-util/lib/util'

export const
	esGlobalError = new Identifier('Error'),
	idBuilt = new Identifier('built'),
	idError = new Identifier('Error'),
	idFocus = new Identifier('_'),
	idLexicalThis = new Identifier('_this'),
	litNull = new LiteralNull(),
	litUndefined = new UnaryExpression('void', new LiteralNumber(0)),
	returnFocus = new ReturnStatement(idFocus),
	esThis = new ThisExpression(),

	declareBuiltBag = new VariableDeclarationLet(
		[new VariableDeclarator(idBuilt, new ArrayExpression([]))]),
	declareBuiltMap = new VariableDeclarationLet([
		new VariableDeclarator(
			idBuilt,
			new NewExpression(member(new Identifier('global'), 'Map'), []))]),
	declareBuiltObj = new VariableDeclarationLet(
		[new VariableDeclarator(idBuilt, new ObjectExpression([]))]),

	declareLexicalThis = new VariableDeclarationLet(
		[new VariableDeclarator(idLexicalThis, esThis)]),
	letLexicalThis = new VariableDeclarationLet([new VariableDeclarator(idLexicalThis)]),
	setLexicalThis = new ExpressionStatement(new AssignmentExpression('=', idLexicalThis, esThis))
开发者ID:mason-lang,项目名称:mason-lang.github.io,代码行数:30,代码来源:esast-constants.ts


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