當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。