當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。