How to use the applyToDefaults function from hoek
Find comprehensive JavaScript hoek.applyToDefaults code examples handpicked from public code repositorys.
GitHub: AlexZeitler/hapijs.com
97 98 99 100 101 102 103 104 105 106
exports.methods.push({ name: 'github.styleGuide', method: function () { const options = Hoek.applyToDefaults(internals.requestOptions, { headers: { accept: 'application/vnd.github.3.html' } }); return Utils.download('https://api.github.com/repos/hapijs/assets/contents/Style.md', options);
276
0
2
+ 3 other calls in file
GitHub: bloglovin/hoek
114 115 116 117 118 119 120 121 122
```javascript var defaults = {host: "localhost", port: 8000}; var options = {port: 8080}; var config = Hoek.applyToDefaults(defaults, options); // results in {host: "localhost", port: 8080}; ``` ### unique(array, key)
170
1
33
+ 3 other calls in file
GitHub: travi/bell
159 160 161 162 163 164 165 166 167
else { credentials.refreshToken = 'refresh_token'; credentials.expiresIn = 3600; } return h.authenticated({ credentials: Hoek.applyToDefaults(credentials, result) }); } }; };
210
0
2
168 169 170 171 172 173 174 175 176
name: 'example' }; var options = { server: { port: 8080 } }; var config = Hoek.applyToDefaults(defaults, options); // results in { server: { port: 8080 }, name: 'example' } ``` ### unique(array, key)
170
0
14
+ 11 other calls in file
GitHub: trabian/hoek
166 167 168 169 170 171 172 173 174 175
```javascript var defaults = { host: "localhost", port: 8000 }; var options = { host: null, port: 8080 }; var config = Hoek.applyToDefaults(defaults, options, true); // results in { host: null, port: 8080 } ``` ### applyToDefaultsWithShallow(defaults, options, keys) keys is an array of key names to shallow copy
170
0
6
+ 5 other calls in file
GitHub: walkthunder/frame
30 31 32 33 34 35 36 37 38
static async sendEmail(options, template, context) { const content = await this.renderTemplate(template, context); options = Hoek.applyToDefaults(options, { from: Config.get('/system/fromAddress'), markdown: content });
161
0
2
52 53 54 55 56 57 58 59 60 61
}, xoptions); options.handler = handler; if (Utils.canCarry(method)) { options.payload = options.payload ? Hoek.applyToDefaults({ allow: operation.consumes || api.consumes }, options.payload) : { allow: operation.consumes || api.consumes }; } if (Array.isArray(handler)) { options.pre = [];
75
0
1
16 17 18 19 20 21 22 23 24
Hoek.assert( this.constructor === Connection, 'Redis cache client must be instantiated using new' ) this.settings = Hoek.applyToDefaults(internals.defaults, options) this.client = null return this }
62
49
28
38 39 40 41 42 43 44 45 46
```javascript const Hoek = require('hoek'); const default = {url : "www.github.com", port : "8000", debug : true}; const config = Hoek.applyToDefaults(default, {port : "3000", admin : true}); // In this case, config would be { url: 'www.github.com', port: '3000', debug: true, admin: true } ```
4
32
5
GitHub: g-div/crudy
16 17 18 19 20 21 22 23 24 25
} } }; exports.register = function (server, options, next) { internals = Hoek.applyToDefaults(internals, options); server.dependency(['bedwetter', 'dogwater'], internals.after); next(); };
4
23
3
GitHub: KrashStudio/bell
175 176 177 178 179 180 181 182 183 184
else { credentials.refreshToken = 'refresh_token'; credentials.expiresIn = 3600; } return reply.continue({ credentials: Hoek.applyToDefaults(credentials, result) }); }); } }; };
210
0
2
GitHub: maniacs-js/levee
11 12 13 14 15 16 17 18 19 20
Events.EventEmitter.call(this); Assert.equal(typeof impl, 'object', 'The command implementation must be an object.'); Assert.equal(typeof impl.execute, 'function', 'The command implementation must have a method named `execute`.'); this.settings = Hoek.applyToDefaults(Defaults.Breaker, options || {}); this.fallback = undefined; this._impl = impl; this._state = Breaker.State.CLOSE;
33
0
3
GitHub: stongo/nsquishy
195 196 197 198 199 200 201 202 203 204
if (err) { throw err; } self.settings = Utils.applyToDefaults(internals.defaults, options); }); } Nsquishy.prototype.squish = function (next) {
0
2
2
52 53 54 55 56 57 58 59 60 61
Joi.assert(handles, schemas.DataRetrievalRouter_register_handles); Joi.assert(retriever, schemas.DataRetrievalRouter_register_retriever); options = options || {}; Joi.assert(options, schemas.DataRetrievalRouter_register_options); options = Hoek.applyToDefaults(defaults.DataRetrievalRouter_register_options, options); if (handles instanceof Array) { handles.forEach((source) => this._register(source, retriever, options)); }
4
0
1
GitHub: rjrodger/wo
90 91 92 93 94 95 96 97 98 99
sneeze.join({ isbase: sneeze_opts.isbase }) } exports.register = function(server, pluginOptions) { internals.defaults = Hoek.applyToDefaults(internals.defaults, pluginOptions) server.decorate('handler', 'wo', internals.handler) server.decorate('toolkit', 'wo', function(options) {
2
11
4
GitHub: eladkishon/vulnr
22 23 24 25 26 27 28 29 30 31
const ddos = function (params) { if (!params) params = {}; params = Hoek.applyToDefaults(defaultParams, params); if ((params.burst !== undefined) && (params.limit === undefined)) { params.limit = params.burst * 4; }
1
0
0
96 97 98 99 100 101 102 103 104 105
utils.getCurrentSettings = function (settings, serverSettings) { if (serverSettings == null) { return settings } else { var currentSettings = Hoek.applyToDefaults(settings, serverSettings) currentSettings.tags = _.union(utils.getTags(settings), utils.getTags(serverSettings)) return currentSettings } }
38
0
0
98 99 100 101 102 103 104 105 106 107
utils.getCurrentSettings = function (settings, serverSettings) { if (serverSettings == null) { return settings } else { const currentSettings = Hoek.applyToDefaults(settings, serverSettings) currentSettings.tags = _.union(utils.getTags(settings), utils.getTags(serverSettings)) return currentSettings } }
38
0
51
274 275 276 277 278 279 280 281 282 283
this._type = extension.name; if (extension.language) { this._settings = this._settings || { language: {} }; this._settings.language = Hoek.applyToDefaults(this._settings.language, { [extension.name]: extension.language }); } }
0
1
0
GitHub: Pacharoth/node-smis
41 42 43 44 45 46 47 48 49 50 51 52 53
internals.stringify = function (object, options) { internals.seen = []; internals.path = []; internals.settings = Hoek.applyToDefaults(internals.defaults, options || {}); return internals.travel(object, ''); };
0
0
1
+ 83 other calls in file
hoek.assert is the most popular function in hoek (1712 examples)