function loadKubeconfig (cfgPath) { let cfgPaths if (!cfgPath) { cfgPaths = defaultConfigPaths() } else if (Array.isArray(cfgPath)) { cfgPaths = cfgPath } else { cfgPaths = [cfgPath] } const configs = cfgPaths.map(cfgPath => { const config = yaml.safeLoad(fs.readFileSync(cfgPath)) return mapCertificates(cfgPath, config) }) return merge.all(configs) }
const mergeVariations = variations => { return variations .map(getRegionAndSlugByVariation) .reduce( (variations, variation) => merge(variations, find(variation.region, variation.slug)), {} ); }
function generateConfig (conf = {}) { const result = merge(DEFAULT_CONFIG, conf) if (conf.destination) { result.exclude.push(path.relative(process.cwd(), conf.destination)) } return result }
test('config is merged correctly', async t => { const conf1 = config.generateConfig() t.deepEqual(conf1, config.DEFAULT_CONFIG) const modifier = { exclude: ['deps/'], custom_key: 'test' } const conf2 = config.generateConfig(modifier) t.deepEqual(conf2, deepmerge(config.DEFAULT_CONFIG, modifier)) })
/** * Deeply merges a given set of objects together. * * Objects to the right take priority. * * @param {...Object} args - The objects to merge. * * @return {Object} - The merged object. */ function mergeDeep(left: Object, right: Object): Object { return deepMerge(left, right) }
/** * Get the workbox config from gasket.config with defaults * * @param {Gasket} gasket - Gasket * @returns {Object} config */ function getWorkboxConfig(gasket) { const { workbox: workboxConfig = {} } = gasket.config; return merge(defaultConfig, workboxConfig); }
// Deep merge utility for configuration objects const deepMerge = function(...values) { const objects = values.filter(isPlainObj) return deepmerge.all(objects, { arrayMerge }) }
constructor(config = {}, options = {}) { super(); const { apiKey, apiSecret, passphrase, unique_id, otc_id, spot_id } = config; this.config = config; this.options = deepmerge(defaultOptions, options); this.passphrase = passphrase; this.apiSecret = apiSecret; this.apiKey = apiKey; this.otc_id = otc_id; this.spot_id = spot_id; this.unique_id = unique_id; this.proxy = isProxy ? 'http://127.0.0.1:1087' : null; this.resp_time_n = 500; }
function create (userFunctions, userConfig) { const opts = deepmerge(defaults, userConfig) const seedPrefix = opts.randomSeed ? crypto.randomBytes(16).toString('hex') : opts.seedPrefix const seedNumber = (opts.seedNumber !== undefined) ? opts.seedNumber : 0 var events = new EventEmitter() return { events, run } async function run () { for (let i = 0; i < opts.numIterations; i++) { const fuzzer = new GenericFuzzer(userFunctions, { ...userConfig, seed: seedPrefix, seedNumber: seedNumber + i }) await fuzzer.setup() events.emit('progress') await fuzzer.run() } } }
function formatSwapPosition(res) { if (!res) return null; const resMap = {}; _.forEach(res, (l) => { const { margin_mode, timestamp, holding, instrument_id: _instrument_id } = l; const time = new Date(timestamp); _.forEach(holding, (l) => { const instrument_id = l.instrument_id || _instrument_id; const old = resMap[instrument_id] || { // long_amount: 0, // long_margin: 0, // short_amount: 0, // short_margin: 0 }; const _l = { ..._formatSwapPosition({ instrument_id, ...l }), margin_mode, time }; const newl = deepmerge(old, _l); resMap[instrument_id] = newl; }); }); return _.values(resMap); }
opts = deepMerge({ apiToken: '' === apiToken ? null : apiToken, }, opts || {});
this.fields[key] = this.mergeArrayDeduped(existing, value); } else if (isObject(value) && isObject(existing)) { this.fields[key] = deepmerge(existing, value, { arrayMerge: this.mergeArrayDeduped });
const combineResolvers = (resolvers = []) => resolvers .reduce((combined, resolver) => merge(combined, resolver))
/** * Get the workbox config from gasket.config with defaults * * @param {Gasket} gasket - Gasket * @returns {Object} config */ function getWorkboxConfig(gasket) { const { workbox: workboxConfig = {} } = gasket.config; return merge(defaultConfig, workboxConfig); }
/** * Deeply merges a given set of objects together. * * Objects to the right take priority. * * @param {...Object} args - The objects to merge. * * @return {Object} - The merged object. */ function mergeDeep(left: Object, right: Object): Object { return deepMerge(left, right) }