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


TypeScript underscore.union函数代码示例

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


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

示例1: executeAsynchronousActions

    return new Promise<void>((resolve, reject) => {
        Logger.info(util.colors.bold(`Uninstalling workspace package '${util.colors.cyan(packageDescriptor.name)}'`));

        try {
            rimraf.sync(path.resolve(packagePath, "node_modules"));

            let postUninstallActions: ConditionableAction<AsyncAction>[]
                = _.union(pluginBinding.options.postUninstallActions, file["getWorkspace"]()["postUninstall"]);

            if (postUninstallActions) {
                Logger.verbose(`Running post-uninstall actions for workspace package '${util.colors.cyan(packageDescriptor.name)}'`);

                executeAsynchronousActions(postUninstallActions, packageDescriptor, packagePath)
                    .then(resolve)
                    .catch((error) => {
                        handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
                    });
            }
            else {
                resolve();
            }
        }
        catch (error) {
            handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
        }
    });
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:26,代码来源:UninstallPackages.ts

示例2: handleError

    return new Promise<void>((resolve, reject) => {
        try {
            let localCucumberPath = path.join(packagePath, "./node_modules/cucumber/bin/cucumber.js");
            let hasLocalCucumber = fs.existsSync(localCucumberPath);
            let workspaceCucumberPath = path.join(pluginBinding.options.cwd, "./node_modules/cucumber/bin/cucumber.js");
            let hasWorkspaceCucumber = fs.existsSync(workspaceCucumberPath);

            if (!hasLocalCucumber && !hasWorkspaceCucumber) {
                return handleError(new Error("Could not load the 'cucumber' package. Add 'cucumber' to the workspace 'package.json'."),
                                   packageDescriptor.name, pluginBinding.options.continueOnError, reject);
            }

            let cucumber: any;

            try {
                cucumber = require("cucumber");
            }
            catch (error) {
                return handleError(new Error("Could not load the 'cucumber' package. Add 'cucumber' to the workspace 'package.json'."),
                                   packageDescriptor.name, pluginBinding.options.continueOnError, reject);
            }

            let featurePaths = glob.sync("./features", { cwd: packagePath });

            if (!featurePaths || featurePaths.length === 0) {
                featurePaths = glob.sync("./*/features", { cwd: packagePath });
            }

            if (!featurePaths || featurePaths.length === 0) {
                Logger.warn(`Could not find a 'features' folder for workspace package '${util.colors.cyan(packageDescriptor.name)}'`);

                return resolve();
            }

            let supportCodePaths = _.union(glob.sync("./support", { cwd: packagePath }),
                                           glob.sync("./step_definitions", { cwd: packagePath }),
                                           glob.sync("./*/support", { cwd: packagePath }),
                                           glob.sync("./*/step_definitions", { cwd: packagePath }));

            let cmdArgs = [ "node", hasLocalCucumber ? localCucumberPath : workspaceCucumberPath, path.join(packagePath, featurePaths[0]) ];

            supportCodePaths.forEach((supportCodePath) => {
                cmdArgs = cmdArgs.concat("-r").concat(path.join(packagePath, supportCodePath));
            });

            cucumber.Cli(cmdArgs).run((success) => {
                if (success) {
                    return resolve();
                }

                return handleError(new Error("Tests failed."),
                                   packageDescriptor.name, pluginBinding.options.continueOnError, reject);
            });
        }
        catch (error) {
            handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
        }
    });
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:58,代码来源:TestCucumberPackages.ts

示例3:

 _.each(scope.section.links,(item: any)=>{
     var permissionStr = item.permission;
     if(permissionStr != undefined) {
         var arr = [];
         if(angular.isArray(permissionStr)) {
             arr = permissionStr;
             //the directive template uses the permission key to check.  it needs to be a string.
             item.permission = arr.join(",")
         }
         else {
             arr = permissionStr.split(',');
         }
         allPermissions = _.union(allPermissions, arr);
     }
 });
开发者ID:prashanthc97,项目名称:kylo,代码行数:15,代码来源:menu_toggle.ts

示例4: union

function mergeResources<T>(
  current: ISource<T>,
  addition: ISource<T>
): ISource<T> {
  if (!current) {
    return addition;
  }

  if (!addition) {
    return current;
  }

  return {
    set: { ...current.set, ...addition.set },
    ids: union(current.ids, addition.ids),
  };
}
开发者ID:HorrerGames,项目名称:itch,代码行数:17,代码来源:search-helpers.ts

