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

TypeScript lodash.flattenDeep函数代码示例

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

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



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

示例1: it

  it('should assign unique ids for repeated panels', function() {
    dashboardJSON.panels = [
      {
        id: 1,
        type: 'row',
        collapsed: true,
        repeat: 'apps',
        gridPos: { x: 0, y: 0, h: 1, w: 24 },
        panels: [
          { id: 2, type: 'graph', gridPos: { x: 0, y: 1, h: 1, w: 6 } },
          { id: 3, type: 'graph', gridPos: { x: 6, y: 1, h: 1, w: 6 } },
        ],
      },
      { id: 4, type: 'row', gridPos: { x: 0, y: 1, h: 1, w: 24 } },
      { id: 5, type: 'graph', gridPos: { x: 0, y: 2, h: 1, w: 12 } },
    ];
    dashboard = new DashboardModel(dashboardJSON);
    dashboard.processRepeats();

    const panel_ids = _.flattenDeep(
      _.map(dashboard.panels, panel => {
        let ids = [];
        if (panel.panels && panel.panels.length) {
          ids = _.map(panel.panels, 'id');
        }
        ids.push(panel.id);
        return ids;
      })
    );
    expect(panel_ids.length).toEqual(_.uniq(panel_ids).length);
  });
开发者ID:arcolife,项目名称:grafana,代码行数:31,代码来源:repeat.jest.ts


