Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(copy.x.b); // results in 100
// merge(target, source, isNullOverride, isMergeArrays)
let target = { a: 1, b: 2 };
let source = { a: 0, c: 5 };
let source2 = { a: null, c: 5 };
Hoek.merge(target, source); // results in {a: 0, b: 2, c: 5}
Hoek.merge(target, source2); // results in {a: null, b: 2, c: 5}
Hoek.merge(target, source2, false); // results in {a: 1, b: 2, c: 5}
let targetArray = [1, 2, 3];
let sourceArray = [4, 5];
Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5]
Hoek.merge(targetArray, sourceArray, true, false); // results in [4, 5]
// applyToDefaults(defaults, options, isNullOverride)
let defaults = { host: "localhost", port: 8000 };
let options = { port: 8080 };
let config = Hoek.applyToDefaults(defaults, options); // results in { host: "localhost", port: 8080 }
defaults = { host: "localhost", port: 8000 };
let options1 = { host: null, port: 8080 };
config = Hoek.applyToDefaults(defaults, options1, true); // results in { host: null, port: 8080 }
// applyToDefaultsWithShallow(defaults, options, keys)
server.register(Bell, function (err) {
expect(err).to.not.exist();
var custom = Bell.providers.bitbucket();
Hoek.merge(custom, provider);
Mock.override('https://bitbucket.org/api/1.0/user', {
// source: https://confluence.atlassian.com/display/BITBUCKET/user+Endpoint
repositories: [{}],
user: {
first_name: 'Steve',
last_name: '',
username: 'steve_stevens'
}
});
server.auth.strategy('custom', 'bell', {
password: 'password',
isSecure: false,
clientId: 'twitter',
clientSecret: 'secret',
}
if (get) {
query[key] = data[key];
return;
}
payload[key] = data[key];
});
var uri = url.parse(newPath, true);
var newQuery = {};
Hoek.merge(newQuery, socketRequest._query);
Hoek.merge(newQuery, query);
Hoek.merge(newQuery, uri.query);
uri.query = newQuery;
delete uri.search;
// Auto map "Authorization" attribute to Authorization header
// TODO: Make this configurable?
var headerNames = ['Authorization'];
headerNames.some(function(value) {
return [value, value.toLowerCase()].some(function(header) {
if (headers[header]) {
return true;
}
if (payload[header]) {
headers[header] = payload[header];
return true;
}
ES.CREATE(timer, function(record) {
Hoek.merge(record, timer); // http://git.io/Amv6
// delete the useless _prefixed fields returned by ES
record.id = record._id;
delete record._index;
delete record._type;
delete record._version;
delete record.person;
delete record._id
reply(record);
})
}
_sendMessages(callback) {
let lineData = [];
this._data.forEach((event) => {
const lines = LineProtocol.format(event, this.config, this.schemas);
lineData = lineData.concat(lines);
});
const wreckOptions = {
payload: lineData.join('\n')
};
Hoek.merge(wreckOptions, this._settings.wreck, false);
// Prevent this from user tampering
wreckOptions.headers['content-type'] = 'text/plain';
Wreck.request('post', this._endpoint, wreckOptions, callback);
}
}
server.register(Bell, function (err) {
expect(err).to.not.exist();
var custom = Bell.providers.google();
Hoek.merge(custom, provider);
var profile = {
id: '1234567890',
displayName: 'steve smith',
name: {
givenName: 'steve',
familyName: 'smith'
},
emails: [
{
'type': 'account',
'value': 'steve@example.com'
}
]
};
server.register(Bell, function (err) {
expect(err).to.not.exist();
var custom = Bell.providers.yahoo();
Hoek.merge(custom, provider);
var profile = {
profile: {
guid: '1234567890',
givenName: 'steve',
familyName: 'smith'
}
};
Mock.override('https://social.yahooapis.com/v1/user/', profile);
server.auth.strategy('custom', 'bell', {
password: 'password',
isSecure: false,
clientId: 'yahoo',
clientSecret: 'secret',
Client.prototype.getHeaders = function(_group, _path, _query, _headers) {
return yarp({
url: this.buildUrl(_group, _path, _query),
headers: Hoek.merge(this.authHeaders, _headers)
});
};
properties.forEach(function(messages) {
Hoek.merge(merged_properties, messages);
});
resolve({content: merged_properties, locale: locale});
exports.register = function (plugin, options, next) {
var settings = Hoek.clone(internals.defaults)
Hoek.merge(settings, options)
plugin.views({
engines: settings.engines || {
hbs: {
module: Handlebars
}
},
path: settings.basePath
})
plugin.route({
method: 'GET',
path: settings.endpoint + '/companies/{id}',
config: handlers.company
})