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