示例2:

    ]).then(results => {

      // combine the annotations and flatten results
      var annotations = _.flattenDeep([results[0], results[1]]);

      // filter out annotations that do not belong to requesting panel
      annotations = _.filter(annotations, item => {
        // shownIn === 1 requires annotation matching panel id
        if (item.source.showIn === 1) {
          if (item.panelId && options.panel.id === item.panelId) {
            return true;
          }
          return false;
        }
        return true;
      });

      // look for alert state for this panel
      var alertState = _.find(results[2], {panelId: options.panel.id});

      return {
        annotations: annotations,
        alertState: alertState,
      };

    }).catch(err => {
开发者ID:casaria,项目名称:grafana-trillium-src-fork,代码行数:26,代码来源:annotations_srv.ts


示例3: textForHtml

 textForHtml(boundVariableLists: string[][]) {
   const name = boundVariableLists[this.level][this.index];
   if (_.countBy(_.flattenDeep(boundVariableLists))[name] > 1) { // Disambiguate variables that appear multiple times in scope
     return this.serialize()
   } else {
     return name;
   }
 }
开发者ID:reavowed,项目名称:prover,代码行数:8,代码来源:Expression.ts


示例4:

 _.forEach(queryResult, result => {
   _.forEach(_.flattenDeep(result.rows), row => {
     variables.push({
       text: row,
       value: row,
     } as AzureLogsVariable);
   });
 });
开发者ID:grafana,项目名称:grafana,代码行数:8,代码来源:response_parser.ts


示例5: relationValueMap

  private async relationValueMap(joinQueryIds: Relation<number[]>): Promise<Relation<Map<number, string>>> {
    let accounts      = [] as DexiePromise<Entity[]>[];
    let categories    = [] as DexiePromise<Entity[]>[];
    let subcategories = [] as DexiePromise<Entity[]>[];
    let payeePayers   = [] as DexiePromise<Entity[]>[];
    let tags          = [] as DexiePromise<Entity[]>[];
    const tables = [
      this.db.accounts,
      this.db.categories,
      this.db.subcategories,
      this.db.payeePayers,
      this.db.tags
    ];
    await this.db.transaction('r', tables, () => {
      joinQueryIds.accounts     .forEach((id) => accounts     .push(this.db.accounts     .where('id').equals(id).toArray()));
      joinQueryIds.categories   .forEach((id) => categories   .push(this.db.categories   .where('id').equals(id).toArray()));
      joinQueryIds.subcategories.forEach((id) => subcategories.push(this.db.subcategories.where('id').equals(id).toArray()));
      joinQueryIds.payeePayers  .forEach((id) => payeePayers  .push(this.db.payeePayers  .where('id').equals(id).toArray()));
      joinQueryIds.tags         .forEach((id) => tags         .push(this.db.tags         .where('id').equals(id).toArray()));
    });

    const allResolved = {
      accounts     : lodash.flattenDeep<Entity>(await Dexie.Promise.all(accounts)),
      categories   : lodash.flattenDeep<Entity>(await Dexie.Promise.all(categories)),
      subcategories: lodash.flattenDeep<Entity>(await Dexie.Promise.all(subcategories)),
      payeePayers  : lodash.flattenDeep<Entity>(await Dexie.Promise.all(payeePayers)),
      tags         : lodash.flattenDeep<Entity>(await Dexie.Promise.all(tags)),
    } as Relation<Entity[]>;

    const _allMap = {
      accounts:      new Map(),
      categories:    new Map(),
      subcategories: new Map(),
      payeePayers:   new Map(),
      tags:          new Map()
    } as Relation<Map<number, string>>;

    allResolved.accounts     .map((item) => _allMap.accounts     .set(item.id, item.name));
    allResolved.categories   .map((item) => _allMap.categories   .set(item.id, item.name));
    allResolved.subcategories.map((item) => _allMap.subcategories.set(item.id, item.name));
    allResolved.payeePayers  .map((item) => _allMap.payeePayers  .set(item.id, item.name));
    allResolved.tags         .map((item) => _allMap.tags         .set(item.id, item.name));

    return _allMap;
  }
开发者ID:armorik83,项目名称:reveal-wealth,代码行数:45,代码来源:money-transaction-repository.service.ts


示例6: flatMapDeep

 /**
  * Maps array of ValidationError returned by validation framework to FormValidationErrors containing extra form related properties.
  *
  * It also flattens nested structure of ValidationError (see: children property) into flat, one dimension array.
  *
  * @param errors - list of errors
  * @param parentProperty - parent property name
  */
 private flatMapDeep (errors: ValidationError[], parentProperty?: string): FormValidationError[] {
   return _.flattenDeep<FormValidationError>(
     errors.map((error: ValidationError) => {
       if (error.children && error.children.length > 0) {
         return this.flatMapDeep(error.children, parentProperty ? `${parentProperty}.${error.property}` : error.property)
       } else {
         return new FormValidationError(error, parentProperty)
       }
     })
   )
 }
开发者ID:hmcts,项目名称:cmc-citizen-frontend,代码行数:19,代码来源:form.ts


示例7: test

  test('calls the converter on the records prior to running', async () => {
    const tasks = [[1, 2, 3], [4, 5]];
    let index = 0;
    const fetchAvailableTasks = async () => tasks[index++] || [];
    const run = sinon.spy(() => false);
    const converter = (x: number) => x.toString();

    await fillPool(run, fetchAvailableTasks, converter);

    expect(_.flattenDeep(run.args)).toEqual(['1', '2', '3']);
  });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:11,代码来源:fill_pool.test.ts


示例8: sortColorsByHue

export function sortColorsByHue(hexColors) {
  const hslColors = _.map(hexColors, hexToHsl);

  let sortedHSLColors = _.sortBy(hslColors, ['h']);
  sortedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);
  sortedHSLColors = _.map(sortedHSLColors, chunk => {
    return _.sortBy(chunk, 'l');
  });
  sortedHSLColors = _.flattenDeep(_.zip(...sortedHSLColors));

  return _.map(sortedHSLColors, hslToHex);
}
开发者ID:acedrew,项目名称:grafana,代码行数:12,代码来源:colors.ts


示例9: sortColorsByHue

function sortColorsByHue(hexColors: string[]) {
  const hslColors = _.map(hexColors, hexToHsl);

  const sortedHSLColors = _.sortBy(hslColors, ['h']);
  const chunkedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);
  const sortedChunkedHSLColors = _.map(chunkedHSLColors, chunk => {
    return _.sortBy(chunk, 'l');
  });
  const flattenedZippedSortedChunkedHSLColors = _.flattenDeep(_.zip(...sortedChunkedHSLColors));

  return _.map(flattenedZippedSortedChunkedHSLColors, hslToHex);
}
开发者ID:CorpGlory,项目名称:grafana,代码行数:12,代码来源:colors.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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