• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.compose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: exec

    exec('git branch --no-color -a', options, (error, stdout, stderr) => {
      if (stderr || error) return reject(stderr || error);

      const getCurrentBranch = R.compose(
        R.trim,
        R.replace('*', ''),
        R.find(line => line.startsWith('*')),
        R.split('\n')
      );

      const processBranches = R.compose(
        R.filter(br => stdout.match(new RegExp(`remotes\/.*\/${br}`))),
        R.uniq
      );

      const currentBranch = getCurrentBranch(stdout);
      const branches = processBranches([currentBranch, defaultBranch]);

      return excludeCurrentRevision
        ? resolve(branches)
        : getCurrentRevision(exec, projectPath)
            .then((currentRevision) => {
              return resolve(branches.concat(currentRevision));
            });
    });
开发者ID:d4rkr00t,项目名称:vscode-open-in-github,代码行数:25,代码来源:common.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

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


示例4:

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


示例5: wrapForeignOpt

export const associationDecorator = ({ modelName, fields }: { modelName: string; fields }) => {
  const TAG = '[associationDecorator]';
  logger.log(TAG, { fields });

  // prettier-ignore
  const associationFields = R.filter(R.compose(R.not, R.isNil, R.prop('associations')))(fields);
  logger.log(TAG, { associationFields }, R.not(R.isEmpty(associationFields)));
  if (R.not(R.isEmpty(associationFields))) {
    const wrapForeignOpt = R.map(opt => ({
      ...opt,
      association: AppContext.adapters.models.getAssociationConfigs(opt.modelName),
    }));
    const withAssociations = R.mapObjIndexed(field => ({
      ...field,
      foreignOpts: wrapForeignOpt(field.foreignOpts),
    }))(associationFields);
    logger.debug(TAG, { withAssociations, wrapForeignOpt });

    const wrappedFields = R.mergeDeepRight(fields, withAssociations);
    logger.debug(TAG, { wrappedFields });

    return { modelName, fields: wrappedFields };
  }

  return { modelName, fields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:26,代码来源:index.ts


示例6: set

export const setData = <T>(
  data: T,
  /**
   * If a schema is provided, execute its validate method. If the validation fails, the
   * errors will be set at L.validationError's path.
   */
  schema?: ObjectSchema<T>,
  /**
   * postValidationTransform will be applied to the data just before it's set on the configuration
   * object, after the validation has happened. Use with caution: It was created as a trap door for
   * merging IPv4 addresses and ports in the NodeBalancer creation flow.
   */
  postValidationTransform?: (v: any) => any
) => {
  if (!schema) {
    return set(L.data, data);
  }

  const updatedData =
    typeof postValidationTransform === 'function'
      ? postValidationTransform(data)
      : data;

  try {
    schema.validateSync(data, { abortEarly: false });
    return set(L.data, updatedData);
  } catch (error) {
    return compose(
      set(L.data, updatedData),
      set(L.validationErrors, convertYupToLinodeErrors(error))
    );
  }
};
开发者ID:linode,项目名称:manager,代码行数:33,代码来源:index.ts


示例7:

const extractItemsBy = primaryKey =>
  R.compose(
    R.uniqBy(R.prop(primaryKey)),
    R.flatten,
    R.map(R.path(['data', 'items'])),
    R.flatten,
  );
开发者ID:danielwii,项目名称:asuna-admin,代码行数:7,代码来源:async.ts


示例8: formatRemotes

export function formatRemotes(remotes: string[]) : string[] {
  const process = R.compose(
    R.uniq,
    R.map(R.replace(/\/$/, '')),
    R.reject(R.isEmpty),
    R.map(R.replace(/\n/, '')),
    R.map(R.trim),
    R.map(rem => rem.replace(/\/\/(.+)@github/, '//github')),
    R.map(rem =>
      rem.match(/github\.com/)
        ? rem.replace(/\.git(\b|$)/, '')
        : rem),
    R.reject(R.isNil),
    R.map(rem => {
      if (rem.match(/^https?:/)) {
        return rem.replace(/\.git(\b|$)/, '');
      } else if (rem.match(/@/)) {
        return 'https://' +
          rem
            .replace(/^.+@/, '')
            .replace(/\.git(\b|$)/, '')
            .replace(/:/g, '/');
      } else if (rem.match(/^ftps?:/)) {
        return rem.replace(/^ftp/, 'http');
      } else if (rem.match(/^ssh:/)) {
        return rem.replace(/^ssh/, 'https');
      } else if (rem.match(/^git:/)) {
        return rem.replace(/^git/, 'https');
      }
    })
  );

  return process(remotes);
}
开发者ID:d4rkr00t,项目名称:vscode-open-in-github,代码行数:34,代码来源:common.ts


示例9: isFeedItem

function isFeedItem(x:OutlineFeedParent|OutlineFolderParent):x is OutlineFeedParent {
    return compose(
        lt(0),
        length,
        path(['$', 'xmlUrl'])
    )(x)
}
开发者ID:r-k-b,项目名称:newsblur-feed-info,代码行数:7,代码来源:index.ts


示例10: compose

 process.nextTick(function () {
   if (!state) { return; }
   compose(
     modulesCheckMessage,
     compiledMessage
   )(stats);
 });
开发者ID:ArtemGovorov,项目名称:reactjs-hackathon-kit,代码行数:7,代码来源:webpack-compiler.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.concat函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.clone函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap