當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript underscore.difference函數代碼示例

本文整理匯總了TypeScript中underscore.difference函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript difference函數的具體用法?TypeScript difference怎麽用?TypeScript difference使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了difference函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: stashNonTextUIElementsInEditBox

        this.each(function() {
            stashNonTextUIElementsInEditBox(this);
            var html = $(this).html();

            // ignore empty elements
            if (html.trim().length > 0 && text.trim().length > 0) {
                html = theOneLibSynphony.wrap_words_extra(
                    html,
                    results.sight_words,
                    cssSightWord,
                    ' data-segment="word"'
                );
                html = theOneLibSynphony.wrap_words_extra(
                    html,
                    results.possible_words,
                    cssPossibleWord,
                    ' data-segment="word"'
                );

                // remove numbers from list of bad words
                var notFound = _.difference(
                    results.remaining_words,
                    results.getNumbers()
                );

                html = theOneLibSynphony.wrap_words_extra(
                    html,
                    notFound,
                    cssWordNotFound,
                    ' data-segment="word"'
                );
                $(this).html(html);
            }
            restoreNonTextUIElementsInEditBox(this);
        });
開發者ID:BloomBooks,項目名稱:BloomDesktop,代碼行數:35,代碼來源:jquery.text-markup.ts

示例2: ArrayToTreeToTemplateToData

  public static ArrayToTreeToTemplateToData(list: Property[], extra?: any) {
    let tree = Tree.ArrayToTree(list)
    let template: { [key: string]: any } = Tree.TreeToTemplate(tree)
    let data
    if (extra) {
      // DONE 2.2 支持引用請求參數
      let keys = Object.keys(template).map(item => item.replace(RE_KEY, '$1'))
      let extraKeys = _.difference(Object.keys(extra), keys)
      let scopedData = Tree.TemplateToData(
        Object.assign({}, _.pick(extra, extraKeys), template),
      )
      for (const key in scopedData) {
        if (!scopedData.hasOwnProperty(key)) continue
        let data = scopedData[key]
        for (const eKey in extra) {
          if (!extra.hasOwnProperty(eKey)) continue
          const pattern = new RegExp(`\\$${eKey}\\$`, 'g')
          if (data && pattern.test(data)) {
            data = scopedData[key] = data.replace(pattern, extra[eKey])
          }
        }
      }
      data = _.pick(scopedData, keys)
    } else {
      data = Tree.TemplateToData(template)
    }

    return data
  }
開發者ID:tonyjt,項目名稱:rap2-delos,代碼行數:29,代碼來源:tree.ts

示例3: on

 on(actions.tabsClosed, (state, action) => {
   const { tabs, andFocus } = action.payload;
   return {
     ...state,
     openTabs: difference(state.openTabs, tabs),
     tab: andFocus ? andFocus : state.tab,
   };
 });
開發者ID:itchio,項目名稱:itch,代碼行數:8,代碼來源:navigation.ts

示例4: drawCompleteGraph

 drawCompleteGraph(CustomObj, 'custom', () => {
   let missing_genes = _.difference(genes, graph.getData().labels);
   if (missing_genes.length > 0) {
     let error = new Error()
     error.name = "Missing Genes";
     error.message = missing_genes.join(',');
     errorHandler(error, 'warning', true);
   }
 });
開發者ID:delosh653,項目名稱:SemNExT-Visualizations,代碼行數:9,代碼來源:ui.ts

示例5: _getSelectedPlugs

  _getSelectedPlugs(item: DimItem) {
    if (!item.sockets) {
      return null;
    }

    const allPlugs = compact(item.sockets.sockets.map((i) => i.plug).map((i) => i && i.plugItem.hash));

    return _.difference(allPlugs, this._getPowerMods(item));
  }
開發者ID:delphiactual,項目名稱:DIM,代碼行數:9,代碼來源:d2-itemTransformer.ts

示例6: randomizedKingdomCards

export function randomizedKingdomCards(forcedCards: Card[], allCards: Card[], numCards: number) : Card[] {
    if (forcedCards.length >= numCards) {
        return forcedCards;
    }

    const randomOptions = _.difference<Card>(allCards, forcedCards);
    const randomCards = _.sample<Card>(randomOptions, numCards - forcedCards.length);
    return forcedCards.concat(randomCards);
};
開發者ID:scottostler,項目名稱:conspirator,代碼行數:9,代碼來源:cards.ts

示例7: getSelectedPlugs

function getSelectedPlugs(item: D2Item, powerModHashes: number[]): number[] {
  if (!item.sockets) {
    return [];
  }

  const allPlugs = compact(
    item.sockets.sockets.map((i) => i.plug).map((i) => i && i.plugItem.hash)
  );

  return _.difference(allPlugs, powerModHashes);
}
開發者ID:bhollis,項目名稱:DIM,代碼行數:11,代碼來源:d2-itemTransformer.ts

示例8: check_options_correctness_against_schema

