underscore的Function之after

本文介绍如何利用Underscore.js中的_.after方法来控制一组异步操作的执行顺序。当达到指定次数后,才会触发特定的回调函数。这种方法非常适合用于确保一系列异步请求完成后再执行后续操作。

   

  after

 

   _.after(count,function)

 

  •  创建一个function,被调用count次后才可执行
  • 应用:一组异步请求都结束后,执行一段程序的时候可以用after

 

_.after = function(times,func){

       //对times参数的非大于0的判断
       if(times < = 0){
            return func();
       }

       return function(){

           //当执行了times次
           if(-- times < 1){
               
                return func.apply(this,arguments);    
 
           }

       };
      

}

 

image\COMPRESS.jpgCompress Block Properties The Compress block has the following properties: Property Description Columns available The block's input columns, available for you to use in the block's other properties. Group by (Categories) The column(s) that you want to use as compress categories. To change a column's position in the list, select the column and click the up or down arrows as appropriate. Note When you use only one column to define a category, each unique value in that column is a separate category. When you use multiple columns to define a category, every unique combination of values in all category columns is treated as a separate category. For an example, see Compressing by a multi-column category. Unhandled columns Specifies how the Compress block should compress those input columns that do not have a similarly named category or compress function specified. This is useful in many types of reporting scenarios, including in macro reports, where all input columns may not be known at the time you define the Compress block properties. Unhandled columns may be compressed by the COUNT, EXPAND, FIRST, LAST, or MODE functions, or you may choose to discard them. Column name A name for the new output column of compressed values. The name must begin with either a letter or an underscore (_) character. Source column The column from which values will be compressed according to the categories you specified. Function The function that is used to compress the values. The Function list only contains valid functions for the source column's data type. For details, see CompressFunctions below. If you select the PERCENTILE[50] function, you can edit the percentile using the Percentile box that appears next to the Function box. Tip To edit a function after you add it, select the function from the Output columns box, and then click Edit. Separator (Visible only when the CONCATENATE compress function is selected.) Allows you to specify a character to use as a separator between concatenated string values. Output columns The output columns to be passed to the next block. To change a column's position in the list, select the column, right-click, and then select either Up or Down as appropriate from the shortcut menu. Note If a Compress block operates on temporal data, the sort order of that data will not be preserved. Important If any of the categories listed in the Compress block are temporal, it will make all the results temporal, thus resulting in a compilation error when other blocks use those temporal result fields. To avoid this error, either remove the temporal category or make the required field scalar, either by adding a Snapshot block or by adding a snapshot to the field in the Function block. The Compress block does not support null values. If any input columns contain null values, the Compress block will generate no output data. You can use a Function block immediately preceding the Compress block to replace the null values with zero using the following expression: FunctionA = IF NULL(FunctionA) THEN 0 ELSE FunctionA Or you can filter out records with null values using the following expression in a Filter block before the Compress block: FULL(FunctionA) Whether you want to replace the null values or remove the records with null values depends on which Compress function(s) you use. Compress functions Click a function name for details: 翻译
最新发布
11-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值