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

TypeScript underscore.reduce函数代码示例

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

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



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

示例1: AddBusVisitItem

    AddBusVisitItem(bookingId, alkhidmatCentre, driver, bus, fuelAmount) {
        if (bus == undefined || bus.length <= 0) {
            helper.ShowModalPopup("danger", "Bus Info", "Please enter valid  vehicle no.!");
            return;
        }
        else if (fuelAmount == "" || fuelAmount == undefined || fuelAmount === 0) {
            helper.ShowModalPopup("danger", "Bus Info", "Please enter valid amount!");
            return;
        }
        
        var counter = this.idCounter++;
        var busExist = this.backboneCollection.findWhere({ busId: bus.id });
        var driverExist = this.backboneCollection.findWhere({ driverId: driver.id });

        

        if (busExist == undefined && driverExist == undefined) {
            this.backboneCollection.push(new busVisitDto.Models.BusVisitDto({
                busVisitId: counter,
                centreId: alkhidmatCentre.id, centreDesc: alkhidmatCentre.description,
                busId: bus.id, busDesc: bus.description,
                driverId: driver.id, driverDesc: driver.description,
                visitTypeId: "2",
                //isAvailableForBooking: false,
                //isAvailableForFutureBooking: false,
                bookingId: bookingId,
                fuelAmount: fuelAmount.replace(",","")
            }));
            
            this.busVisitCollectionView.collection = this.backboneCollection;

            var sum = _.reduce(this.backboneCollection.models, (memo, item) => memo + parseFloat(item.get("fuelAmount").replace(",","")), 0);
            this.paymentView.viewModel.amount(helper.FormatMoney(sum));
        }
        else {
            helper.ShowModalPopup("danger", "Bus Info", "Entry already exists!");
        }

    }
开发者ID:saeed-ahmed,项目名称:CCTracking,代码行数:39,代码来源:PaymentCtrl.ts


示例2: function

import * as _ from "underscore";
var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
console.log(sum);
开发者ID:chun4foryou,项目名称:develop,代码行数:3,代码来源:test-underscore.ts


示例3: RemoveBusVisitItem

 RemoveBusVisitItem(busId, centreId, driverId) {
     this.backboneCollection.remove(this.backboneCollection.findWhere({ busId: busId, centreId: centreId, driverId: driverId }));
     var sum = _.reduce(this.backboneCollection.models, (memo, item) => memo + parseFloat(item.get("fuelAmount").replace(",","")), 0);
     this.paymentView.viewModel.amount(helper.FormatMoney(sum));
 }
开发者ID:saeed-ahmed,项目名称:CCTracking,代码行数:5,代码来源:PaymentCtrl.ts


示例4: getBuckets

      return getBuckets().then((buckets) => {
        const reservations: MoveReservations = {};
        if (settings.farming.makeRoomForItems) {
          // reserve one space in the active character
          reservations[this.store.id] = {};
          makeRoomTypes.forEach((type) => {
            reservations[this.store.id][buckets.byId[type].type!] = 1;
          });
        }

        return _.reduce(
          items,
          (promise, item) => {
            // Move a single item. We do this as a chain of promises so we can reevaluate the situation after each move.
            return promise
              .then(() => {
                const vault = D1StoresService.getVault()!;
                const vaultSpaceLeft = vault.spaceLeftForItem(item);
                if (vaultSpaceLeft <= 1) {
                  // If we're down to one space, try putting it on other characters
                  const otherStores = D1StoresService.getStores().filter(
                    (store) => !store.isVault && store.id !== this.store.id
                  );
                  const otherStoresWithSpace = otherStores.filter((store) =>
                    store.spaceLeftForItem(item)
                  );

                  if (otherStoresWithSpace.length) {
                    if ($featureFlags.debugMoves) {
                      console.log(
                        'Farming initiated move:',
                        item.amount,
                        item.name,
                        item.type,
                        'to',
                        otherStoresWithSpace[0].name,
                        'from',
                        D1StoresService.getStore(item.owner)!.name
                      );
                    }
                    return dimItemService.moveTo(
                      item,
                      otherStoresWithSpace[0],
                      false,
                      item.amount,
                      items,
                      reservations
                    );
                  }
                }
                if ($featureFlags.debugMoves) {
                  console.log(
                    'Farming initiated move:',
                    item.amount,
                    item.name,
                    item.type,
                    'to',
                    vault.name,
                    'from',
                    D1StoresService.getStore(item.owner)!.name
                  );
                }
                return dimItemService.moveTo(item, vault, false, item.amount, items, reservations);
              })
              .then(() => {
                if (incrementCounter) {
                  this.itemsMoved++;
                }
              })
              .catch((e) => {
                if (e.code === 'no-space') {
                  outOfSpaceWarning(this.store);
                } else {
                  toaster.pop('error', item.name, e.message);
                }
                throw e;
              });
          },
          $q.resolve()
        );
      });
开发者ID:bhollis,项目名称:DIM,代码行数:81,代码来源:farming.service.ts


示例5: subtract

function subtract($all) {
    enforce($all).isArray().isNotEmpty();
    return _.reduce($all, (memo, num) => memo - num);
}
开发者ID:pumlhorse,项目名称:pumlhorse,代码行数:4,代码来源:math.ts


示例6: getFields

 getFields() {
   return _.reduce(this.templates, (fields: string[], template: Template) => fields.concat(template.getFields()), []);
 }
开发者ID:erocheleau,项目名称:search-ui,代码行数:3,代码来源:TemplateList.ts


示例7: add

function add($all) {
    enforce($all).isArray().isNotEmpty();
    return _.reduce($all, (memo, num) => memo + num);
}
开发者ID:pumlhorse,项目名称:pumlhorse,代码行数:4,代码来源:math.ts


示例8: multiply

function multiply($all) {
    enforce($all).isArray().isNotEmpty();
    return _.reduce($all, (memo, num) => memo * num);
}
开发者ID:pumlhorse,项目名称:pumlhorse,代码行数:4,代码来源:math.ts


示例9: reduce

 .sortBy(key => {
   const total = reduce(rankingInfo.termsWeight[key].Weights, (memo, value) => memo + value, 0);
   return total;
 })
开发者ID:coveo,项目名称:search-ui,代码行数:4,代码来源:RankingInfoTable.ts


示例10: fn

export function sum<T>(list: T[], summer: _.ListIterator<T, number>): number {
  const fn = _.iteratee(summer) as _.ListIterator<T, number>;
  return _.reduce(list, (memo, val, index) => {
    return memo + fn(val, index, list);
  }, 0);
}
开发者ID:delphiactual,项目名称:DIM,代码行数:6,代码来源:util.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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