本文整理汇总了TypeScript中deepmerge.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: loadFile
export const load = (
name: string,
defaultConfig: any = {},
noCache?: boolean
) => {
let file = {}
const filepath = findup.sync(finds(name))
if (filepath) {
file = loadFile(filepath, defaultConfig, noCache)
}
return defaultConfig !== null ? merge(defaultConfig, file) : file
}
示例2: function
export default function(givenInitialState: Partial<State> = {}) {
const initialState = merge(getInitialState(), givenInitialState);
const epicMiddleware = createEpicMiddleware();
const composeEnhancers =
(typeof window !== "undefined" &&
(window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
compose;
const store = createStore(
reducer,
initialState,
composeEnhancers(applyMiddleware(epicMiddleware, errorMiddleware))
);
epicMiddleware.run(epics);
return store;
}
示例3: async
export default async (args: Args) => {
args = merge<Args>(
{
options: {
env: {
NODE_ENV: process.env.NODE_ENV || 'development',
},
},
middleware: [],
},
args
)
const compiler = await run('inspect', args)
// tslint:disable-next-line:no-console
console.log(compiler)
}
示例4: async
export default async (args: Args) => {
args = merge<Args>(
{
options: {
env: {
NODE_ENV: process.env.NODE_ENV || 'production',
},
},
middleware: [],
},
args
)
const spinner = ora('Building project').start()
let result
try {
result = await run('build', args)
} catch (err) {
spinner.fail('Failed to compile.')
printBuildError(err)
process.exit(1)
}
const { warnings } = result
if (warnings.length) {
spinner.warn('Compiled with warnings.')
// tslint:disable-next-line:no-console
console.log(warnings.join('\n\n'))
// tslint:disable-next-line:no-console
console.log(
'\nSearch for the ' +
chalk.underline(chalk.yellow('keywords')) +
' to learn more about each warning.'
)
// tslint:disable-next-line:no-console
console.log(
'To ignore, add ' +
chalk.cyan('// eslint-disable-next-line') +
' to the line before.\n'
)
} else {
spinner.succeed('Compiled successfully.')
}
}
示例5: async
export default async (args: Args) => {
const serverOptions = await getServerOptions(args)
const protocol = serverOptions.https ? 'https' : 'http'
const url = `${protocol}://${serverOptions.host}:${serverOptions.port}`
args = merge<Args>(
{
options: {
env: {
NODE_ENV: process.env.NODE_ENV || 'development',
},
},
middleware: [],
},
args
)
if (isInteractive) {
clearConsole()
}
const spinner = ora('Compiling project').start()
let multiCompiler: MultiCompiler
try {
multiCompiler = await run('start', args)
} catch (err) {
spinner.fail('Failed to compile')
// tslint:disable:no-console
console.log()
console.log(err.stackTrace || err)
console.log()
// tslint:enable:no-console
throw exitProcess(1)
}
const server = new Server({
multiCompiler,
...serverOptions,
})
await server.listen()
spinner.succeed(`Development server running on: ${url}`)
openBrowser(url)
const building = ora('Waiting for initial compilation to finish').start()
multiCompiler.plugin('done', (stats: Stats) => {
if (isInteractive) {
clearConsole()
}
// We have switched off the default Webpack output in WebpackDevServer
// options so we are going to "massage" the warnings and errors and present
// them in a readable focused way.
const messages = formatWebpackMessages(stats.toJson())
const isSuccessful = !messages.errors.length && !messages.warnings.length
if (isSuccessful) {
building.succeed(`Compiled successfully!`)
}
// If errors exist, only show errors.
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1
}
building.fail(`Failed to compile`)
// tslint:disable-next-line:no-console
console.log(messages.errors.join('\n\n'))
return
}
// Show warnings if no errors were found.
if (messages.warnings.length) {
building.warn('Compiled with warnings')
// tslint:disable-next-line:no-console
console.log(messages.warnings.join('\n\n'))
// Teach some ESLint tricks.
// tslint:disable-next-line:no-console
console.log(
'\nSearch for the ' +
chalk.underline(chalk.yellow('keywords')) +
' to learn more about each warning.'
)
// tslint:disable-next-line:no-console
console.log(
'To ignore, add ' +
chalk.cyan('// eslint-disable-next-line') +
' to the line before.\n'
)
}
})
multiCompiler.plugin('invalid', () => {
if (isInteractive) {
clearConsole()
}
building.text = 'Compiling...'
building.start()
})
//.........这里部分代码省略.........
示例6: renderChart
export function renderChart(elementId: string, definition: any, data?: any) {
if (definition.type === 'custom') {
const chart = AmCharts.makeChart(elementId, definition.specification)
return
}
// Clone/copy spec and data
// Longer than normal conditional so setting as its own const
const hasSpecAndIsntString = definition.specification && typeof definition.specification !== 'string'
// ternary checking to see if there is a def.spec and that it is NOT a string (url)
// if true than return def.spec. If not true than fetch a premade spec
let spec = hasSpecAndIsntString ? clone(definition.specification) : fetchSpec(definition.type)
const copyData = clone(data)
// Set the spec's data
spec.dataProvider = copyData
// Apply the series
if (!!definition.datasets) {
spec = fillInSpec(spec, definition)
}
// Apply overrides
if (definition.overrides) {
// NOTE: this counts on using deepmerge < 2.x
// see: https://github.com/KyleAMathews/deepmerge#arraymerge
spec = deepmerge(spec, definition.overrides, { clone: true })
}
const chart = AmCharts.makeChart(elementId, spec)
return
}
示例7: getOptions
function getOptions(command: Command, args: Args, target: Target) {
return merge<Options>(
{
target,
command,
browserEntry: require.resolve('./entry-points/browser'),
serverEntry: require.resolve('./entry-points/server'),
mains: { index: 'app' },
output: target === 'browser' ? 'build/static' : 'build/ssr',
quiet: true,
},
args.options
)
}
示例8: reduce
export const babelrc = (args: Config): BabelRC => {
const config = merge(load('babel', null), {
babelrc: false,
cacheDirectory: !args.debug,
presets: [
[require.resolve('babel-preset-react-app'), { flow: !args.typescript }],
...(args.typescript ? [require.resolve('@babel/preset-typescript')] : []),
],
plugins: [],
})
const reduce = Plugin.reduceFromPlugins<BabelRC>(args.plugins)
return reduce('modifyBabelRc', config)
}
示例9: return
return (vuexStore: Store<IState>) => {
const hydratedState: IState = {} as IState;
storages.forEach((storage: IVuexPersistStorage): void => {
if (canWriteStorage(storage)) {
processStorage(storage, hydratedState, vuexStore);
}
});
const mergedState: IState = merge(vuexStore.state, hydratedState, {
clone: false,
arrayMerge: (store, saved) => {
return saved;
},
});
vuexStore.replaceState(mergedState);
};
示例10: merge
export const setupHappypack = (config: Config, args: Args, babelrc: any) => {
const babelLoader: any = {
loader: require.resolve('babel-loader'),
options: merge(babelrc, {
plugins: [require.resolve('react-hot-loader/babel')],
}),
}
const jsx = {
id: 'jsx',
verbose: args.debug,
loaders: [babelLoader],
}
if (args.propsParser && !args.typescript) {
babelLoader.options.plugins.push(
require.resolve('babel-plugin-react-docgen')
)
}
if (args.propsParser && args.typescript) {
jsx.loaders.push({
loader: require.resolve('react-docgen-typescript-loader'),
})
}
const mdx = {
id: 'mdx',
verbose: args.debug,
loaders: [
{
loader: require.resolve('babel-loader'),
options: babelrc,
},
],
}
config.plugin('happypack-jsx').use(HappyPack, [jsx])
config.plugin('happypack-mdx').use(HappyPack, [mdx])
}