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


TypeScript ramda.compose函数代码示例

本文整理汇总了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;未经允许,请勿转载。