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


TypeScript ramda.find函数代码示例

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


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

示例1: matchesToMigration

function matchesToMigration(directory: string, matches: RegExpMatchArray[]): Migration {
  if (matches.length === 1) {
    let match = matches[0];

    // Single match is a split migration file.
    if (match[3]) throw new SplitFileMissingError(match[0]);

    return {
      id: match[1],
      name: match[2],
      split: false,
      path: path.join(directory, match[0])
    };
  } else if (matches.length === 2) {
    let upMatch = R.find(R.propEq(3, 'up'), matches);
    let downMatch = R.find(R.propEq(3, 'down'), matches);

    if (!upMatch) throw new SplitFileMissingError(downMatch[0]);
    if (!downMatch) throw new SplitFileMissingError(upMatch[0]);

    return {
      id: upMatch[1],
      name: upMatch[2],
      split: true,
      upPath: path.join(directory, upMatch[0]),
      downPath: path.join(directory, downMatch[0])
    };
  } else {
    // Too many matches.
    throw new SplitFileConflictError(R.map(m => m[0], matches));
  }
}
开发者ID:programble,项目名称:careen,代码行数:32,代码来源:files.ts

示例2: 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

示例3: createCorrectReplacementSet

  private createCorrectReplacementSet(syllable: string) {
    const vowels = ['a', 'e', 'i', 'o', 'u'];
    const knownVowels = intersection(vowels, this.letters);
    const longVowels = map(vowel => vowel + vowel, vowels);
    const knownLongVowels = map(vowel => vowel + vowel, knownVowels);
    const diphtongs = ['ie', 'ei', 'au', 'eu', 'äu'];
    const umlauts = ['ä', 'ö', 'ü'];

    // start with the sets containing strings of length two!
    const possibleReplacementSetsLowercase = [
      knownLongVowels,
      diphtongs,
      longVowels,
      umlauts,
      knownVowels,
      vowels
    ];
    const possibleReplacementSetsCapitalized = map(
      set => map(capitalizeFirstLetter, set),
      possibleReplacementSetsLowercase
    );
    return find(
      set => set.length > 0 && new RegExp(join('|', set), 'g').test(syllable),
      [
        ...possibleReplacementSetsCapitalized,
        ...possibleReplacementSetsLowercase
      ]
    );
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:29,代码来源:connect-syllables.ts

示例4: getUser

		.map(([claim, users]) => {
			if (claim.approver) {
				const getUser = R.find(R.propEq('$key', claim.approver));
				return Object.assign(claim, { $approver: getUser(users) })
			}

			return claim;
		})
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:8,代码来源:claim.model.ts

示例5: findEntity

  public findEntity(id: string): Optional<AbstractNode> {
    const entity = super.findEntity(id);

    if (entity) {
      return entity;
    }

    const recursiveFind = map(child => child.findEntity(id), this.children);
    return find(found => typeof found !== 'undefined', recursiveFind);
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:10,代码来源:InternalNode.ts

示例6: getPidByPidCode

export function getPidByPidCode (pidstring: string) : PID|null {
  let names:Array<string> = keys(PIDS);

  let pidname:string = find((name:string) => {
    let curpid:PID = PIDS[name];

    return curpid.getPid() === pidstring;
  })(names);

  if (pidname) {
    return PIDS[pidname];
  } else {
    return null;
  }
};
开发者ID:evanshortiss,项目名称:obd-parser,代码行数:15,代码来源:index.ts

示例7: findImmediate

function findImmediate(id: string): User|undefined {
  const userMatches: (user: User|undefined) => boolean = R.propEq('id', id);
  return R.find(userMatches, userStore);
}
开发者ID:MikeyBurkman,项目名称:ts-example,代码行数:4,代码来源:userModel.ts

示例8: compose

import { DataResolver } from './app.resolver';

import { routes as blogRoutes, asyncRoutes as blogAsyncRoutes } from './blog/blog.routing';

import { prop, compose, split, find, trim, equals, nth, ifElse, identity } from 'ramda';

export const appNavLinks: NavigationConfig = [
  ...Pages.navLinks,
  ...Layouts.navLinks,
  ...Authentication.navLinks,
];

const layout = compose(
    ifElse(identity, compose(nth(1), split('=')), identity),
    find(compose(equals('layout'), trim, nth(0), split('='))),
    split(';')
  )(document.cookie);

const layouts = {
  'horizontal': HorizontalLayout,
  'vertical' : VerticalLayout
};

export const routes: RouterConfig = [
  {
    path: '',
    component: layouts[layout],
    children: [
      ...Pages.routes,
      ...Authentication.routes
开发者ID:the-fool,项目名称:attacus-atlas,代码行数:30,代码来源:app.routes.ts

示例9: find

const findStr = (target: string, set: string[]) => find((a: string) => a.toLocaleLowerCase() === target, set)
开发者ID:vtex,项目名称:apps-client-node,代码行数:1,代码来源:setCookie.ts

示例10:

				.map(res => R.find(R.propEq('$key', typeKey))(res))
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:receipt-form.ts

示例11:

      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);
          logger.debug('[init]', 'current authoritiesList is', authoritiesList);

          const authorities = R.reduce(R.mergeWith(R.or), {})(authoritiesList);
          logger.debug('[init]', 'current authorities is', authorities);
开发者ID:danielwii,项目名称:asuna-admin,代码行数:30,代码来源:menu.redux.ts

示例12:

			.map(([onLogin, user, employees]) => onLogin ? R.find(R.propEq('user', user))(employees) : undefined)
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:app.component.ts

示例13: getEmployee

		.map(([userKey, employees]) => {
			const getEmployee = R.find(R.propEq('user', userKey));
			return (getEmployee(employees) && getEmployee(employees).isAdmin) || false;
		})
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:4,代码来源:user.model.ts

示例14:

			R.map((n: any) => Object.assign(n, { $user: R.find(R.propEq('$key', n.user))(users) }))(items));
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:1,代码来源:user.model.ts

示例15:

let safeQuote = (str: string) => R.find(qt => !str.includes(qt));
开发者ID:tycho01,项目名称:html2jade,代码行数:1,代码来源:html2jade.ts


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