本文整理汇总了TypeScript中basic/tried.insteadFuck函数的典型用法代码示例。如果您正苦于以下问题:TypeScript insteadFuck函数的具体用法?TypeScript insteadFuck怎么用?TypeScript insteadFuck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insteadFuck函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: toOptions
export function toRunner<Options, State, Shared>(
ruleKey: string,
configs: Configs,
toOptions: (config: {}) => bt.Tried<Options, string[]>,
rule: FileRule<Options, State, Shared>
): bt.Tried<bo.Optional<Runner<Shared>>, string[]> {
const config = configs[ruleKey];
if (config !== undefined) {
return bt.insteadFuck(
bt.insteadLuck(
toOptions(config),
options => {
const runner = runnerFrom(
ruleKey,
(program, shared) => applyFileRule(program, options, rule, ruleKey, shared)
);
return bo.someFrom(runner)
}
),
problems => ba.insteadEach(
problems,
problem => 'Rule \'' + ruleKey + '\' has invalid configuration. ' + problem
)
);
} else {
return bt.luckFrom(
bo.noneFrom('Rule \'' + ruleKey + '\' is disabled due to not being configured.')
);
}
}
示例2: readClusion
export function readClusion(config: ClusionConfig): Tried<RegExp, string>[] {
if (br.isString(config)) {
return [insteadFuck(toRegexp(config), messageOf)];
} else if (br.isArray(config)) {
return ba.insteadEach(
ba.insteadEach(
config,
config => br.isString(config)
? insteadFuck(toRegexp(config), messageOf)
: readRegexp(config)
),
(tried, index) => insteadFuck(tried, fuck => 'At #' + index + ': ' + fuck)
);
} else {
return [readRegexp(config)]
}
}
示例3: insteadFuck
(tried, index) => insteadFuck(tried, fuck => 'At #' + index + ': ' + fuck)
示例4: readRegexp
export function readRegexp(config: RegexpConfig): Tried<RegExp, string> {
return config.pattern === undefined
? fuckFrom('The "pattern" property is missing in a regex configuration object.')
: insteadFuck(toRegexp(config.pattern, config.flags), messageOf)
}
示例5: Trying
inFail<c>(within: (value: b) => c): Trying<a, c> {
return new Trying(insteadFuck(this.value, within));
}