本文整理匯總了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();
}
}
示例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();
}
}
示例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;
}
}
示例4: addDefaults
function addDefaults(option: any): any {
return merge({
type: 'string',
requiresArg: true,
group: MAIN_GROUP,
global: true
}, option);
}
示例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;
}
}
示例6: function
passport.use( new passportGithub.Strategy(passportOptions, function(accessToken, refreshToken, profile, done) {
done(null, merge(profile._json, { token: accessToken }));
}));
示例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);
});