本文整理汇总了TypeScript中basic/array.fold函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fold函数的具体用法?TypeScript fold怎么用?TypeScript fold使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fold函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: fold
(result, value) => fold(
toArguments(value),
result,
(result, argument) => (
void tryAdd(result, argument, value),
result
)
)
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:8,代码来源:arguments.ts
示例2: lint
function lint(
projectFile: string,
shared: Shared,
configuration: Configs
): OneOfThree<Issue[], ts.Diagnostic[], Line<Severity>[]> {
const runners = toRunners(configuration);
if (bt.isLuck(runners)) {
const [configured, unconfigured] = partition<bm.Some<Runner<Shared>>, bm.None>(runners.luck, bm.isSome);
if (configured.length > 0) {
const linted = run(
projectFile,
shared,
insteadEach(configured, bm.someOf)
);
if (bt.isLuck(linted)) {
return firstFrom(linted.luck);
} else {
return secondFrom(linted.fuck);
}
} else {
return thirdFrom(
fold(
unconfigured,
[lineFrom(Severity.Info, 'There are no available rules.')],
(result, unconfigured) => append(result, lineFrom(Severity.Info, unconfigured.none))
)
);
}
} else {
return thirdFrom(
fold(
runners.fuck,
[lineFrom(Severity.Error, 'Unable to get runners ready.')],
(result, failure) => append(result, lineFrom(Severity.Error, failure))
)
);
}
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:39,代码来源:starting.ts
示例3:
export function applyFileRule<Options, State, Shared>(
program: ts.Program,
options: Options,
rule: FileRule<Options, State, Shared>,
ruleKey: string,
shared: Shared
): Issue[] {
return rule.toIssues(
ba.fold(
program.getSourceFiles(),
rule.toState(program, options, shared),
(state, file) => rule.enforce(file, program.getTypeChecker(), state, options, ruleKey, shared)
),
options,
shared
);
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:17,代码来源:applying.ts
示例4: viaTarget
(node, state) => {
if (isIdentifier(node)) {
const identifier = node;
state.issues = ba.fold(
state.checks,
state.issues,
(issues, rule) => viaTarget(
identifier,
rule.target,
identifier => rule.regex.test(identifier.text)
? bl.add(issues, issueFrom(node, rule.message, 'invalid-name'))
: issues,
() => issues
)
);
}
return state;
}
开发者ID:aleksey-bykov,项目名称:rules,代码行数:18,代码来源:rule.ts
注:本文中的basic/array.fold函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论