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


TypeScript lodash.union函數代碼示例

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


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

示例1: addDatabasesFrom

 /**
  * Register database configurations from any object, resolving existing "database" or "databases" properties
  *
  * @param {Object} config - The object to resolve the database configurations from
  *
  * @memberOf MlclDatabase
  */
 public addDatabasesFrom(config: Object) {
   let databases: any[] = [];
   if (config && !_.isEmpty(config)) {
     // loop over object or array properties
     for (let prop in config) {
       // check for relevant property
       if (prop === "database" || prop === "databases") {
         if (_.isArray(config[prop])) {
           for (let database of config[prop]) {
             databases.push(database);
           }
         } else {
           databases.push(config[prop]);
         }
         // check for sub-objects to resolve
       } else if (typeof config[prop] === "object" && typeof config[prop] !== "function" && config[prop] !== null) {
         this.addDatabasesFrom(config[prop]);
       }
     }
   }
   if (databases.length && !this.ownConfigs) {
     this.ownConfigs = [];
   }
   this.ownConfigs = _.union(this.ownConfigs, databases);
 }
開發者ID:molecuel,項目名稱:mlcl_database,代碼行數:32,代碼來源:index.ts

示例2: function

        _.each(content, function(item, index) {
            var _level = getLevel(item.level);
            var _treatment = treatmentsToStr(item.content);
            var _tumorType = item.tumorType;
            var _alterations = item.alterations.map(function(alt:any) {
                return alt.alteration;
            }).join(',');
            if (!treatments.hasOwnProperty(_level)) {
                treatments[_level] = {};
            }
            if (!treatments[_level].hasOwnProperty(_alterations)) {
                treatments[_level][_alterations] = {};
            }

            if (!treatments[_level][_alterations].hasOwnProperty(_treatment)) {
                treatments[_level][_alterations][_treatment] = {};
            }

            if (!treatments[_level][_alterations][_treatment].hasOwnProperty(_tumorType)) {
                treatments[_level][_alterations][_treatment][_tumorType] = {
                    articles: [],
                    tumorType: _tumorType,
                    alterations: item.alterations,
                    level: _level,
                    description: item.description,
                    treatment: _treatment
                };
            } else {
                treatments[_level][_alterations][_treatment][_tumorType].description = [treatments[_level][_alterations][_treatment][_tumorType].description, '<br/>', item.description].join();
            }
            treatments[_level][_alterations][_treatment][_tumorType].articles = _.union(treatments[_level][_alterations][_treatment][_tumorType].articles, item.articles);
        });
開發者ID:agarwalrounak,項目名稱:cbioportal-frontend,代碼行數:32,代碼來源:OncoKbUtils.ts

示例3: listReducer

function listReducer(state: Array<ListDefinition> = INITIAL_STATE, action: any = { type: "" }): Array<ListDefinition> {
    switch (action.type) {
        case ADD_LIST:
            //https://spin.atomicobject.com/2016/09/27/typed-redux-reducers-typescript-2-0/
            let newarray = _.clone(state);
            newarray.push(action.payload.list);
            return newarray;
        case SAVE_LIST:
            let newarray2 = _.clone(state);
            let item =_.find( newarray2,item => item.guid === action.payload.list.guid);
            item = action.payload.list;
            return newarray2;
        case REMOVE_LIST:
            let newArr = _.filter(state, (o) => { return o.guid !== action.payload.list.guid; });
            return newArr;
        case REMOVE_ALLLISTS:
            return [];

        case ADD_LISTS:
            return _.union(state, action.payload.lists);
        case REMOVE_COLUMN:

            let listrefs = _.clone(state);
            for (const listref of listrefs) {
                for (let i = listref.columnReferences.length - 1; i >= 0; i--) {
                    if (listref.columnReferences[i].columnDefinitionId === action.payload.column.guid) {
                        listref.columnReferences.splice(i, 1);
                    }
                }
            }
            return listrefs;
        default:
            return state;
    }
}
開發者ID:,項目名稱:,代碼行數:35,代碼來源:

示例4: listItemReducer

