本文整理汇总了TypeScript中lodash-es/each.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: generateNode
const generateNode = (ast) => {
if (ast instanceof Ast.BinaryExpr) {
return "(" + generateNode(ast.leftOperand) + ast.operator + generateNode(ast.rightOperand) + ")";
}
if (ast instanceof Ast.UnaryExpr) {
return "(" + ast.operator + generateNode(ast.operand) + ")";
}
if (ast instanceof Ast.FuncCall) {
switch (ast.funcName) {
case "above":
return [
"(",
generateNode(ast.args[0]),
">",
generateNode(ast.args[1]),
"?1:0)",
].join("");
case "below":
return [
"(",
generateNode(ast.args[0]),
"<",
generateNode(ast.args[1]),
"?1:0)",
].join("");
case "equal":
return [
"(",
generateNode(ast.args[0]),
"==",
generateNode(ast.args[1]),
"?1:0)",
].join("");
case "if":
return [
"(",
generateNode(ast.args[0]),
"!==0?",
generateNode(ast.args[1]),
":",
generateNode(ast.args[2]),
")",
].join("");
case "select":
const code = ["((function() {"];
code.push("switch(" + generateNode(ast.args[0]) + ") {");
each(takeRight(ast.args, ast.args.length - 1), (arg, i) => {
code.push("case " + i + ": return " + generateNode(arg) + ";");
});
code.push("default : throw new Error('Unknown selector value in select');");
code.push("}}).call(this))");
return code.join("");
case "sqr":
return "(Math.pow((" + generateNode(ast.args[0]) + "),2))";
case "band":
return "(((" + generateNode(ast.args[0]) + ")&&(" + generateNode(ast.args[1]) + "))?1:0)";
case "bor":
return "(((" + generateNode(ast.args[0]) + ")||(" + generateNode(ast.args[1]) + "))?1:0)";
case "bnot":
return "((!(" + generateNode(ast.args[0]) + "))?1:0)";
case "invsqrt":
return "(1/Math.sqrt(" + generateNode(ast.args[0]) + "))";
case "atan2":
return "(Math.atan((" + generateNode(ast.args[0]) + ")/(" + generateNode(ast.args[1]) + ")))";
default:
let prefix;
const args = map(ast.args, (arg) => generateNode(arg)).join(",");
if (jsMathFuncs.indexOf(ast.funcName) >= 0) {
prefix = "Math.";
} else {
prefix = "this.";
}
return "(" + prefix + ast.funcName + "(" + args + "))";
}
}
if (ast instanceof Ast.Assignment) {
return generateNode(ast.lhs) + "=" + generateNode(ast.expr);
}
if (ast instanceof Ast.Program) {
const stmts = map(ast.statements, (stmt) => generateNode(stmt));
return stmts.join(";\n");
}
if (ast instanceof Ast.PrimaryExpr && ast.type === "VALUE") {
return ast.value.toString();
}
if (ast instanceof Ast.PrimaryExpr && ast.type === "CONST") {
return translateConstants(ast.value).toString();
}
if (ast instanceof Ast.PrimaryExpr && ast.type === "ID") {
return "this." + ast.value;
}
if (ast instanceof Ast.PrimaryExpr && ast.type === "REG") {
return "this.registerBank[\"" + ast.value + "\"]";
}
};
示例2: bindUniforms
// bind state values to uniforms
public bindUniforms(program: ShaderProgram) {
// bind all values
each(this.uniforms, (name) => {
program.setUniform(name, WebGLVarType._1F, this[name]);
});
// bind registers
each(this.glslRegisters, (name) => {
program.setUniform(name, WebGLVarType._1F, this.registerBank[name]);
});
// bind random step value if there are usages of random
if (this.hasRandom) {
const step = [Math.random() / 100, Math.random() / 100];
program.setUniform("__randStep", WebGLVarType._2FV, step);
}
// bind precomputed values
each(this.preCompute, (entry, name) => {
const args = drop(entry).map(arg => {
if (isString(arg)) {
if (arg.substring(0, 5) === "__REG") {
return this.registerBank[arg];
} else {
return this[arg];
}
} else {
return arg;
}
});
const result = this[entry[0]].apply(this, args);
program.setUniform(name, WebGLVarType._1F, result);
});
}
示例3: copyValues
// copies instance values from one code instance to another
public static copyValues(dest: CodeInstance, src: CodeInstance) {
each(src, (value, name) => {
if (!isFunction(value) && name.charAt(0) !== "_") {
dest[name] = value;
}
});
}
示例4: handleErrorResponseNew
protected handleErrorResponseNew(err: Ro.ErrorMap, getFriendlyName: (id: string) => string) {
if (err.invalidReason()) {
return this.returnResult('', err.invalidReason());
}
let msg = Usermessages.pleaseCompleteOrCorrect;
each(err.valuesMap(),
(errorValue, fieldId) => {
msg += this.fieldValidationMessage(errorValue, () => getFriendlyName(fieldId!));
});
return this.returnResult('', msg);
}
示例5: setup
// initializes this codeinstance
public setup(main: IMain) {
this.registerBank = main.getRegisterBank();
this.bootTime = main.getBootTime();
this.analyser = main.getAnalyser();
this.updateDimVars(main.getRctx().getGl());
// clear all used registers
each(this.registerUsages, (name) => {
if (!this.registerBank.hasOwnProperty(name)) {
this.registerBank[name] = 0;
}
});
}
示例6: handleErrorResponse
export function handleErrorResponse(err: Ro.ErrorMap, messageViewModel: IMessageViewModel, valueViewModels: FieldViewModel[]) {
let requiredFieldsMissing = false; // only show warning message if we have nothing else
let fieldValidationErrors = false;
let contributedParameterErrorMsg = '';
each(err.valuesMap(), (errorValue, k) => {
const valueViewModel = find(valueViewModels, vvm => vvm.id === k);
if (valueViewModel) {
const reason = errorValue.invalidReason;
if (reason) {
if (reason === 'Mandatory') {
const r = 'REQUIRED';
requiredFieldsMissing = true;
valueViewModel.description = valueViewModel.description.indexOf(r) === 0 ? valueViewModel.description : `${r} ${valueViewModel.description}`;
} else {
valueViewModel.setMessage(reason);
fieldValidationErrors = true;
}
}
} else {
// no matching parm for message - this can happen in contributed actions
// make the message a dialog level warning.
contributedParameterErrorMsg = errorValue.invalidReason || '';
}
});
let msg = contributedParameterErrorMsg || err.invalidReason() || '';
if (requiredFieldsMissing) { msg = `${msg} Please complete REQUIRED fields. `; }
if (fieldValidationErrors) { msg = `${msg} See field validation message(s). `; }
if (!msg) { msg = err.warningMessage; }
messageViewModel.setMessage(msg);
}