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


TypeScript lodash.matches函数代码示例

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


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

示例1: it

    it('should correctly disable krs emails when creating backup keychains', co(function *() {
      const params = {
        label: 'my_wallet',
        disableKRSEmail: true,
        backupXpubProvider: 'test',
        passphrase: 'test123',
        userKey: 'xpub123'
      };

      // bitgo key
      nock(bgUrl)
      .post('/api/v2/tbtc/key', _.matches({ source: 'bitgo' }))
      .reply(200);

      // user key
      nock(bgUrl)
      .post('/api/v2/tbtc/key', _.conforms({ pub: (p) => p.startsWith('xpub') }))
      .reply(200);

      // backup key
      nock(bgUrl)
      .post('/api/v2/tbtc/key', _.matches({ source: 'backup', provider: params.backupXpubProvider, disableKRSEmail: true }))
      .reply(200);

      // wallet
      nock(bgUrl)
      .post('/api/v2/tbtc/wallet')
      .reply(200);

      yield wallets.generateWallet(params);
    }));
开发者ID:BitGo,项目名称:BitGoJS,代码行数:31,代码来源:wallets.ts

示例2: findRoutes

export default function findRoutes(routerAst): RouteNode {
  let routeFn;
  let isRouteMap = _.matches({
    callee: {
      object: { name: 'Router' },
      property: { name: 'map' }
    }
  });

  recast.visit(routerAst, {
    visitCallExpression(path) {
      let node = path.node;
      if (isRouteMap(node)) {
        routeFn = node;
      }
      return false;
    }
  });

  let appRoute: RouteNode = {
    node: routeFn,
    parent: null,
    children: null,
    moduleName: 'application',
    name: 'application'
  };

  appRoute.children = findChildRoutes(routeFn, appRoute);

  return appRoute;
}
开发者ID:Bestra,项目名称:ember-analyzer,代码行数:31,代码来源:routeGraph.ts

示例3: findChildRoutes

function findChildRoutes(routeFnNode: ESTree.FunctionExpression, parentRoute) {
  let routeNodes: any[] = [];
  let isRoute = _.matches({
    callee: {
      object: { type: 'ThisExpression' },
      property: { name: 'route' }
    }
  });
  recast.visit(routeFnNode, {
    visitCallExpression(path) {
      if (isRoute(path.node) && path.node !== parentRoute.node) {
        routeNodes.push(path.node);
        return false;
      } else {
        this.traverse(path);
      }
    }
  });

  return routeNodes.map(routeCallNode => {
    let child: RouteNode = {
      node: routeCallNode,
      parent: parentRoute,
      children: [],
      moduleName: routeCallNode.arguments[0].value,
      name: routeCallNode.arguments[0].value
    };
    child.children = findChildRoutes(routeCallNode, child);

    return child;
  });
}
开发者ID:Bestra,项目名称:ember-analyzer,代码行数:32,代码来源:routeGraph.ts

示例4: it

    it('arguments', co(function *() {
      const optionalParams = {
        limit: '25',
        minValue: '0',
        maxValue: '9999999999999',
        minHeight: '0',
        minConfirms: '2',
        enforceMinConfirmsForChange: 'false',
        feeRate: '10000',
        maxFeeRate: '100000',
        recipientAddress: '2NCUFDLiUz9CVnmdVqQe9acVonoM89e76df'
      };

      const path = `/api/v2/${wallet.coin()}/wallet/${wallet.id()}/maximumSpendable`;
      const response = nock(bgUrl)
        .get(path)
        .query(_.matches(optionalParams)) // use _.matches to do a partial match on request body object instead of strict matching
        .reply(200, {
          coin: 'tbch',
          maximumSpendable: 65000
        });

      try {
        yield wallet.maximumSpendable(optionalParams);
      } catch (e) {
        // test is successful if nock is consumed
      }

      response.isDone().should.be.true();
    }));
开发者ID:BitGo,项目名称:BitGoJS,代码行数:30,代码来源:wallet.ts

示例5: valueToUrl

export function valueToUrl(
  value,
  {
    host,
    type,
    thumbnail,
  }: {
    host?: string;
    type?: 'image' | 'video' | 'attache' | 'file';
    thumbnail?: { width?: number; height?: number };
  },
) {
  if (value) {
    const hostPrefix =
      host ||
      _.cond([
        [_.matches('image'), _.constant(Config.get('IMAGE_HOST'))],
        [_.matches('video'), _.constant(Config.get('VIDEO_HOST'))],
        [_.matches('attache'), _.constant(Config.get('ATTACHE_HOST'))],
        [_.matches('file'), _.constant(Config.get('FILE_HOST'))],
      ])(type) ||
      '';
    let url = hostPrefix + `/${value}`.replace('//', '/').slice(1);
    if (thumbnail) {
      const template = _.get(AppContext.serverSettings['settings.url-resolver'], 'value.uploads');
      try {
        url = template.replace('{{ url }}', url);
      } catch (e) {
        logger.warn('using template error', { template, url });
      }
      // url += `?imageView2/2/w/${thumbnail.width || 1280}/h/${thumbnail.height ||
      //   1280}/format/jpg/interlace/1/ignore-error/1`;
    }
    logger.debug('[valueToUrl]', { value, url, host });
    return url;
  }
  return '';
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:38,代码来源:url-rewriter.ts


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