示例5: workspacePackages

export function workspacePackages(options?: gulp.SrcOptions & NpmWorkspacePluginOptions & WorkspacePackagesOptions): NodeJS.ReadWriteStream {
    options = _.extend(getWorkspacePluginOptions(options), options, { read: true });

    let context = new PackageDependencyContext();
    let productionOnly = options.productionOnly || false;

    let packageSourcePaths = [ "./package.json", "./*/package.json" ];

    if (options.additionalPaths) {
       packageSourcePaths = _.union(packageSourcePaths, options.additionalPaths.map((p) => path.join(p, "*/package.json")))
    }

    let packagesStream = gulp.src(packageSourcePaths, options)
        .pipe(through.obj(collectPackages(context, productionOnly), streamPackages(context, options)));

    packagesStream.once("error", () => { });

    return packagesStream;
}
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:19,代码来源:WorkspacePackages.ts

示例6: isTextPresentInFeature

function isTextPresentInFeature(searchContext: ISearchContext, feature: IFeature): IFeature {
  const tagsScenariosMap = _.map(searchContext.tags, t => isTagPresentInFeature(t, feature));

  if (_.any(tagsScenariosMap, a => a === null)) {
    return null;
  }

  const tagsScenarios = _.union(...tagsScenariosMap);

  const isTextPresentInTitle = isTextPresent(searchContext, feature.Feature.Name);

  const isTextPresentInDescription = isTextPresent(searchContext, feature.Feature.Description);

  const isTextPresentInBackground = feature.Feature.Background &&
    isTextPresentInScenario(searchContext, feature.Feature.Background);

  // Intersection is made to preserve original order between scenarios
  let scenarios = !_.any(searchContext.tags)
    ? feature.Feature.FeatureElements : _.intersection(feature.Feature.FeatureElements, tagsScenarios);

  scenarios = _.filter(scenarios, s => isTextPresentInScenario(searchContext, s));
  if (!isTextPresentInTitle && !isTextPresentInDescription && !isTextPresentInBackground && !_.any(scenarios)) {
    return null;
  }

  return {
    Feature: {
      Background: !isTextPresentInBackground ? null : feature.Feature.Background,
      Description: feature.Feature.Description,
      FeatureElements: scenarios,
      Name: feature.Feature.Name,
      Result: feature.Feature.Result,
      Tags: feature.Feature.Tags
    },
    RelativeFolder: feature.RelativeFolder,
    code: feature.code,
    get isExpanded() { return feature.isExpanded; },
    set isExpanded(value: boolean) { feature.isExpanded = value; },
    isManual: feature.isManual
  };
}
开发者ID:eugene-sea,项目名称:LivingDocumentation,代码行数:41,代码来源:search.service.ts

示例7: throttle

const queueCleanup = throttle((store: IStore, window: string) => {
  // TODO: figure that out multi-window
  const validKeys = new Set(
    Object.keys(store.getState().windows[window].tabInstances)
  );

  const wfs = getWindowFetchState(window);

  const allKeys = union(
    Object.keys(wfs.lastFetchers),
    Object.keys(wfs.nextFetchReason),
    Object.keys(wfs.fetching)
  );
  for (const k of allKeys) {
    if (!validKeys.has(k)) {
      logger.debug(`Cleaning up ${k}`);
      delete wfs.lastFetchers[k];
      delete wfs.fetching[k];
      delete wfs.nextFetchReason[k];
    }
  }
}, 3000 /* space out cleanups */);
开发者ID:HorrerGames,项目名称:itch,代码行数:22,代码来源:fetchers.ts

示例8: makeItem


