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


TypeScript ramda.propOr函数代码示例

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


在下文中一共展示了propOr函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

const getBasePathFilter = (pathParts: string[]): ((data: object | object[]) => object) => {
    return R.compose(
        R.head,
        R.filter(
            R.compose(
                R.equals(`/${R.propOr('', 0, pathParts)}`),
                getRoute
            )
        ),
        wrap
    );
};
开发者ID:benjambles,项目名称:my-own-world,代码行数:12,代码来源:index.ts

示例2: splitBySelector

const extractExamples = (senseOrExampleGroupMarkup: string) => {
    const examples = R.pipe(
        splitBySelector({ selector: '.EXAMPLE', onlyChildren: true }),
        R.map(
            R.pipe(
                domify,
                R.propOr('', 'textContent'),
                cleanse
            )
        )
    )(senseOrExampleGroupMarkup)

    return examples
}
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:14,代码来源:extractExamples.ts

示例3:

    const transformedAssociations = R.map(association => {
      const primaryKey = _.first(AppContext.adapters.models.getPrimaryKeys(association.name));
      let value;

      if (_.isArrayLike(association.value)) {
        value = association.value
          ? R.map(entity => R.propOr(entity, primaryKey, entity))(association.value)
          : undefined;
      } else {
        value = association.value
          ? R.propOr(association.value, primaryKey, association.value)
          : undefined;
      }
      logger.debug(TAG, 'handle association', { association, value, primaryKey });
      return { ...association, value };
    })(pairedWrappedAssociations);
开发者ID:danielwii,项目名称:asuna-admin,代码行数:16,代码来源:async.ts

示例4: async

export const send = async (ctx: Koa.Context, error: iError, data: Function): Promise<void> => {
    try {
        const response: ApiResponse = await data(ctx);
        const status = R.propOr(200, 'status', response);

        ctx.status = status;
        ctx.body = maybeProp('parts', response).fold(
            () => R.propOr('', 'data', response),
            ({ meta = {}, body = {} }) => ({
                meta: {
                    ...meta,
                    status,
                    message: responseStatuses.success
                },
                body
            })
        );
    } catch (e) {
        sendError(ctx, e, error);
    }
};
开发者ID:benjambles,项目名称:my-own-world,代码行数:21,代码来源:index.ts

示例5: select

const menuSagaFunctions = {
  *init() {
    try {
      const { roles, user } = yield select((state: RootState) => state.security);

      if (user) {
        if (roles && roles.items) {
          const currentRoles = R.compose(
            R.filter(role => {
              // 判断返回的是否是 ids
              if (user.roles && _.isObjectLike(user.roles[0])) {
                return R.contains(role.id)(R.values(R.pluck('id', user.roles)));
              }
              return R.contains(role.id)(user.roles);
            }),
            R.propOr([], 'items'),
          )(roles);
          logger.debug('[init]', 'current roles is', currentRoles);

          const isSysAdmin = !!R.find(role => role.name === 'SYS_ADMIN')(currentRoles);
          logger.debug('[init]', 'current user isSysAdmin', isSysAdmin);

          const authoritiesList = R.compose(
            // remove null values
            R.filter(R.identity),
            // 后端返回字符串时需要反序列化为 JSON
            R.map(role => {
              const each = R.prop('authorities')(role);
              return R.is(String, each) ? JSON.parse(each) : each;
            }),
          )(currentRoles);
开发者ID:danielwii,项目名称:asuna-admin,代码行数:31,代码来源:menu.redux.ts

示例6: keys

  // keys :: {k: v} → [k]
  keys(obj) {
    return R.keys(obj)
  },
  // values :: {k: v} → [v]
  values(obj) {
    return R.values(obj)
  },

  // prop :: s → {s: a} → a | Undefined
  prop(obj) {
    return R.prop(obj)
  },
  // propOr :: a → String → Object → a
  propOr(defaultVal, fieldsArr, obj) {
    return R.propOr(defaultVal, fieldsArr, obj)
  },
  // [Idx] → {a} → a | Undefined
  // Idx = String | Int
  path(fieldsLevelArr, obj) {
    return R.path(fieldsLevelArr, obj)
  },
  pathOr(defaultVal, fieldsLevelArr, obj) {
    return R.path(defaultVal, fieldsLevelArr, obj)
  },
  // pick :: [k] → {k: v} → {k: v}
  pick(fieldsArr, obj) {
    return R.pick(fieldsArr, obj)
  },

  // assoc/assocPath
开发者ID:stefaniepei,项目名称:react-redux-scaffold,代码行数:31,代码来源:ramda.ts

示例7: propOr

export const getDisplayNameForGroup = (key: string) =>
  propOr('Other', key, groupNameMap);
开发者ID:linode,项目名称:manager,代码行数:2,代码来源:images.ts

示例8: BundleAnalyzerPlugin

          output: {
            wrap_iife: true
          }
        }
      })
    ]
  },
  plugins: [
    new BundleAnalyzerPlugin({
      analyzerMode: 'static',
      reportFilename: path.join('..', 'report.html')
    }),
    new MiniCssExtractPlugin({
      filename: path.join('css', '[name].css')
    }),
    new ZipPlugin({
      filename: `${pkg.version}.zip`
    })
  ]
}

const getMergedConfigByEnv = R.converge(R.mergeDeepWith(R.concat), [
  R.prop('default'),
  R.propOr({}, nodeEnv)
])
export default getMergedConfigByEnv({
  default: defaultConfig,
  development: developmentConfig,
  production: productionConfig
})
开发者ID:foray1010,项目名称:Popup-my-Bookmarks,代码行数:30,代码来源:webpack.config.ts


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