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


TypeScript ramda.when函数代码示例

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


在下文中一共展示了when函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: curry

export default curry((defaultValue: number, v?: null | string | number) =>
  compose<
    string | number | null | undefined,
    number | null | undefined,
    number>(
      defaultTo(defaultValue),
      when(compose(not, isEmpty), (value: string) => +value),
  )(v));
开发者ID:displague,项目名称:manager,代码行数:8,代码来源:defaultNumeric.ts

示例3: compose

 fs.readdirSync(root).map((name: string) =>
     compose(
         getOrElse(null),
         when(isDirectory, filePath =>
             getPrefixedRoutesFromMap(getPrefixedRoute)(
                 requireFilePath(filePath, 'index.js'),
                 requireFilePath(filePath, 'config.json')
             )
         )
     )(resolve(root, name))
开发者ID:benjambles,项目名称:my-own-world,代码行数:10,代码来源:load-routes.ts

示例4: async

    return async (ctx, next) => {
        R.when(isTruthy, () => {
            const roles = R.pathOr([], ['state', 'accessRoles'], ctx) as string[];
            const hasAccess = roles.some(accessMap(ctx));

            if (roles.length && !hasAccess) ctx.throw(401, 'Unauthorised access to endpoint');
        })(accessMap);

        await next();
    };
开发者ID:benjambles,项目名称:my-own-world,代码行数:10,代码来源:index.ts

示例5: when

export const setHeaders = (headers: any = {}) =>
  when(() => isNotEmpty(headers), set(L.headers, headers));
开发者ID:linode,项目名称:manager,代码行数:2,代码来源:index.ts

示例6:

		const apply = (m, s) => R.when(isModuloOf(m), R.always(s))
开发者ID:sprengerjo,项目名称:katas_js,代码行数:1,代码来源:fizzbuzz.ts


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