当前位置: 首页>>代码示例>>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;未经允许,请勿转载。