当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript tried.insteadLuck函数代码示例

本文整理汇总了TypeScript中basic/tried.insteadLuck函数的典型用法代码示例。如果您正苦于以下问题:TypeScript insteadLuck函数的具体用法?TypeScript insteadLuck怎么用?TypeScript insteadLuck使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了insteadLuck函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.')
        );
    }
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:30,代码来源:configuring.ts

示例2: readFileFilterOptions

export function readFileFilterOptions(config: any) : Tried<PerFileOptions, string[]> {
    return insteadLuck(
        allOrNothing(
            readClusions(config)
        ),
        files => ({ files })
    );
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:8,代码来源:file-filter.ts

示例3: loadConfigs

export function loadConfigs(
    filePath: string
): bt.Tried<Configs, Problem<FileDoesNotExist | InvalidJson>> {
    return bt.smash(
        bt.insteadLuck(
            readFile(filePath),
            luck => parseJson(luck)
        )
    );
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:10,代码来源:configuring.ts

示例4: Trying

 insteadLuck<c>(within: (value: a) => c): Trying<c, b> {
     return new Trying(insteadLuck(this.value, within));
 }
开发者ID:aleksey-bykov,项目名称:fluent,代码行数:3,代码来源:trying.ts


注:本文中的basic/tried.insteadLuck函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。