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

TypeScript ramda.find函数代码示例

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

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



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


示例16:

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


示例17: find

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


示例18: getEmployee

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


示例19:

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.findIndex函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.filter函数代码示例发布时间: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