• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript tried.luckFrom函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了luckFrom函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: isSome

 luck => isSome(luck)
     ? luck.some !== undefined
         ? luckAsMaybe(read(luck.some))
         : luckFrom(
             noneFrom('No value specified.') // AB: TODO: some name, but no value (needs a special treatment in optional/required)
         )
     : luckFrom(
         noneFrom('No argument specified.') // no name
     )
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:9,代码来源:mapping.ts


示例2: readVerbosity

function readVerbosity(value: string): bt.Tried<Severity, string> {
    const normalized = value.toLowerCase();
    switch (normalized) {
        case 'debug': return bt.luckFrom(Severity.Debug);
        case 'info': return bt.luckFrom(Severity.Info);
        case 'warning': return bt.luckFrom(Severity.Warning);
        case 'error': return bt.luckFrom(Severity.Error);
        default: return bt.fuckFrom('Unexpected value \'' + value + '\' for a verbosity.');
    }
}
开发者ID:aleksey-bykov,项目名称:linting,代码行数:10,代码来源:commandlining.ts


示例3: readFlag

export function readFlag(value: string): Tried<boolean, string> {
    switch (value) {
        case 'true':
        case '1':
        case 'y':
            return luckFrom(true);
        case 'false':
        case '0':
        case 'n':
            return luckFrom(false);
        default:
            return fuckFrom('Unexpected value \'' + value + '\' of a flag argument.');
    }
}
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:14,代码来源:mapping.ts


示例4: 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


示例5: oneOrAnotherOrNeitherButNotBoth

function reading<Before, Value>(
    before: Tried<Before, string[]>,
    all: LooselyParsedResult,
    fullName: string,
    shortName: string | undefined,
    read: (value: string) => Tried<Value, string>
): Finishing<Before, Value> {

    const parsed = shortName !== undefined
        ? oneOrAnotherOrNeitherButNotBoth(
            tryAt(all.fullArgs, fullName),
            tryAt(all.shortArgs, shortName)
        )
        : luckFrom(tryAt(all.fullArgs, fullName));

    // attempt to read a string value as boolean
    const recognized = offTried(
        parsed,
        luck => isSome(luck)
            ? luck.some !== undefined
                ? luckAsMaybe(read(luck.some))
                : luckFrom(
                    noneFrom('No value specified.') // AB: TODO: some name, but no value (needs a special treatment in optional/required)
                )
            : luckFrom(
                noneFrom('No argument specified.') // no name
            )
        ,
        fuck => fuckFrom(fuck)
    );

    return new Finishing(all, before, recognized);
}
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:33,代码来源:mapping.ts


示例6: toRunner

export function toRunners<Shared extends PerNodeShared & PerFileShared>(
    configs: Configs
): bt.Tried<bo.Optional<Runner<Shared>>[], string[]> {

    const all = [
        toRunner('bad-comment', configs, config => readFileFilterOptions(config), building().stateless(toBadComment).perNode().file().perFile(x => x).rule),
        toRunner('no-throw', configs, toEmptyOptions, building().stateless(toNoThrow).perNode().file().perFile(x => x).rule),

        toRunner(
            'no-export-import', configs, config => readFileFilterOptions(config),
            building().stateless(noExportImport).perNode().file().perFile(x => x).rule
        ),

        toRunner('no-primitive-to-self', configs, config => readFileFilterOptions(config), building().stateless(toNoPrimitiveToSelf).perNode().file().perFile(x => x).rule),
        toRunner('no-expressionless-return', configs, toEmptyOptions, building().stateless(toNoExpressionlessReturn).perNode().file().perFile(x => x).rule),
        toRunner('no-unnecessary-annotations', configs, toEmptyOptions, building().stateless(toNoUnnecessaryAnnotations).perNode().file().perFile(x => x).rule),
        toRunner('no-unnecessary-assertions', configs, toEmptyOptions, building().stateless(toNoUnnecessaryAssertions).perNode().file().perFile(x => x).rule),
        toRunner('names-stat', configs, config => {
            const ruleOptions = nameStat.toOptions(config);
            const fileOptions = readFileFilterOptions(config);
            const options = bothLucks(ruleOptions, fileOptions, fuse, concat);
            return options;
        }, building().stateful(nameStat.toRule()).perNode().file().perFile(x => x).rule),
        toRunner(
            'no-const-lambdas', configs, config => readFileFilterOptions(config),
            building().stateless(noConstLambdas).perNode().file().perFile(x => x).rule
        ),
        toRunner('banned-names', configs, toEmptyOptions, building().stateful(toBannedNames).perNode().file().perFile(x => x).rule),
        toRunner('no-symbol', configs, toEmptyOptions, building().stateless(toNoUndeclaredSymbols).perNode().file().perFile(x => x).rule),
        toRunner('const-needed', configs, config => readFileFilterOptions(config), building().stateful(toConstNeeded).perNode().file().perFile(x => x).rule)
    ];

    const [goods, bads] = partition(all);
    return bads.length > 0
        ? bt.fuckFrom(
            ba.concatAll(bads)
        )
        : bt.luckFrom(goods);
}
开发者ID:aleksey-bykov,项目名称:rules,代码行数:39,代码来源:all.ts


示例7: standFrom

export function read<Parsing, Parsed>(
    value: string,
    parsing: Parsing,
    builder: Builder<Parsing>,
    asParsed: (parsing: Parsing) => Optional<Parsed>
): Tried<Parsed, Error> {
    const stand = standFrom(mightNeedCommandOrParameter, []);
    const started = keepReading(parsing, value, 0, stand, builder);
    if (isLuck(started)) {
        const finished = finishReading(started.luck.result, started.luck.stand, builder)
        if (isLuck(finished)) {
            const parsed = asParsed(finished.luck);
            if (isSome(parsed)) {
                return luckFrom(parsed.some);
            } else {
                return toFailedToFindBuilderInParameterState();
            }
        } else {
            return finished;
        }
    } else {
        return started;
    }
}
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:24,代码来源:reading.ts


示例8: toEmptyOptions

export function toEmptyOptions(): bt.Luck<{}> {
    return bt.luckFrom({});
}
开发者ID:aleksey-bykov,项目名称:rules,代码行数:3,代码来源:all.ts


示例9: luckFrom

function luck<State>(parsing: LooselyParsing, state: State): Luck<Expected<State, LooselyParsing>> {
    return luckFrom(expectedFrom(parsing, state));
}
开发者ID:aleksey-bykov,项目名称:commandlining,代码行数:3,代码来源:loose-builder.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript basil.js.default类代码示例发布时间:2022-05-25
下一篇:
TypeScript tried.isLuck函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap