當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript tried.fuckFrom函數代碼示例

本文整理匯總了TypeScript中basic/tried.fuckFrom函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fuckFrom函數的具體用法?TypeScript fuckFrom怎麽用?TypeScript fuckFrom使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fuckFrom函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: isSome

 (built, recognized) => isSome(recognized)
     ? luckFrom(
         take(
             built,
             recognized.some
         )
     )
     : fuckFrom([recognized.none]),
開發者ID:aleksey-bykov,項目名稱:commandlining,代碼行數:8,代碼來源: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: readClusions

export function readClusions(config: ClusionsConfig): Crooked<Clusions, string[]> {
    const include = config.include === undefined
        ? [fuckFrom('The \'include\' property of a file filter is unspecified.')]
        : readClusion(config.include);
    const exclude = config.exclude === undefined
        ? []
        : readClusion(config.exclude);

    const [included, notIncluded] = partitionAsOfTried(include);
    const [excluded, notExcluded] = partitionAsOfTried(exclude);
    return crookedFrom(
        clusionsFrom(included, excluded),
        ba.concat(
            ba.insteadEach(notIncluded, problem => 'Invalid include. ' + problem),
            ba.insteadEach(notExcluded, problem => 'Invalid exclude. ' + problem)
        )
    );
}
開發者ID:aleksey-bykov,項目名稱:linting,代碼行數:18,代碼來源:file-filter.ts

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

示例6: allOrNothing

export function allOrNothing(crooked: Crooked<Clusions, string[]>): Tried<Clusions, string[]> {
    return crooked.fuck.length > 0 ? fuckFrom(crooked.fuck) : luckFrom(crooked.luck);
}
開發者ID:aleksey-bykov,項目名稱:linting,代碼行數:3,代碼來源:file-filter.ts

示例7: 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)
}
開發者ID:aleksey-bykov,項目名稱:linting,代碼行數:5,代碼來源:file-filter.ts

示例8: fuckFrom

import * as ba from 'basic/array';
import * as br from 'basic/runtime';
import { partitionAsOfTried } from 'basic/tried-array';
import { messageOf } from 'basic/problem';
import { toRegexp } from "basic/text";
import { insteadFuck, fuckFrom, Tried, Crooked, luckFrom, insteadLuck, crookedFrom } from "basic/tried";

export interface RegexpConfig { pattern?: string, flags?: string }
export type ClusionConfig = string | (string | RegexpConfig)[] | RegexpConfig;

export const fuckingUnspecified = fuckFrom('Unspecified');

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)
}

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)
        );
開發者ID:aleksey-bykov,項目名稱:linting,代碼行數:31,代碼來源:file-filter.ts

示例9: fail

export function fail(code: ErrorCode, message: string): Fuck<Error> {
    debugger;
    return fuckFrom(errorFrom(code, message));
}
開發者ID:aleksey-bykov,項目名稱:commandlining,代碼行數:4,代碼來源:failing.ts

示例10: toOptions

export function toOptions(config: {}): Tried<Options, string[]> {
    return isOptions(config) ? luckFrom(config) : fuckFrom(['Invalid config.']);
}
開發者ID:aleksey-bykov,項目名稱:rules,代碼行數:3,代碼來源:rule.ts


注:本文中的basic/tried.fuckFrom函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。