//.........这里部分代码省略.........
  let currentBucket = buckets.byHash[item.bucket] || normalBucket;
  if (!normalBucket) {
    currentBucket = normalBucket = buckets.unknown;
    buckets.setHasUnknown();
  }

  // We cheat a bit for items in the vault, since we treat the
  // vault as a character. So put them in the bucket they would
  // have been in if they'd been on a character.
  if (currentBucket.id.startsWith('BUCKET_VAULT')) {
    // TODO: Remove this if Bungie ever returns bucket.id for classified
    // items in the vault.
    if (itemDef.classified && itemDef.itemTypeName === 'Unknown') {
      if (currentBucket.id.endsWith('WEAPONS')) {
        currentBucket = buckets.byType.Heavy;
      } else if (currentBucket.id.endsWith('ARMOR')) {
        currentBucket = buckets.byType.ClassItem;
      } else if (currentBucket.id.endsWith('ITEMS')) {
        currentBucket = buckets.byType.Artifact;
      }
    } else {
      currentBucket = normalBucket;
    }
  }

  const itemType = normalBucket.type || 'Unknown';

  const dmgName = [null, 'kinetic', 'arc', 'solar', 'void'][item.damageType];

  itemDef.sourceHashes = itemDef.sourceHashes || [];

  const missingSource = missingSources[itemDef.hash] || [];
  if (missingSource.length) {
    itemDef.sourceHashes = _.union(itemDef.sourceHashes, missingSource);
  }

  const createdItem: D1Item = Object.assign(Object.create(ItemProto), {
    // figure out what year this item is probably from
    destinyVersion: 1,
    // The bucket the item is currently in
    location: currentBucket,
    // The bucket the item normally resides in (even though it may be in the vault/postmaster)
    bucket: normalBucket,
    hash: item.itemHash,
    // This is the type of the item (see dimCategory/dimBucketService) regardless of location
    type: itemType,
    itemCategoryHashes: itemDef.itemCategoryHashes || [],
    tier: tiers[itemDef.tierType] || 'Common',
    isExotic: tiers[itemDef.tierType] === 'Exotic',
    isVendorItem: !owner || owner.id === null,
    name: itemDef.itemName,
    description: itemDef.itemDescription || '', // Added description for Bounties for now JFLAY2015
    icon: itemDef.icon,
    secondaryIcon: itemDef.secondaryIcon,
    notransfer: Boolean(
      currentBucket.inPostmaster ||
        itemDef.nonTransferrable ||
        !itemDef.allowActions ||
        itemDef.classified
    ),
    id: item.itemInstanceId,
    equipped: item.isEquipped,
    equipment: item.isEquipment,
    equippingLabel:
      item.isEquipment && tiers[itemDef.tierType] === 'Exotic' ? normalBucket.sort : undefined,
    complete: item.isGridComplete,
开发者ID:bhollis,项目名称:DIM,代码行数:67,代码来源:d1-item-factory.service.ts

示例9: linkWorkspacePackage


//.........这里部分代码省略.........

                lookupRegistryDependencies(pluginBinding.options.registryMap[packageName], packageDependencies)
                    .push(`${packageName}@${pluginBinding.toSemverRange(packageDescriptor.dependencies[packageName])}`);
            }

            if (!pluginBinding.options.productionOnly) {
                let devDependencies: IDictionary<string> = { };

                _.extend(devDependencies, packageDescriptor.devDependencies, packageDescriptor.optionalDependencies);

                for (let packageName in devDependencies) {
                    mappedPackage = packageMap[packageName];
                    externalPackagePath = pluginBinding.options.externalWorkspacePackageMap[packageName];

                    if (!pluginBinding.options.disableExternalWorkspaces && (mappedPackage && externalPackagePath)) {
                        Logger.warn(`Package '${packageName}' is both a workspace package and has an entry in options.externalWorkspacePackageMap. Using workspace package.`);
                    }

                    if (mappedPackage) {
                        linkWorkspacePackage(pluginBinding, packageName, packagePath, mappedPackage.packagePath);

                        continue;
                    }

                    if (!pluginBinding.options.disableExternalWorkspaces && externalPackagePath) {
                        linkExternalPackage(pluginBinding, packageName, packagePath, externalPackagePath);

                        continue;
                    }

                    if (!pluginBinding.options.minimizeSizeOnDisk) {
                        // Don't care about minimizing size on disk, so install it in the package
                        lookupRegistryDependencies(pluginBinding.options.registryMap[packageName], packageDependencies)
                            .push(`${packageName}@${pluginBinding.toSemverRange(packageDescriptor.devDependencies[packageName])}`);

                        continue;
                    }

                    let workspacePackagePath = path.join(pluginBinding.options.cwd, "node_modules", packageName);

                    if (!fs.existsSync(workspacePackagePath)) {
                        // Doesn't exist in the workspace, so install it there
                        lookupRegistryDependencies(pluginBinding.options.registryMap[packageName], workspaceDependencies)
                            .push(`${packageName}@${pluginBinding.toSemverRange(packageDescriptor.devDependencies[packageName])}`);
                    }
                    else {
                        // Does exist in the workspace, so if the version there satisfies our version requirements do nothing
                        // and we'll use that version; otherwise, install it in the package
                        let workspacePackageVersion = require(path.join(workspacePackagePath, "package.json")).version;

                        if (!semver.satisfies(workspacePackageVersion, packageDescriptor.devDependencies[packageName])) {
                            lookupRegistryDependencies(pluginBinding.options.registryMap[packageName], packageDependencies)
                                .push(`${packageName}@${pluginBinding.toSemverRange(packageDescriptor.devDependencies[packageName])}`);

                            Logger.warn(util.colors.yellow(`Package '${packageName}' cannot be satisfied by version ${workspacePackageVersion}. Installing locally.`));
                        }
                    }
                }
            }

            Logger.verbose((logger) => {
                let logDependencies = function(level: string, registryPackages: IDictionary<Array<string>>) {
                    for (let registry in registryPackages) {
                        let packages = registryPackages[registry];

                        if (!packages || packages.length === 0) continue;

                        logger(`  ${util.colors.blue(registry)}`);
                        packages.forEach((p) => { logger(`    - ${util.colors.cyan(p)} (${level})`); });
                    }
                };

                logger("Installing:")
                logDependencies("workspace package", packageDependencies);
                logDependencies("workspace", workspaceDependencies);
            });

            pluginBinding.shellExecuteNpmInstall(packagePath, workspaceDependencies);
            pluginBinding.shellExecuteNpmInstall(packagePath, packageDependencies);

            let postInstallActions: ConditionableAction<AsyncAction>[]
                = _.union(pluginBinding.options.postInstallActions, file["getWorkspace"]()["postInstall"]);

            if (postInstallActions && postInstallActions.length > 0) {
                Logger.verbose(`Running post-install actions for workspace package '${util.colors.cyan(packageDescriptor.name)}'`);

                executeAsynchronousActions(postInstallActions, packageDescriptor, packagePath)
                    .then(resolve)
                    .catch((error) => {
                        handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
                    });
            }
            else {
                resolve();
            }
        }
        catch (error) {
            handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
        }
    });
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:101,代码来源:InstallPackages.ts

