本文整理汇总了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);
});