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


TypeScript ramda.always函數代碼示例

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


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

示例1: sendSubscriptions

    /**
     * Sends all subscribed values to the Reactotron app.
     *
     * @param node The tree to grab the state data from
     */
    function sendSubscriptions(state: any) {
      // this is unreadable
      const changes = pipe(
        map(when(isNil, always(""))) as any,
        filter(endsWith(".*")),
        map((key: string) => {
          const keyMinusWildcard = slice(0, -2, key)
          const value = dotPath(keyMinusWildcard, state)
          if (is(Object, value) && !isNilOrEmpty(value)) {
            return pipe(keys, map(key => `${keyMinusWildcard}.${key}`))(value)
          }
          return []
        }) as any,
        concat(map(when(isNil, always("")), subscriptions)),
        flatten,
        reject(endsWith(".*")) as any,
        uniq as any,
        sortBy(identity) as any,
        map((key: string) => ({
          path: key,
          value: isNilOrEmpty(key) ? state : dotPath(key, state),
        })),
      )(subscriptions)

      reactotron.stateValuesChange(changes)
    }
開發者ID:nick121212,項目名稱:reactotron,代碼行數:31,代碼來源:reactotron-mst.ts

示例2: cond

const swaggerToJoiType = (type: string): string =>
    cond([
        [equals('token'), always('string')],
        [equals('integer'), always('number')],
        [equals('int64'), always('integer')],
        [T, _type => '' + _type]
    ])(type);
開發者ID:benjambles,項目名稱:my-own-world,代碼行數:7,代碼來源:swagger-to-joi-type.ts

示例3: cond

export const getProblemFromStatus = status => {
  return cond([
    [isNil, always(UNKNOWN_ERROR)],
    [in200s, always(NONE)],
    [in400s, always(CLIENT_ERROR)],
    [in500s, always(SERVER_ERROR)],
    [T, always(UNKNOWN_ERROR)],
  ])(status)
}
開發者ID:skellock,項目名稱:apisauce,代碼行數:9,代碼來源:apisauce.ts

示例4: upToConditional

    static upToConditional(n) {
        const isModuloOf = mod => i => i % mod === 0;
        const fb = R.cond([
            [isModuloOf(15), R.always('fizzbuzz')],
            [isModuloOf(5), R.always('buzz')],
            [isModuloOf(3), R.always('fizz')],
            [R.T, i => '' + i]
        ]);

        return R.map(fb, R.range(1, R.inc(n)));
	}
開發者ID:sprengerjo,項目名稱:katas_js,代碼行數:11,代碼來源:fizzbuzz.ts

示例5: compose

getIdOrNullFor = type => compose(
  ifElse(isNil, always(null), compose(
    ifElse(
      contains(type),
      compose<string, string[], string, number, Record<string, number>>(
        objOf(`${type}_id`), Number, last, split('-'),
      ),
      always(null),
    ),
  )),
);
開發者ID:displague,項目名稱:manager,代碼行數:11,代碼來源:createDevicesFromStrings.ts

示例6: upToLookUp

    static upToLookUp(n) {
        const s = R.toString
        const f = R.always('fizz');
        const b = R.always('buzz');
        const fb = R.always(f() + b());
        const funs = [s, s, f, s, b, f, s, s, f, b, s, f, s, s, fb];

        const selectFun: any = (n) => R.nth(R.modulo(R.dec(n), 15), funs);
        const fizzBuzzify = (n) => R.call(selectFun(n), n);

        return R.map(fizzBuzzify, R.range(1, R.inc(n)));
    }
開發者ID:sprengerjo,項目名稱:katas_js,代碼行數:12,代碼來源:fizzbuzz.ts

示例7: initialize

  public async initialize(): Promise<void> {
    const container = new InvocationContainer({
      defaults: {
        conventionCalls: ['initialize'],
      },
    });

    const fileNames = ['fizzy.bpmn', 'fizzy_upto.bpmn'];

    for (const name of fileNames) {
      const processFilePath = './src/process_engine/' + name;
      const bpmn = fs.readFileSync(processFilePath, 'utf8');
      await container.registerObject('boilerplate', bpmn)
        .setTag('bpmn_process', 'internal')
        .setTag('path', processFilePath);
    }

    for (const iocModule of iocModules) {
      iocModule.registerInContainer(container);
    }

    container.validateDependencies();

    try {
      const bootstrapper: any = await container.resolveAsync('AppBootstrapper');
      await bootstrapper.start();

      const iamService: any = await container.resolveAsync('IamService');

      iamService.authService.getIdentity = R.always({});
      iamService.hasClaim = R.always(true);

      this.processEngineService = await container.resolveAsync('ProcessEngineService');
      this.context = await iamService.createInternalContext('lizard');
    }
    catch (error) {
      // nothing to be done
      console.error(error);
    }
  }
開發者ID:sprengerjo,項目名稱:katas_js,代碼行數:40,代碼來源:process_engine_boilerplate.ts

示例8: buildJoiSpec

 (acc, [method, spec]) =>
     Maybe.of(concat)
         .ap(parseSecuritySpec(spec))
         .ap(parseRouteSpec(spec, routeHandlers))
         .map(handler => [
             {
                 method,
                 path,
                 handler,
                 validate: buildJoiSpec(Joi, spec),
                 meta: pick(['summary', 'description'], spec)
             }
         ])
         .fold(always(acc), concat(acc)),
開發者ID:benjambles,項目名稱:my-own-world,代碼行數:14,代碼來源:get-route-mapping.ts

示例9: it

 it('0 pin games score is 0', () => {
   const rolls = times(always(0), 20);
   expect(score(rolls)).toEqual(0)
 });
開發者ID:sprengerjo,項目名稱:katas_js,代碼行數:4,代碼來源:bowling_score_calculator.spec.ts


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