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

TypeScript lodash.sortBy函数代码示例

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

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



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

示例1: getDefinitions

  getDefinitions().then((defs) => {
    Object.assign(vm, {
      active: 'titan',
      i18nClassNames: _.zipObject(
        ['titan', 'hunter', 'warlock'],
        _.sortBy(Object.values(defs.Class), (classDef) => classDef.classType).map(
          (c: any) => c.className
        )
      ),
      i18nItemNames: _.zipObject(
        ['Helmet', 'Gauntlets', 'Chest', 'Leg', 'ClassItem', 'Artifact', 'Ghost'],
        [45, 46, 47, 48, 49, 38, 39].map((key) => defs.ItemCategory.get(key).title)
      ),
      activesets: '5/5/2',
      type: 'Helmet',
      scaleType: 'scaled',
      progress: 0,
      fullMode: false,
      includeVendors: false,
      showBlues: false,
      showExotics: true,
      showYear1: false,
      allSetTiers: [],
      hasSets: true,
      highestsets: {},
      activeHighestSets: [],
      ranked: {},
      activePerks: {},
      excludeditems: [],
      collapsedConfigs: [false, false, false, false, false, false, false, false, false, false],
      lockeditems: {
        Helmet: null,
        Gauntlets: null,
        Chest: null,
        Leg: null,
        ClassItem: null,
        Artifact: null,
        Ghost: null
      },
      lockedperks: {
        Helmet: {},
        Gauntlets: {},
        Chest: {},
        Leg: {},
        ClassItem: {},
        Artifact: {},
        Ghost: {}
      },
      setOrderValues: ['-str_val', '-dis_val', '-int_val'],
      lockedItemsValid(droppedId: string, droppedType: ArmorTypes) {
        droppedId = getId(droppedId);
        if (alreadyExists(vm.excludeditems, droppedId)) {
          return false;
        }

        const item = getItemById(droppedId, droppedType)!;
        const startCount: number = item.isExotic && item.type !== 'ClassItem' ? 1 : 0;
        return (
          startCount +
            (droppedType !== 'Helmet' && vm.lockeditems.Helmet && vm.lockeditems.Helmet.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Gauntlets' &&
            vm.lockeditems.Gauntlets &&
            vm.lockeditems.Gauntlets.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Chest' && vm.lockeditems.Chest && vm.lockeditems.Chest.isExotic
              ? 1
              : 0) +
            (droppedType !== 'Leg' && vm.lockeditems.Leg && vm.lockeditems.Leg.isExotic ? 1 : 0) <
          2
        );
      },
      excludedItemsValid(droppedId: string, droppedType: ArmorTypes) {
        const lockedItem = vm.lockeditems[droppedType];
        return !(lockedItem && alreadyExists([lockedItem], droppedId));
      },
      onSelectedChange(prevIdx, selectedIdx) {
        if (vm.activeCharacters[prevIdx].class !== vm.activeCharacters[selectedIdx].class) {
          const classType = vm.activeCharacters[selectedIdx].class;
          if (classType !== 'vault') {
            vm.active = classType;
          }
          vm.onCharacterChange();
          vm.selectedCharacter = selectedIdx;
        }
      },
      onCharacterChange() {
        vm.ranked = getActiveBuckets(
          buckets[vm.active],
          vendorBuckets[vm.active],
          vm.includeVendors
        );
        vm.activeCharacters = D1StoresService.getStores().filter((s) => !s.isVault);
        const activeStore = D1StoresService.getActiveStore()!;
        vm.selectedCharacter = _.findIndex(
          vm.activeCharacters,
          (char) => char.id === activeStore.id
        );
//.........这里部分代码省略.........
开发者ID:w1cked,项目名称:DIM,代码行数:101,代码来源:loadout-builder.component.ts


示例2: keyBy

    fn: (context, args) => {
      const seriesStyles: { [key: string]: SeriesStyle } =
        keyBy(args.seriesStyle || [], 'label') || {};

      const sortedRows = sortBy(context.rows, ['x', 'y', 'color', 'size', 'text']);
      const ticks = getTickHash(context.columns, sortedRows);
      const font = args.font ? getFontSpec(args.font) : {};

      const data = map(groupBy(sortedRows, 'color'), (series, label) => {
        const seriesStyle = {
          ...args.defaultStyle,
          ...seriesStyles[label as string],
        };

        const flotStyle = seriesStyle ? seriesStyleToFlot(seriesStyle) : {};

        return {
          ...flotStyle,
          label,
          data: series.map(point => {
            const attrs: {
              size?: number;
              text?: string;
            } = {};

            const x = get(context.columns, 'x.type') === 'string' ? ticks.x.hash[point.x] : point.x;
            const y = get(context.columns, 'y.type') === 'string' ? ticks.y.hash[point.y] : point.y;

            if (point.size != null) {
              attrs.size = point.size;
            } else if (get(seriesStyle, 'points')) {
              attrs.size = seriesStyle.points;
              set(flotStyle, 'bubbles.size.min', seriesStyle.points);
            }

            if (point.text != null) {
              attrs.text = point.text;
            }

            return [x, y, attrs];
          }),
        };
      });

      const gridConfig = {
        borderWidth: 0,
        borderColor: null,
        color: 'rgba(0,0,0,0)',
        labelMargin: 30,
        margin: {
          right: 30,
          top: 20,
          bottom: 0,
          left: 0,
        },
      };

      const result = {
        type: 'render',
        as: 'plot',
        value: {
          font: args.font,
          data: sortBy(data, 'label'),
          options: {
            canvas: false,
            colors: getColorsFromPalette(args.palette, data.length),
            legend: getLegendConfig(args.legend, data.length),
            grid: gridConfig,
            xaxis: getFlotAxisConfig('x', args.xaxis, {
              columns: context.columns,
              ticks,
              font,
            }),
            yaxis: getFlotAxisConfig('y', args.yaxis, {
              columns: context.columns,
              ticks,
              font,
            }),
            series: {
              shadowSize: 0,
              ...seriesStyleToFlot(args.defaultStyle),
            },
          },
        },
      };

      // fix the issue of plot sometimes re-rendering with an empty chart
      // TODO: holy hell, why does this work?! the working theory is that some values become undefined
      // and serializing the result here causes them to be dropped off, and this makes flot react differently.
      // It's also possible that something else ends up mutating this object, but that seems less likely.
      return JSON.parse(JSON.stringify(result));
    },
开发者ID:elastic,项目名称:kibana,代码行数:92,代码来源:index.ts


示例3: generateCommonTypes

export function generateCommonTypes(
  collections: Tyr.CollectionInstance[],
  output: 'server' | 'client',
  idType = 'string'
) {
  const sorted = _.sortBy(collections, 'def.name');
  const docs: string[] = [];
  const cols: string[] = [];
  const aliases: string[] = [];

  sorted.forEach(c => {
    const name = c.def.name;
    const docName = names.document(name);
    const colName = names.collection(name);
    const isoName = names.isomorphic(names.base(name));
    const aliasName = names.id(name);
    const isoAlias = names.isomorphic(names.id(name));
    const idType = names.idType(c);

    const staticName = c.def.enum
      ? `,
                ${names.isomorphic(
                  names.enumStatic(name)
                )}<ObjIdType, Inserted<ObjIdType>, Inserted<number>>`
      : '';

    docs.push(`
    /**
     * ${names.format(output)} base document definition for ${colName}.
     */
    ${output === 'client' ? 'export ' : ''}interface ${names.base(name)}
      extends ${isoName}<ObjIdType, Inserted<ObjIdType>, Inserted<number>> {}

    /**
     * ${names.format(output)} document definition for ${colName},
     * extends isomorphic base interface ${names.base(name)}.
     */
    ${output === 'client' ? 'export ' : ''}interface ${docName}
      extends Inserted<${idType}>,
              ${names.base(name)} {}
    `);

    cols.push(`
    /**
     * ${names.format(output)} collection definition.
     */
    ${output === 'client' ? 'export ' : ''}interface ${colName}
      extends Tyr.CollectionInstance<${idType}, ${docName}>${staticName} {}
    `);

    if (c.def.enum)
      aliases.push(pad(`export type ${aliasName} = ${isoAlias};`, 2));
  });

  return `

    ${docs.join('\n').trim()}

    ${cols.join('\n').trim()}

    ${aliases.join('\n').trim()}
  `;
}
开发者ID:tyranid-org,项目名称:tyranid,代码行数:63,代码来源:isomorphic.ts


示例4: getDevices

	getDevices(): Device[] {
		return _.sortBy(this.devices.getMotionSensors(), 'name');
	}
开发者ID:Dianoga,项目名称:quickdash-web,代码行数:3,代码来源:motion-list.component.ts


示例5:

 return this.$q.all(promises).then(() => {
   return _.sortBy(_.values(sections), 'score');
 });
开发者ID:arcolife,项目名称:grafana,代码行数:3,代码来源:search_srv.ts


示例6: render_panel


//.........这里部分代码省略.........
          },
          crosshair: {
            mode: 'x'
          }
        };

        for (let i = 0; i < data.length; i++) {
          let series = data[i];
          series.data = series.getFlotPairs(series.nullPointMode || panel.nullPointMode);

          // if hidden remove points and disable stack
          if (ctrl.hiddenSeries[series.alias]) {
            series.data = [];
            series.stack = false;
          }
        }

        switch (panel.xaxis.mode) {
          case 'series': {
            options.series.bars.barWidth = 0.7;
            options.series.bars.align = 'center';

            for (let i = 0; i < data.length; i++) {
              let series = data[i];
              series.data = [[i + 1, series.stats[panel.xaxis.values[0]]]];
            }

            addXSeriesAxis(options);
            break;
          }
          case 'histogram': {
            let bucketSize: number;
            let values = getSeriesValues(data);

            if (data.length && values.length) {
              let histMin = _.min(_.map(data, s => s.stats.min));
              let histMax = _.max(_.map(data, s => s.stats.max));
              let ticks = panel.xaxis.buckets || panelWidth / 50;
              bucketSize = tickStep(histMin, histMax, ticks);
              let histogram = convertValuesToHistogram(values, bucketSize);

              data[0].data = histogram;
              data[0].alias = data[0].label = data[0].id = "count";
              data = [data[0]];

              options.series.bars.barWidth = bucketSize * 0.8;
            } else {
              bucketSize = 0;
            }

            addXHistogramAxis(options, bucketSize);
            break;
          }
          case 'table': {
            options.series.bars.barWidth = 0.7;
            options.series.bars.align = 'center';
            addXTableAxis(options);
            break;
          }
          default: {
            options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5;
            addTimeAxis(options);
            break;
          }
        }

        thresholdManager.addFlotOptions(options, panel);
        eventManager.addFlotEvents(annotations, options);
        configureAxisOptions(data, options);

        sortedSeries = _.sortBy(data, function(series) { return series.zindex; });

        function callPlot(incrementRenderCounter) {
          try {
            plot = $.plot(elem, sortedSeries, options);
            if (ctrl.renderError) {
              delete ctrl.error;
              delete ctrl.inspector;
            }
          } catch (e) {
            console.log('flotcharts error', e);
            ctrl.error = e.message || "Render Error";
            ctrl.renderError = true;
            ctrl.inspector = {error: e};
          }

          if (incrementRenderCounter) {
            ctrl.renderingCompleted();
          }
        }

        if (shouldDelayDraw(panel)) {
          // temp fix for legends on the side, need to render twice to get dimensions right
          callPlot(false);
          setTimeout(function() { callPlot(true); }, 50);
          legendSideLastValue = panel.legend.rightSide;
        } else {
          callPlot(true);
        }
      }
开发者ID:gofore,项目名称:grafana,代码行数:101,代码来源:graph.ts


示例7: serializeCriteriaValues

function serializeCriteriaValues(criteriaValues: IAuthCriteriaPropertyValues): string {
  return JSON.stringify(sortBy(map(criteriaValues, (value, prop) => [prop, value]), '0'))
}
开发者ID:patrickhulce,项目名称:klay,代码行数:3,代码来源:grants.ts


示例8: getExternal

 getExternal() {
   const datasources = this.getAll().filter(ds => !ds.meta.builtIn);
   return _.sortBy(datasources, ['name']);
 }
开发者ID:johntdyer,项目名称:grafana,代码行数:4,代码来源:datasource_srv.ts


示例9: function

 _.map(categories, function(submenu, category) {
   return {
     text: category,
     submenu: _.sortBy(submenu, 'text'),
   };
 }),
开发者ID:gzq0616,项目名称:grafana,代码行数:6,代码来源:add_graphite_func.ts


示例10: groupUpgrades

export function groupUpgrades(upgrades: SystemUpgrade[]): SystemUpgrade[][] {
  const groupedVersions = groupBy(upgrades, upgrade => upgrade.version.split('.')[0]);
  const sortedMajor = sortBy(Object.keys(groupedVersions), key => -Number(key));
  return sortedMajor.map(key => groupedVersions[key]);
}
开发者ID:christophelevis,项目名称:sonarqube,代码行数:5,代码来源:utils.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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