export function check_options_correctness_against_schema(obj: any, schema: StructuredTypeSchema, options: any) {

    if (!parameters.debugSchemaHelper) {
        return; // ignoring set
    }

    options = options || {};

    // istanbul ignore next
    if (!_.isObject(options) && !(typeof(options) === "object")) {
        let message = chalk.red(" Invalid options specified while trying to construct a ")
          + " " + chalk.yellow(schema.name);
        message += "\n";
        message += chalk.red(" expecting a ") + chalk.yellow(" Object ");
        message += "\n";
        message += chalk.red(" and got a ") + chalk.yellow((typeof options)) + chalk.red(" instead ");
        // console.log(" Schema  = ", schema);
        // console.log(" options = ", options);
        throw new Error(message);
    }

    // istanbul ignore next
    if (options instanceof obj.constructor) {
        return true;
    }

    // extract the possible fields from the schema.
    const possibleFields = obj.constructor.possibleFields || schema._possibleFields;

    // extracts the fields exposed by the option object
    const currentFields = Object.keys(options);

    // get a list of field that are in the 'options' object but not in schema
    const invalidOptionsFields = _.difference(currentFields, possibleFields);

    /* istanbul ignore next */
    if (invalidOptionsFields.length > 0) {
        // tslint:disable:no-console
        console.log("expected schema", schema.name);
        console.log(chalk.yellow("possible fields= "), possibleFields.sort().join(" "));
        console.log(chalk.red("current fields= "), currentFields.sort().join(" "));
        console.log(chalk.cyan("invalid_options_fields= "), invalidOptionsFields.sort().join(" "));
        console.log("options = ", options);
    }
    if (invalidOptionsFields.length !== 0) {
        throw new Error(" invalid field found in option :" + JSON.stringify(invalidOptionsFields));
    }
    return true;
}
開發者ID:node-opcua,項目名稱:node-opcua,代碼行數:49,代碼來源:factories_structuredTypeSchema.ts

示例9: moment

            data.setupFeedHealth = (feedsArray: any)=>{
             var processedFeeds: any[] = [];
             if(feedsArray) {
                     var processed: any[] = [];
                     var arr: any[] = [];
                     _.each(feedsArray,  (feedHealth: any) =>{
                         //pointer to the feed that is used/bound to the ui/service
                         var feedData = null;
                         if (data.feedSummaryData[feedHealth.feed]) {
                             feedData = data.feedSummaryData[feedHealth.feed]
                             angular.extend(feedData, feedHealth);
                             feedHealth = feedData;
                         }
                         else {
                             data.feedSummaryData[feedHealth.feed] = feedHealth;
                             feedData = feedHealth;
                         }
                         arr.push(feedData);

                         processedFeeds.push(feedData);
                         if (feedData.lastUnhealthyTime) {
                             feedData.sinceTimeString = moment(feedData.lastUnhealthyTime).fromNow();
                         }

                        this.OpsManagerFeedService.decorateFeedSummary(feedData);
                         if(feedData.stream == true && feedData.feedHealth){
                             feedData.runningCount = feedData.feedHealth.runningCount;
                             if(feedData.runningCount == null){
                                 feedData.runningCount =0;
                             }
                         }

                         if(feedData.running){
                             feedData.timeSinceEndTime = feedData.runTime;
                             feedData.runTimeString = '--';
                         }
                          processed.push(feedData.feed);
                     });
                     var keysToRemove=_.difference(Object.keys(data.feedSummaryData),processed);
                     if(keysToRemove != null && keysToRemove.length >0){
                         _.each(keysToRemove,(key: any)=>{
                             delete  data.feedSummaryData[key];
                         })
                     }
                     data.feedsArray = arr;
                 }
                 return processedFeeds;

         };
開發者ID:prashanthc97,項目名稱:kylo,代碼行數:49,代碼來源:OpsManagerDashboardService.ts

示例10: list

 /**
  * LIST operation of CFS. List files at given location. Tree traversal.
  * @param ofPath Location folder to list files.
  * @param localLevel Limit listing to local level.
  * @returns {*} Promise of file names.
  */
 async list(ofPath:string): Promise<string[]> {
   const dirPath = path.normalize(ofPath);
   let files: string[] = [], folder = path.join(this.rootPath, dirPath);
   const hasDir = await this.qfs.exists(folder);
   if (hasDir) {
     files = files.concat(await this.qfs.list(folder));
   }
   const hasDeletedFiles = await this.qfs.exists(this.deletedFolder);
   if (hasDeletedFiles) {
     const deletedFiles = await this.qfs.list(this.deletedFolder);
     const deletedOfThisPath = deletedFiles.filter((f:string) => f.match(new RegExp('^' + this.toRemoveDirName(dirPath))));
     const locallyDeletedFiles = deletedOfThisPath.map((f:string) => f.replace(this.toRemoveDirName(dirPath), '')
       .replace(/^__/, ''));
     files = _.difference(files, locallyDeletedFiles);
   }
   return _.uniq(files);
 };
開發者ID:duniter,項目名稱:duniter,代碼行數:23,代碼來源:CFSCore.ts


注:本文中的underscore.difference函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。