本文整理汇总了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
)
)
示例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))
)
);
}
}
示例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
);
}
示例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;
}