本文整理汇总了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);
}
示例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);
});
示例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;
}
}
示例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;
}
}
示例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));
}
示例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));
});
示例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));
}
示例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));
}
示例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);
}
}())
示例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(() => {