How to use the applyToDefaultsWithShallow function from hoek
Find comprehensive JavaScript hoek.applyToDefaultsWithShallow code examples handpicked from public code repositorys.
GitHub: ferlores/good

35 36 37 38 39 40 41 42 43 44
options = options || {}; Hoek.assert(this.constructor === internals.Monitor, 'Monitor must be instantiated using new'); Hoek.assert(plugin, 'plugin required to create monitor'); options = Hoek.applyToDefaultsWithShallow(internals.defaults, options, ['reporters', 'httpAgents', 'httpsAgents']); // Force them to be arrays var args = []; options.httpAgents = args.concat(options.httpAgents || Http.globalAgent);
GitHub: trabian/hoek

186 187 188 189 190 191 192 193 194
name: 'example' }; var options = { server: { port: 8080 } }; var config = Hoek.applyToDefaultsWithShallow(defaults, options, ['server']); // results in { server: { port: 8080 }, name: 'example' } ``` ### deepEqual(b, a, [options])
GitHub: cmoody/service-client

19 20 21 22 23 24 25 26 27 28
const Http = require('http') const Https = require('https') const Hoek = require('hoek') const create = function (protocol, options = {}) { let agentOptions = Hoek.applyToDefaultsWithShallow({}, options.agentOptions || {}, ['secureContext']) if (protocol.indexOf('https') >= 0) { // Pre cache secureContext for handshake so it doesn't create one every connect. if (!agentOptions.secureContext) {
GitHub: muzzley/good-bunyan

35 36 37 38 39 40 41 42 43
// Validates inputs and throws errors validate(events, config); super({ objectMode: true }); this.settings = Hoek.applyToDefaultsWithShallow(defaults, config, ['logger']); this.logger = this.settings.logger; // Alias for consistency this._subscription = Squeeze.subscription(events); }
GitHub: g-div/crudy

27 28 29 30 31 32 33 34 35 36
internals.after = function (server, next) { for (const entity in server.plugins.dogwater) { if (server.plugins.dogwater.hasOwnProperty(entity)) { let current; if (internals[entity]) { current = Hoek.applyToDefaultsWithShallow(internals.defaults, internals[entity], ['actions']); } else { current = internals.defaults; } const path = `${current.config.handler.bedwetter.prefix || ''}/${entity}`;
30 31 32 33 34 35 36 37 38
/** * Create a child DataRetrievalRouter inheriting the current object, applied for a certain data context **/ internals.DataRetrievalRouter.prototype.createChild = function (context) { const options = Hoek.applyToDefaultsWithShallow(this.options, { parent: this, context: context }, ['parent', 'context']);
GitHub: rjrodger/wo

102 103 104 105 106 107 108 109 110 111
internals.sneeze(server, pluginOptions) } internals.handler = function(route, handlerOptions) { const settings = Hoek.applyToDefaultsWithShallow( internals.defaults, handlerOptions, ['agent'] )
GitHub: codedebug/wreck

64 65 66 67 68 69 70 71 72 73
internals.Client.prototype.request = function (method, url, options, callback, _trace) { var self = this; options = Hoek.applyToDefaultsWithShallow(options || {}, this._defaults, internals.shallowOptions); Hoek.assert(options.payload === null || options.payload === undefined || typeof options.payload === 'string' || options.payload instanceof Stream || Buffer.isBuffer(options.payload), 'options.payload must be a string, a Buffer, or a Stream');
+ 3 other calls in file
GitHub: lholmquist/hapi

50 51 52 53 54 55 56 57 58
// Apply settings in order: {connection} <- {handler} <- {realm} <- {route} const handlerDefaults = Handler.defaults(method, handler, connection.server); let base = Hoek.applyToDefaultsWithShallow(connection.settings.routes, handlerDefaults, ['bind']); base = Hoek.applyToDefaultsWithShallow(base, realm.settings, ['bind']); this.settings = Hoek.applyToDefaultsWithShallow(base, route.config || {}, ['bind']); this.settings.handler = handler; this.settings = Schema.apply('routeConfig', this.settings, routeDisplay);
+ 5 other calls in file
GitHub: finnp/hapi

57 58 59 60 61 62 63 64 65 66
// Apply settings in order: {connection} <- {handler} <- {realm} <- {route} const handlerDefaults = Handler.defaults(method, handler, connection.server); let base = Hoek.applyToDefaultsWithShallow(connection.settings.routes, handlerDefaults, ['bind']); base = Hoek.applyToDefaultsWithShallow(base, realm.settings, ['bind']); this.settings = Hoek.applyToDefaultsWithShallow(base, config || {}, ['bind', 'validate.headers', 'validate.payload', 'validate.params', 'validate.query']); this.settings.handler = handler; this.settings = Schema.apply('routeConfig', this.settings, routeDisplay); const socketTimeout = (this.settings.timeout.socket === undefined ? 2 * 60 * 1000 : this.settings.timeout.socket);
+ 11 other calls in file
83 84 85 86 87 88 89 90 91 92
const engines = options.engines; const defaultExtension = options.defaultExtension; // Clone options const defaults = Hoek.applyToDefaultsWithShallow(internals.defaults, options, ['engines', 'context']); delete defaults.engines; delete defaults.defaultExtension; // Prepare manager state
+ 3 other calls in file
GitHub: thebergamo/hapi

28 29 30 31 32 33 34 35 36
Hoek.assert(this instanceof internals.Server, 'Server must be instantiated using new'); options = Schema.apply('server', options || {}); this._settings = Hoek.applyToDefaultsWithShallow(Defaults.server, options, ['connections.routes.bind']); this._settings.connections = Hoek.applyToDefaultsWithShallow(Defaults.connection, this._settings.connections || {}, ['routes.bind']); this._settings.connections.routes.cors = Hoek.applyToDefaults(Defaults.cors, this._settings.connections.routes.cors); this._settings.connections.routes.security = Hoek.applyToDefaults(Defaults.security, this._settings.connections.routes.security);
+ 2 other calls in file
GitHub: remind101/hapi

67 68 69 70 71 72 73 74 75
Hoek.assert(key, 'Bad server constructor arguments: no match for arg type:', type); Hoek.assert(!args[key], 'Bad server constructor arguments: duplicated arg type:', type, '(values: `' + args[key] + '`, `' + argVal + '`)'); args[key] = argVal; } this.settings = Hoek.applyToDefaultsWithShallow(Defaults.server, args.options || {}, ['app', 'plugins', 'views']); Schema.assert('server', this.settings); this.settings.labels = Hoek.unique([].concat(this.settings.labels)); // Convert string to array and removes duplicates
GitHub: remind101/hapi

25 26 27 28 29 30 31 32 33
var engines = options.engines; var defaultExtension = options.defaultExtension; // Clone options var defaults = Hoek.applyToDefaultsWithShallow(Defaults.views, options, ['engines']); if (_override) { Hoek.merge(defaults, _override); // _override cannot contain non-clonable objects }
+ 3 other calls in file
GitHub: boneskull/hapi

45 46 47 48 49 50 51 52 53
// Apply settings in order: {connection} <- {handler} <- {realm} <- {route} var handlerDefaults = Handler.defaults(method, handler, connection.server); var base = Hoek.applyToDefaultsWithShallow(connection.settings.routes, handlerDefaults, ['bind']); base = Hoek.applyToDefaultsWithShallow(base, realm.settings, ['bind']); this.settings = Hoek.applyToDefaultsWithShallow(base, options.config || {}, ['bind']); this.settings.handler = handler; Schema.assert('routeConfig', this.settings, options.path);
+ 2 other calls in file
141 142 143 144 145 146 147 148 149 150
}; internals.configure = function (options) { var settings = Hoek.applyToDefaultsWithShallow(internals.defaults.connection, options || {}, ['app', 'plugins']); Schema.assert('server', settings); settings.labels = Hoek.unique([].concat(settings.labels)); // Convert string to array and removes duplicates
hoek.assert is the most popular function in hoek (1712 examples)