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


TypeScript underscore.chain函数代码示例

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


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

示例1: encodeURIComponent

                    _.each(result.Results, (v, k) => {
                        if (_.filter(v.Values, x => x.Hits > 0).length < 2) {
                            delete result.Results[k];
                            return;
                        }
                        v.Values = _.chain(v.Values)
                            .map((x) => {

                                var val = JSON.stringify(x.Range)
                                    .replace(/^\"|\"$/gi, "")
                                    .replace(/\:/gi, "\\:")
                                    .replace(/\(/gi, "\\(")
                                    .replace(/\)/gi, "\\)")
                                ;

                                if (x.Range.indexOf(" TO ") <= 0 || x.Range.indexOf("[") !== 0) {
                                    val = val.replace(/\ /gi, "\\ ");
                                }
                                val = encodeURIComponent(val);
                                x.q = k + ":" + val;

                                x.Range = x.Range.replace(/^\[Dx/, "").replace(/ Dx/, " ").replace(/\]$/, "").replace(/ TO /, "-")
                                    return x;
                            })
                            .filter((x) => x.Hits > 0)
                            .sortBy((x) => x.Range)
                            .value();
                    });
开发者ID:Antares007,项目名称:AiPos,代码行数:28,代码来源:ravendb.ts

示例2: save

 save() {
     _.chain(this.tnxs)
         .forEach((t:Transaction) => {
             this._tnxService.saveItem(t);
             this._pTnxService.deleteItem(t);
         });
 }
开发者ID:gjuhasz86,项目名称:expense-proto,代码行数:7,代码来源:account-mapper.component.ts

示例3: function

 static respondToResourceGET<T>(requestBody, res, dao: DAO<T>, whereArray: string[], likeArray: string[]) {
     let whereQuery = _.omit(_.pick(requestBody, whereArray),
         function (value, key, object) {
             return value === "";
         });
     let likeQuery_ = _.chain(requestBody)
         .pick(requestBody, likeArray)
         .omit(function (value, key, object) {
             return value === "";
         }).value();
     let likeQuery = _.mapObject(likeQuery_, function (value, key) {
         return "%" + value + "%";
     });
     dao.find({
         where: whereQuery, like: likeQuery, orderBy: requestBody.orderBy
     }, function (err, results) {
         if (err) {
             APIHelper.sendDatabaseErrorResponse(res, err);
         } else {
             if (results.length === 0) {
                 APIHelper.sendNotFoundResponse(res, "Not found.");
             } else {
                 APIHelper.sendResponse(res, results);
             }
         }
     });
 }
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:27,代码来源:apiHelper.ts

示例4: async

 checkMembershipUnicity: async (block:BlockDTO, conf:ConfDTO, index:IndexEntry[]) => {
   const mindex = Indexer.mindex(index);
   const pubkeys = _.chain(mindex).pluck('pub').uniq().value();
   if (pubkeys.length !== mindex.length) {
     throw Error('Unicity constraint PUBLIC_KEY on MINDEX is not respected');
   }
   return true;
 },
开发者ID:duniter,项目名称:duniter,代码行数:8,代码来源:local_rules.ts

示例5: isEmpty

  public static isEmpty(queryBuilderExpression: QueryBuilderExpression) {
    const allNonEmptyValues = _.chain(queryBuilderExpression)
      .values()
      .compact()
      .value();

    return _.isEmpty(allNonEmptyValues);
  }
开发者ID:coveo,项目名称:search-ui,代码行数:8,代码来源:QueryBuilderExpression.ts

示例6: update

 update() {
     _.chain(this.tnxs)
         .filter(t=> t.accountId == this.selectedFrom)
         .forEach((t:Transaction) => {
             t.accountId = this.selectedTo;
             this._pTnxService.updateItem(t);
         });
 }
开发者ID:gjuhasz86,项目名称:expense-proto,代码行数:8,代码来源:account-mapper.component.ts

示例7: cb

    return through2.obj(function (chunk, enc, cb) {
        const pushGerritEventForward = (gerritEvent: GerritEvent) => this.push(gerritEvent);

        _.chain(getGerritEventsStringByChunk(chunk))
        .compact()
        .map(parseToGerritEvent)
        .compact()
        .map(pushGerritEventForward);

        cb();
    });
开发者ID:adasq,项目名称:gerrit-native-notifications,代码行数:11,代码来源:to-gerrit-event.ts

示例8: instantiateToString

  public instantiateToString(object: IQueryResult, instantiateOptions: IInstantiateTemplateOptions = {}): string {
    Assert.exists(object);
    let mergedOptions = new DefaultInstantiateTemplateOptions().merge(instantiateOptions);
    object = _.extend({}, object, UnderscoreTemplate.templateHelpers);

    const templates = _.chain(TemplateCache.getDefaultTemplates())
      .map(name => TemplateCache.getTemplate(name))
      .value();

    // Put templates with conditions first
    const sortedTemplates = _.chain(templates)
      .sortBy(template => template.condition == null)
      .sortBy(template => template.fieldsToMatch == null)
      .value();

    for (let i = 0; i < sortedTemplates.length; i++) {
      const result = sortedTemplates[i].instantiateToString(object, mergedOptions);
      if (result != null) {
        return result;
      }
    }

    return this.getFallbackTemplate();
  }
开发者ID:coveo,项目名称:search-ui,代码行数:24,代码来源:DefaultResultTemplate.ts


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