How to use the reach function from hoek

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

33
34
35
36
37
38
39
40
41
42
for (const [path, operations] of Object.entries(api.paths)) {
    const pathnames = Utils.unsuffix(path, '/').split('/').slice(1).join('.');

    for (const [method, operation] of Object.entries(operations)) {
        const pathsearch = `${pathnames}.${method}`;
        const handler = Hoek.reach(handlers, pathsearch);
        const xoptions = operation['x-hapi-options'] || {};

        if (!handler) {
            continue;
fork icon75
star icon0
watch icon1

44
45
46
47
48
49
50
51
52
  const update = Object.assign({ history }, data)
  this.emitter.emit(eventId, update, historical)
}

loadDatasources () {
  const datasources = reach(this, 'descriptor.datasources', { default: {} })
  const hasDatasources = Object.keys(datasources).length
  this.datasources = hasDatasources ? datasourceLoader.load(datasources) : {}
}
fork icon47
star icon410
watch icon15

+ 7 other calls in file

186
187
188
189
190
191
192
193
194
195
if (all) {
    return waterline.collections;
}

const collections = {};
const models = Hoek.reach(this, `${realmPath}.plugins.dogwater.models`) || [];

for (let i = 0; i < models.length; ++i) {
    collections[models[i]] = waterline.collections[models[i]];
}
fork icon14
star icon102
watch icon9

6
7
8
9
10
11
12
13
14
15
  return request.connection || request.server
}

utils.getRoutesModifiers = function (plugin) {
  // plugin.config fallback for hapi < 8
  return plugin.config || Hoek.reach(plugin, 'realm.modifiers')
}

utils.firstCharToUpperCase = function (string) {
  if (!string || string.length === 0) {
fork icon38
star icon0
watch icon0

+ 3 other calls in file

204
205
206
207
208
209
210
211
212
213
utils.getMetaSwaggerType = function (schema) {
  return utils.getMeta(schema, 'swaggerType')
}

utils.isSupportedSchema = function (schema) {
  return schema != null && Hoek.reach(schema, '_flags.func') !== true && schema.isJoi === true && (utils.isSupportedType(utils.getPrimitiveType(schema)) || utils.getMetaSwaggerType(schema) != null)
}

utils.isSupportedType = function (type) {
  return type != null && _.includes(supportedTypes, type)
fork icon38
star icon0
watch icon51

+ 5 other calls in file

175
176
177
178
179
180
181
182
183
184
}

var routesPluginOptions = routeSettings.plugins['hapi-swaggered'] || {}
Joi.assert(routesPluginOptions, schema.RoutesPluginOptions)
var defaultResponseSchema = Hoek.reach(routeSettings, 'response.schema')
var statusResponseSchema = Hoek.reach(routeSettings, 'response.status')

// Process response
var responses = internals.prepareResponses(definitions, routesPluginOptions, defaultResponseSchema, statusResponseSchema)
operation.responses = responses
fork icon38
star icon0
watch icon2

+ 5 other calls in file

36
37
38
39
40
41
42
43
44

const generate = function (schemaInput, options) {

    const self = this;
    let input = Hoek.reach(options, 'input');
    const config = Hoek.reach(options, 'config');
    const ignoreDefaults  = Hoek.reach(config, 'ignoreDefaults');

    const schemaMapper = function (target, schema) {
fork icon9
star icon0
watch icon3

+ 17 other calls in file

24
25
26
27
28
29
30
31
32
33

  if (typeof mode !== 'object') {
    return mode;
  }

  return Hoek.reach(mode, method, internals.defaultMode);
};


/**
fork icon5
star icon13
watch icon2

43
44
45
46
47
48
49
50
51
52
},
{
  path: `${inputSegment}/unsafe${sinkSegment}`,
  method: methods,
  handler: (request, reply) => {
    const value = Hoek.reach(request, dataPath);

    /* For synchronous sink methods:  */
    if (handle.length == 1) {
      try {
fork icon3
star icon0
watch icon25

626
627
628
629
630
631
632
633
634
635
_fillOrderedErrors(errors, ordereds, state, options) {

    const requiredOrdereds = [];

    for (let i = 0; i < ordereds.length; ++i) {
        const presence = Hoek.reach(ordereds[i], '_flags.presence');
        if (presence === 'required') {
            requiredOrdereds.push(ordereds[i]);
        }
    }
fork icon0
star icon1
watch icon0

15
16
17
18
19
20
21
22
23
24

const settings = Hoek.clone(options);         // options can be reused and modified

const ref = function (value, validationOptions) {

    return Hoek.reach(ref.isContext ? validationOptions.context : value, ref.key, settings);
};

ref.isContext = (key[0] === ((settings && settings.contextPrefix) || '$'));
ref.key = (ref.isContext ? key.slice(1) : key);
fork icon0
star icon1
watch icon0

115
116
117
118
119
120
121
122
123
124
        format = (Hoek.reach(localized, 'key') || Hoek.reach(Language.errors, 'key')) + format;
    }

    return format.replace(/\{\{(\!?)([^}]+)\}\}/g, ($0, isSecure, name) => {

        const value = Hoek.reach(this.context, name);
        const normalized = internals.stringify(value, wrapArrays);
        return (isSecure ? Hoek.escapeHtml(normalized) : normalized);
    });
}
fork icon0
star icon1
watch icon0

+ 3 other calls in file

110
111
112
113
114
115
116
117
118
119
if (skipKey) {
    format = format.slice(2);
}

if (!hasKey && !skipKey) {
    const localizedKey = Hoek.reach(localized, 'key');
    if (typeof localizedKey === 'string') {
        format = localizedKey + format;
    }
    else {
fork icon0
star icon0
watch icon0

+ 4 other calls in file