How to use the cloneWithShallow function from hoek

Find comprehensive JavaScript hoek.cloneWithShallow code examples handpicked from public code repositorys.

85
86
87
88
89
90
91
92
93
94
});


internals.implementation = function (server, options) {

    let settings = Hoek.cloneWithShallow(options, 'provider');      // Options can be reused

    // Lookup provider

    if (typeof settings.provider === 'object') {
fork icon210
star icon0
watch icon2

52
53
54
55
56
57
58
59
60
61
});


internals.implementation = function (server, options) {

    var settings = Hoek.cloneWithShallow(options, 'provider');      // Options can be reused

    // Lookup provider

    if (typeof settings.provider === 'object') {
fork icon210
star icon0
watch icon1

+ 3 other calls in file

111
112
113
114
115
116
117
118
119
120
        },
        y: 'y',
        z: new Date()
    };

var copy = Hoek.cloneWithShallow(nestedObj, ['x']);

copy.x.b = 100;

console.log(copy.y);        // results in 'y'
fork icon170
star icon1
watch icon2

183
184
185
186
187
188
189
190
191

if (!/^https?:/i.test(location)) {
    location = Url.resolve(uri.href, location);
}

var redirectOptions = Hoek.cloneWithShallow(options, internals.shallowOptions);

redirectOptions.payload = shadow || options.payload;         // shadow must be ready at this point if set
redirectOptions.redirects = --redirects;
fork icon107
star icon0
watch icon2

151
152
153
154
155
156
157
158
159

internals.Graph.prototype.updateVertex = function (v, info) {

    Hoek.assert(this._vertices[v], 'Vertex [', v, '] does not exist.');

    info = Hoek.cloneWithShallow(info, ['data']) || {};
    info = this._normalizeLabelUpdate(info);

    this._setVertex(v, info);
fork icon3
star icon19
watch icon6

44
45
46
47
48
49
50
51
52
53
Hoek.assert(name.match(internals.methodNameRx), 'Invalid name:', name);
Hoek.assert(!Hoek.reach(this.methods, name, { functions: false }), 'Server method function name already exists:', name);

options = Config.apply('method', options, name);

const settings = Hoek.cloneWithShallow(options, ['bind']);
settings.generateKey = settings.generateKey || internals.generateKey;

const bind = settings.bind || realm.settings.bind || null;
const bound = !bind ? method : (...args) => method.apply(bind, args);
fork icon0
star icon0
watch icon6

27
28
29
30
31
32
33
34
35

const realm = plugin.realm;
if (realm.modifiers.route.vhost ||
    realm.modifiers.route.prefix) {

    route = Hoek.cloneWithShallow(route, ['config']);       // config is left unchanged
    route.path = (realm.modifiers.route.prefix ? realm.modifiers.route.prefix + (route.path !== '/' ? route.path : '') : route.path);
    route.vhost = realm.modifiers.route.vhost || route.vhost;
}
fork icon0
star icon0
watch icon2

70
71
72
73
74
75
76
77
78
79
exports.plugin = {
  name: `${Pkg.name}/db`,
  version: Pkg.version,
  register: async function (server, opts) {
    const options = Joi.attempt(opts, internals.schema.plugin, `Invalid "${this.name}@${this.version}" plugin options`);
    const knexOpts = Hoek.cloneWithShallow(options, [
      'client', 'pool', 'connection', 'wrapIdentifier', 'postProcessResponse', 'migrations'
    ]);

    Object.entries(knexOpts.connection).forEach(([k, v]) => {
fork icon0
star icon0
watch icon0

21
22
23
24
25
26
27
28
29
// Apply plugin environment (before schema validation)

if (env &&
    (env.route.vhost || env.route.prefix)) {

    options = Hoek.cloneWithShallow(options, ['config']);
    options.path = (env.route.prefix ? env.route.prefix + (options.path !== '/' ? options.path : '') : options.path);
    options.vhost = env.route.vhost || options.vhost;
}
fork icon0
star icon0
watch icon2

+ 3 other calls in file

21
22
23
24
25
26
27
28
29
// Apply plugin environment (before schema validation)

if (realm.modifiers.route.vhost ||
    realm.modifiers.route.prefix) {

    options = Hoek.cloneWithShallow(options, ['config']);       // config is left unchanged
    options.path = (realm.modifiers.route.prefix ? realm.modifiers.route.prefix + (options.path !== '/' ? options.path : '') : options.path);
    options.vhost = realm.modifiers.route.vhost || options.vhost;
}
fork icon0
star icon0
watch icon2

47
48
49
50
51
52
53
54
55
56
Hoek.assert(!Hoek.reach(this.methods, name, { functions: false }), 'Server method function name already exists');

options = options || {};
Schema.assert('method', options, name);

var settings = Hoek.cloneWithShallow(options, ['bind']);
settings.generateKey = settings.generateKey || internals.generateKey;
var bind = settings.bind || env.bind || null;

// Normalize methods
fork icon0
star icon0
watch icon1