本文整理匯總了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)
}
示例2: transpileMember
export function transpileMember(object: Expression, memberName: MemberName): MemberExpression {
return typeof memberName === 'string' ?
member(object, memberName) :
new MemberExpressionComputed(object, transpileVal(memberName))
}
示例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)
}
示例4: msMember
export function msMember(name: string): Expression {
return member(idMs, name)
}
示例5: msCall
export function msCall(name: string, ...args: Array<Expression>): Expression {
return new CallExpression(member(idMs, name), args)
}
示例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))