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


TypeScript lodash.chain函数代码示例

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


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

示例1: configureAvailableSecurityGroups

  public configureAvailableSecurityGroups(command: IEcsServerGroupCommand): void {
    if (command.subnetType == null) {
      command.backingData.filtered.securityGroups = [];
      return;
    }

    const vpcId = chain(command.backingData.subnets)
      .filter({
        account: command.credentials,
        region: command.region,
        purpose: command.subnetType,
      })
      .compact()
      .uniqBy('purpose')
      .map('vpcId')
      .value()[0];

    if (
      command.backingData.securityGroups[command.credentials] &&
      command.backingData.securityGroups[command.credentials]['ecs'] &&
      command.backingData.securityGroups[command.credentials]['ecs'][command.region]
    ) {
      const allSecurityGroups = command.backingData.securityGroups[command.credentials]['ecs'][command.region];
      command.backingData.filtered.securityGroupNames = chain(allSecurityGroups)
        .filter({ vpcId: vpcId })
        .map('name')
        .value();
    }
  }
开发者ID:mizzy,项目名称:deck,代码行数:29,代码来源:serverGroupConfiguration.service.ts

示例2: normalizeLoadBalancer

  public normalizeLoadBalancer(loadBalancer: IAmazonLoadBalancer): IPromise<IAmazonLoadBalancer> {
    this.normalizeServerGroups(loadBalancer.serverGroups, loadBalancer, 'loadBalancers', 'LoadBalancer');

    let serverGroups = loadBalancer.serverGroups;
    if ((loadBalancer as IAmazonApplicationLoadBalancer).targetGroups) {
      const appLoadBalancer = loadBalancer as IAmazonApplicationLoadBalancer;
      appLoadBalancer.targetGroups.forEach(targetGroup => this.normalizeTargetGroup(targetGroup));
      serverGroups = flatten<IAmazonServerGroup>(map(appLoadBalancer.targetGroups, 'serverGroups'));
    }

    loadBalancer.loadBalancerType = loadBalancer.loadBalancerType || 'classic';
    loadBalancer.provider = loadBalancer.type;

    this.normalizeActions(loadBalancer as IAmazonApplicationLoadBalancer);

    const activeServerGroups = filter(serverGroups, { isDisabled: false });
    loadBalancer.instances = chain(activeServerGroups)
      .map('instances')
      .flatten<IInstance>()
      .value();
    loadBalancer.detachedInstances = chain(activeServerGroups)
      .map('detachedInstances')
      .flatten<IInstance>()
      .value();
    this.updateHealthCounts(loadBalancer);
    return VpcReader.listVpcs().then(
      (vpcs: IVpc[]) => this.addVpcNameToContainer(loadBalancer)(vpcs) as IAmazonLoadBalancer,
    );
  }
开发者ID:mizzy,项目名称:deck,代码行数:29,代码来源:loadBalancer.transformer.ts

示例3: buildInstanceCounts

  private buildInstanceCounts(serverGroups: IServerGroup[]): IInstanceCounts {
    const instanceCounts = chain(serverGroups)
      .map(serverGroup => serverGroup.instances)
      .flatten()
      .reduce(
        (acc: IInstanceCounts, instance: any) => {
          acc[camelCase(instance.health.state) as keyof IInstanceCounts]++;
          return acc;
        },
        {
          up: 0,
          down: 0,
          outOfService: 0,
          succeeded: 0,
          failed: 0,
          unknown: 0,
          starting: 0,
        },
      )
      .value();

    instanceCounts.outOfService += chain(serverGroups)
      .map(serverGroup => serverGroup.detachedInstances)
      .flatten()
      .value().length;

    return instanceCounts;
  }
开发者ID:mizzy,项目名称:deck,代码行数:28,代码来源:transformer.ts

示例4: await

    const uniqueValues = await (async (): Promise<Relation<string[]>> => {
      let allValues = {
        accounts     : [],
        categories   : [],
        subcategories: [],
        payeePayers  : [],
        tags         : []
      } as Relation<string[]>;
      importedCsv.forEach((item) => {
        allValues.accounts     .push(item['Account']);
        allValues.accounts     .push(item['AccountTo']);
        allValues.categories   .push(item['Category']);
        allValues.subcategories.push(item['Subcategory']);
        allValues.payeePayers  .push(item['Payee/Payer']);
        allValues.tags         .push(item['Tag']);
      });

      return {
        accounts     : lodash.chain(allValues.accounts)     .uniq().value(),
        categories   : lodash.chain(allValues.categories)   .uniq().value(),
        subcategories: lodash.chain(allValues.subcategories).uniq().value(),
        payeePayers  : lodash.chain(allValues.payeePayers)  .uniq().value(),
        tags         : lodash.chain(allValues.tags)         .uniq().value()
      };
    })();
开发者ID:armorik83,项目名称:reveal-wealth,代码行数:25,代码来源:import-facade.service.ts

