function sendMessageWrapper (agent, original) { return function (channel, Method, fields, Properties, props, content) { var traceHeaders = { 'x-client-send': String(microtime.now()), 'x-parent': String(agent.getServiceKey()) } debug.info('amqplib.sendMessageWrapper', 'sending instrumented message...') defaults(fields.headers, traceHeaders) return original.apply(this, arguments) } }
// sign params, add signature. Return the created payload function signedParams(method, path, host, keys, params = {}) { params = defaults(clone(params), { access_key: keys.accessKey, timestamp: new Date().toISOString() }); params.signature = generateHmacSignature(method, path, host, keys, params); return params; }
Object.keys(this.middleware).reduce((acc, current) => { // Try to find the settings in the current environment, then in the main configurations. const currentSettings = merge(get(cloneDeep(this.middleware[current]), ['defaults', current], {}), flattenMiddlewaresConfig[current] || this.config.currentEnvironment[current] || this.config[current]); acc[current] = !isObject(currentSettings) ? {} : currentSettings; if (!acc[current].hasOwnProperty('enabled')) { this.log.warn(`(middleware:${current}) wasn't loaded due to missing key \`enabled\` in the configuration`); } // Ensure that enabled key exist by forcing to false. defaults(acc[current], { enabled : false }); return acc; }, {})
function getRdpFileContent(config) { defaults(config, mapping); var rdpConfigText = ''; for (var key in config) { if (mappingStructure[key].name) { rdpConfigText += mappingStructure[key].name + mappingStructure[key].fn(config[key]) + '\n'; } } return rdpConfigText; }
function webpack3Compiler (config) { return webpack({ entry: './test/erb/' + config.file, module: { loaders: [ { test: /\.erb$/, loader: './index', options: defaults({}, config, { dependenciesRoot: './test/dependencies', timeoutMs: 2000 }) } ] }, output: { filename: './output.js' } }) }
Object.keys(this.hook).reduce((acc, current) => { // Try to find the settings in the current environment, then in the main configurations. const currentSettings = flattenHooksConfig[current] || this.config[current]; if (isString(currentSettings)) { acc[current] = currentSettings; } else { acc[current] = !isObject(currentSettings) ? {} : currentSettings; if (!acc[current].hasOwnProperty('enabled')) { this.log.warn(`(hook:${current}) wasn't loaded due to missing key \`enabled\` in the configuration`); } // Ensure that enabled key exist by forcing to false. defaults(acc[current], { enabled : false }); } return acc; }, {})
const pages = (filePath, options, callback) => { if (typeof options === 'function') { callback = options options = {} } if (typeof callback !== 'function') return options = defaults(options || {}, { text: false }) debug('Converts PDF to HTML pages') html(filePath, (err, html) => { if (err) return callback(err) const $ = cheerio.load(html) const pages = [] const $pages = $('.page') $pages.each((index) => { const $page = $pages.eq(index) pages.push(options.text ? $page.text().trim() : $page.html()) }) return callback(null, pages) }) }
const createApiNormalizer = ({ endpoint: baseUrl }) => flow( defaults({ method: 'GET', headers: { 'content-type': 'application/x-www-form-urlencoded; charset=utf-8', }, }), mapParams({ currentPage: 'page', sizePerPage: 'per-page', }), toJson(['filter']), accumulate('query', [ 'fields', 'sort', 'filter', 'expand', 'page', 'per-page', ]), normalizeEndpoint(baseUrl), normalizeBody, pick([ 'endpoint', 'method', 'body', 'headers', 'credentials', ]), )
middlewareCategories.reduce((acc, index) => { const current = merge(this.config.currentEnvironment[index], { public: defaults(this.config.public, { enabled: true }), favicon: defaults(this.config.favicon, { enabled: true }) }); if (isObject(current)) { acc = merge(acc, current); } else { acc[index] = current; } return acc; }, {})
function withGen(spec, genFn) { return defaults(omit(specize(spec), 'gen'), {gen: genFn}); }
const runPDFBox = (filePath, options, callback) => { options = defaults(options || {}, { page: 1, imageType: 'png', width: 160, height: 226 }) const uri = new URI(filePath)
function webpack4Compiler (config) { return webpack({ entry: './test/erb/' + config.file, mode: 'development', module: { rules: [ { test: /\.erb$/, loader: './index', options: defaults({}, config, { dependenciesRoot: './test/dependencies', timeoutMs: 2000 }) } ] }, output: { path: __dirname, filename: 'output.js' } }) }