示例10: require

    return new Promise<void>((resolve, reject) => {
        Logger.info(util.colors.bold(`Publishing workspace package '${util.colors.cyan(packageDescriptor.name)}'`));

        let prepareFunction = () => {
            if (pluginBinding.options.shrinkWrap) {
                pluginBinding.shellExecuteNpm(packagePath, [ "shrinkwrap" ]);

                //
                // Filter out any 'resolved' fields

                let shrinkWrapFilePath = path.join(packagePath, "npm-shrinkwrap.json");
                let shrinkwrap = require(shrinkWrapFilePath);

                function replacer(key, val) {
                    if (key === "resolved" && this.from && this.version) {
                        return undefined;
                    }

                    return val;
                }

                fs.writeFileSync(shrinkWrapFilePath, JSON.stringify(shrinkwrap, replacer, 2));
            }

            let versionBump = pluginBinding.options.versionBump;

            if (versionBump) {
                packageDescriptor = bumpVersion(packageDescriptor, packagePath, versionBump);

                jsonFile.writeFileSync(path.join(packagePath, "package.json"), packageDescriptor, { spaces: 4 });

                file.contents = new Buffer(JSON.stringify(packageDescriptor));
            }
        };

        let publishFunction = () => {
            let publishArgs = [ "publish" ];

            if (pluginBinding.options.tag) publishArgs.push("--tag " + pluginBinding.options.tag);
            if (pluginBinding.options.access) publishArgs.push("--access " + pluginBinding.options.access);

            pluginBinding.shellExecuteNpm(packagePath, publishArgs);
        };

        try {
            let prePublishActions: ConditionableAction<AsyncAction>[] =
                _.union(pluginBinding.options.prePublishActions, file["getWorkspace"]()["prePublish"]);

            Logger.verbose(`Running pre-publish actions for workspace package '${util.colors.cyan(packageDescriptor.name)}'`);

            executeAsynchronousActions(prePublishActions || [], packageDescriptor, packagePath)
            .then(prepareFunction)
            .then(publishFunction)
            .then(resolve)
            .catch((error) => {
                handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
            });
        }
        catch (error) {
            handleError(error, packageDescriptor.name, pluginBinding.options.continueOnError, reject);
        }
    });
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:62,代码来源:PublishPackages.ts


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