function listItemReducer(state = INITIAL_STATE, action: any = { type: "" }) {

    switch (action.type) {
        case MOVE_COLUMN_UP:
            return moveColumnUp(state, action);
        case MOVE_COLUMN_DOWN:
            return moveColumnDown(state, action);
        case ADD_COLUMN:
            let newarray = _.clone(state);
            newarray.push(action.payload.column);
            return newarray;
        case SAVE_COLUMN:

            let newarray2 = _.clone(state);
            let item = _.find(newarray2,item => item.guid === action.payload.column.guid);
            item = action.payload.column;
            return newarray2;
        case REMOVE_COLUMN:
            let newArr = _.filter(state, (o) => { return o.guid !== action.payload.column.guid; });
            return newArr;
        case REMOVE_ALLCOLUMNS:

            return [];
        case ADD_COLUMNS:
            return _.union(state, action.payload.columns);
        default:

            return state;
    }
}
開發者ID:,項目名稱:,代碼行數:30,代碼來源:

示例5: unglob

/**
 * Expands any glob expressions in `patterns`.
 *
 * @param {string} baseDir
 * @param {!Array<string>} patterns
 */
async function unglob(baseDir: string, patterns: string[]): Promise<string[]> {
  const strs: string[][] = [];
  const pGlob: any = promisify(glob);
  for (const pattern of patterns) {
    strs.push(await pGlob(String(pattern), {cwd: baseDir, root: baseDir}));
  }
  return  _.union(_.flatten(strs));
}
開發者ID:digideskio,項目名稱:web-component-tester,代碼行數:14,代碼來源:paths.ts

示例6: map

    taskRunner.run(gulp.series(Clean, Build, Serve)).then(() => {
        let settings = helper.getSettings();
        let bootstrapperBasePath = (settings.bootstrapperStyles) ? settings.bootstrapperStyles :
            path.resolve(process.cwd(), settings.targets, helper.getCurrentTarget());

        let watchFolders = map(settings.watchStyles, folder => path.resolve(process.cwd(), folder) + "/**/*.{scss, css}");

        gulp.watch(union([bootstrapperBasePath], watchFolders), gulp.parallel(Styles));
    });
開發者ID:mtfranchetto,項目名稱:smild,代碼行數:9,代碼來源:FrontendWatchBuild.ts

示例7: expandDirectories

/**
 * Expands any directories in `patterns`, following logic similar to a web
 * server.
 *
 * If a pattern resolves to a directory, that directory is expanded. If the
 * directory contains an `index.html`, it is expanded to that. Otheriwse, the
 * it expands into its children (recursively).
 */
async function expandDirectories(baseDir: string, paths: string[]) {
  const listsOfPaths: string[][] = [];
  for (const aPath of paths) {
    listsOfPaths.push(await expandDirectory(baseDir, aPath));
  }

  const files = _.union(_.flatten(listsOfPaths));
  return files.filter((file) => /\.(js|html)$/.test(file));
}
開發者ID:fearphage,項目名稱:web-component-tester,代碼行數:17,代碼來源:paths.ts

示例8: unglob

/**
 * Expands any glob expressions in `patterns`.
 */
async function unglob(baseDir: string, patterns: string[]): Promise<string[]> {
  const strs: string[][] = [];
  const pGlob: any = promisify(glob);
  for (const pattern of patterns) {
    strs.push(await pGlob(String(pattern), {cwd: baseDir, root: baseDir}));
  }

  // for non-POSIX support, replacing path separators
  return _.union(_.flatten(strs)).map((str) => str.replace(/\//g, path.sep));
}
開發者ID:poehlmann,項目名稱:EvaluacionDiferencialDeLaMemoria,代碼行數:13,代碼來源:paths.ts

示例9: function

    completionPromise: (async function() {
      await Promise.all(promises);
      const error = errors.length > 0 ? _.union(errors).join(', ') : null;
      context.emit('run-end', error);
      // TODO(nevir): Better rationalize run-end and hook.
      await context.emitHook('cleanup');

      if (error) {
        throw new Error(error);
      }
    }())
開發者ID:marcinkubicki,項目名稱:web-component-tester,代碼行數:11,代碼來源:steps.ts

示例10:

        }).then((error) => {
            if (error) {
                this.loggerService.error(this.lang.errors.savingVDF_entries, { invokeAlert: true, alertTimeout: 3000 });
                this.loggerService.error(error);
            }
            this.loggerService.success(this.lang.info.updatingKnownSteamDirList, { invokeAlert: true, alertTimeout: 3000 });

            if (!remove) {
                let settings = this.settingsService.getSettings();
                settings.knownSteamDirectories = _.union(settings.knownSteamDirectories, Object.keys(this.previewData));
                this.settingsService.settingsChanged();
            }
        }).then(() => {
開發者ID:kencinder,項目名稱:steam-rom-manager,代碼行數:13,代碼來源:preview.service.ts


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