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


TypeScript merge.default函數代碼示例

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


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

示例1: _registerTheme

  /** Registers a theme in the $mdTheming provider */
  private _registerTheme(theme: MdTheme) {
    // Apply defaults theme palettes to current theme.
    theme = merge({}, DefaultConfig.theme, theme);

    let themeRef = this._$mdThemingProvider
      .theme(theme.name || 'default')
      .primaryPalette(theme.primaryPalette, theme.primaryPaletteHues)
      .accentPalette(theme.accentPalette, theme.accentPaletteHues)
      .warnPalette(theme.warnPalette, theme.warnPaletteHues)
      .backgroundPalette(theme.backgroundPalette, theme.backgroundPaletteHues);

    if (theme.dark) {
      themeRef.dark();
    }
  }
開發者ID:angular,項目名稱:material-tools,代碼行數:16,代碼來源:ThemeBuilder.ts

示例2: serve

export function serve(options: ScaleOptions, app?: () => void): void {
  var i, startTimes = {}, failures = 0;
  options = merge({
    cores: defaultCores,
    retryThreshold: 23,
    retryDelay: 10000,
    failureThreshold: 5000
  }, options);

  function pid(worker) {
    return options.worker ? worker.pid : worker.process.pid;
  }

  function spawnMore() {
    var worker;
    if (options.worker) {
      worker = child.fork(options.worker, options.workerArgs);
      log.debug("Spawning worker %s as child process: %j %j",
                pid(worker), options.worker, options.workerArgs);
    } else {
      worker = cluster.fork();
      log.debug("Spawning worker in cluster:", pid(worker));
    }

    startTimes[pid(worker)] = Date.now();
    if (!options.worker) {
      worker.on("listening", (addr) =>
                log.info("Process", pid(worker), "is now listening on",
                         addr.address + ":" + addr.port));
    }

    // Enable Erlang mode
    worker.on("exit", (code, signal) => {
      var replacement, lifetime = Date.now() - startTimes[pid(worker)];
      delete startTimes[pid(worker)];

      if (worker.suicide) {
        log.info("Worker", pid(worker), "terminated voluntarily.");
        return;
      }

      log.info("Process", pid(worker), "terminated with signal", signal,
                  "code", code + "; restarting.");

      if (lifetime < options.failureThreshold) {
        failures++;
      } else {
        failures = 0;
      }

      if (failures > options.retryThreshold) {
        log.warn(failures + " consecutive failures; pausing for",
                 options.retryDelay + "ms before respawning.");
      }

      setTimeout(() => {
        replacement = spawnMore();
        replacement.on("online", () =>
                       log.info("Process", replacement.process.pid,
                                "has successfully replaced", pid(worker)));
      }, (failures > options.retryThreshold) ? options.retryDelay : 0);
    });

    return worker;
  }

  if (cluster.isMaster) {
    // Spawn more overlords
    for (i = 0; i < options.cores; i++) {
      spawnMore();
    }

    log.info("Spawned", options.cores, options.worker ? "worker processes."
             : "server instances.");
  } else {
    log.handleExceptions();
    options.worker || app();
  }
}
開發者ID:FutureAdLabs,項目名稱:hellojoe,代碼行數:79,代碼來源:hellojoe.ts

示例3: appendJSConfig

export function appendJSConfig(data): boolean {
    if (!workspace || !workspace.rootPath) {
        return false;
    }

    let jscPath = path.join(workspace.rootPath, "jsconfig.json");
    let newJsc;
    let mergedJsc;
    let currentJsc;

    // Check first if a jsconfig.json exists
    if (pathExists.sync(jscPath)) {
        // Merge
        try {
            currentJsc = JSON.parse(fs.readFileSync(jscPath, "utf8"));
            mergedJsc = merge(currentJsc, data);
        } catch (e) {
            console.log(e);
        }
    }

    // Write new config
    try {
        newJsc = mergedJsc || jsConfig;
        fs.writeFileSync(jscPath, JSON.stringify(newJsc), "utf8");
    } catch (e) {
        return false;
    }
}
開發者ID:ChrisBriggsy,項目名稱:vsc-ember-cli,代碼行數:29,代碼來源:file-ops.ts

示例4: addDefaults

function addDefaults(option: any): any {
  return merge({
    type: 'string',
    requiresArg: true,
    group: MAIN_GROUP,
    global: true
  }, option);
}
開發者ID:angular,項目名稱:material-tools,代碼行數:8,代碼來源:options.ts

示例5: writeSetting

export function writeSetting(data) {
    let currentConfig, mergedConfig, newConfig;
    // Check first if a jsconfig.json exists
    if (pathExists.sync(configPath)) {
        // Merge
        try {
            currentConfig = JSON.parse(fs.readFileSync(configPath, "utf8"));
            mergedConfig = merge(currentConfig, data);
        } catch (e) {
            console.log(e);
        }
    }

    // Write new config
    try {
        newConfig = mergedConfig || data;
        fs.writeFileSync(configPath, JSON.stringify(newConfig), "utf8");
        return true;
    } catch (e) {
        return false;
    }
}
開發者ID:Georotzen,項目名稱:vsc-ember-cli,代碼行數:22,代碼來源:config.ts

示例6: function

 passport.use( new passportGithub.Strategy(passportOptions, function(accessToken, refreshToken, profile, done) {
     done(null, merge(profile._json, { token: accessToken }));
 }));
開發者ID:thojansen,項目名稱:github-seed,代碼行數:3,代碼來源:githubAuthentication.ts

示例7: it

  it('should reject for an invalid file path', done => {
    let versionDataCopy = merge({}, versionData, { module: './some/random/path/' });

    LocalResolver.resolve(components, versionDataCopy)
      .then(() => done.fail(), done);
  });
開發者ID:angular,項目名稱:material-tools,代碼行數:6,代碼來源:LocalResolver.spec.ts


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