當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。