示例5: normalizeTargetGroup

  private normalizeTargetGroup(targetGroup: ITargetGroup): IPromise<ITargetGroup> {
    this.normalizeServerGroups(targetGroup.serverGroups, targetGroup, 'targetGroups', 'TargetGroup');

    const activeServerGroups = filter(targetGroup.serverGroups, { isDisabled: false });
    targetGroup.provider = targetGroup.type;
    targetGroup.instances = chain(activeServerGroups)
      .map('instances')
      .flatten<IInstance>()
      .value();
    targetGroup.detachedInstances = chain(activeServerGroups)
      .map('detachedInstances')
      .flatten<IInstance>()
      .value();
    this.updateHealthCounts(targetGroup);

    return $q.all([VpcReader.listVpcs(), AccountService.listAllAccounts()]).then(([vpcs, accounts]) => {
      const tg = this.addVpcNameToContainer(targetGroup)(vpcs) as ITargetGroup;

      tg.serverGroups = tg.serverGroups.map(serverGroup => {
        const account = accounts.find(x => x.name === serverGroup.account);
        const cloudProvider = serverGroup.cloudProvider || (account && account.cloudProvider);

        serverGroup.instances.forEach(instance => {
          instance.cloudProvider = cloudProvider;
          instance.provider = cloudProvider;
        });

        return { ...serverGroup, cloudProvider };
      });

      return tg;
    });
  }
开发者ID:mizzy,项目名称:deck,代码行数:33,代码来源:loadBalancer.transformer.ts

示例6: convert

export function convert(docs: swagger.ApiDefinition, resource?: string): string {

    let resources = _.pick(docs.paths, (operations: any, path: string) => resource ? repository.normalize(path).startsWith(resource) : true)

    let pathLength = 25
    let methodLength = 3
    
    _.chain(resources)
        .forEach((operations, path: string) => {
            _.chain(operations)
                .forEach((operation, method: string) => {
                    methodLength = Math.max(method.length, methodLength)
                })
                .value()             
            pathLength = Math.max(path.length, pathLength)
        })
        .value();

    methodLength = methodLength + 2

    return _.chain(resources)
        .map((operations: swagger.PathsObject, path: string) => {
            return _.chain(operations)
                .map((operation: swagger.OperationObject, method: string) =>
                    `${sprintf(`%-${methodLength}s`, '['+method+']')} ${sprintf(`%-${pathLength}s`, path)} [[b;#fff;]${operation.summary}]`
                )
                .value()
                .join('\n');
        })
        .value()
        .join('\n');
}
开发者ID:designing-experiences,项目名称:webconsole,代码行数:32,代码来源:describe.ts

示例7:

 ).map(([sentences, answers]) => [
     _.chain(sentences).map(
         sentence => sentence.words.filter(
             word => sentence.missing_words_positions.indexOf(sentence.words.indexOf(word)) >= 0
         )
     ).flatten().value() as String[],
     _.chain(answers).map(answer => _.values(answer)).flatten().map((answer: { word: String }) => answer.word).value()
 ]).map(([sentences, answers]) => { console.log(answers); return _.difference(sentences, answers) });
开发者ID:pocmanu,项目名称:angular2-seed-advanced,代码行数:8,代码来源:missing-word-exercise.reducer.ts

示例8: normalizeTargetGroup

  private normalizeTargetGroup(targetGroup: ITargetGroup): IPromise<ITargetGroup> {
    this.normalizeServerGroups(targetGroup.serverGroups, targetGroup, 'targetGroups', 'TargetGroup');

    const activeServerGroups = filter(targetGroup.serverGroups, {isDisabled: false});
    targetGroup.provider = targetGroup.type;
    targetGroup.instances = chain(activeServerGroups).map('instances').flatten<IInstance>().value();
    targetGroup.detachedInstances = chain(activeServerGroups).map('detachedInstances').flatten<IInstance>().value();
    this.updateHealthCounts(targetGroup);

    return this.vpcReader.listVpcs().then((vpcs: IVpc[]) => this.addVpcNameToContainer(targetGroup)(vpcs) as ITargetGroup);
  }
开发者ID:jcwest,项目名称:deck,代码行数:11,代码来源:loadBalancer.transformer.ts

示例9: buildInstanceCounts

  private buildInstanceCounts(serverGroups: ServerGroup[]): InstanceCounts {
    const instanceCounts: InstanceCounts = chain(serverGroups)
      .map('instances')
      .flatten()
      .reduce((acc: InstanceCounts, instance: any) => {
        if (has(instance, 'health.state')) {
          acc[camelCase(instance.health.state)]++;
        }
        return acc;
      }, {up: 0, down: 0, outOfService: 0, succeeded: 0, failed: 0, unknown: 0}).value();

    instanceCounts.outOfService += chain(serverGroups).map('detachedInstances').flatten().value().length;
    return instanceCounts;
  }
开发者ID:brujoand,项目名称:deck,代码行数:14,代码来源:transformer.ts

示例10: get_es

  return get_es("/_aliases").then((indices) => {
    // The aliases endpoint returns a map from index name to metadata about those indexes.
    // e.g.
    //   {
    //     ".kibana-4": {
    //       "aliases": {}
    //     },
    //     "logs-2016-04-02": {
    //       "aliases": {
    //         "last_2days": {},
    //         "last_2weeks": {},
    //         "last_day": {},
    //         "last_week": {}
    //       }
    //     },
    //   }
    // It's much easier to work with a map from alias name to list of indexes in the alias.
    const aliases = {};
    for (const index of Object.keys(indices)) {
      for (const alias of Object.keys(indices[index].aliases)) {
        if (!aliases[alias]) {
          aliases[alias] = [];
        }
        aliases[alias].push(index);
        // Keep the results sorted and unique
        aliases[alias] = _.chain(aliases[alias]).sortBy(_.identity).uniq(true).value();
      }
    }

    return aliases;
  });
开发者ID:Clever,项目名称:elasticsearch-toolbox,代码行数:31,代码来源:elasticsearch.ts


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