How to use the @hapi/hoek.flatten function in @hapi/hoek

To help you get started, we’ve selected a few @hapi/hoek examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / lab / lib / reporters / html.js View on Github external
}
            }

        });

        // Return original file descriptors (that will be flatten next) and generated file as well
        return Object.keys(descriptors).map((key) => descriptors[key]).concat([file]);
    });

    for (let i = 0; i < context.coverage.cov.files.length; ++i) {
        // Need to await for SourceMap.SourceMapConsumer
        const file = await context.coverage.cov.files[i];
        context.coverage.cov.files[i] = file;
    }

    context.coverage.cov.files = Hoek.flatten(context.coverage.cov.files);

    context.coverage.cov.files.forEach((file) => {

        file.segments = file.filename.split('/');
        file.basename = file.segments.pop();
        if (file.percent >= 0) {
            file.percent = (file.percent % 1 === 0) ? file.percent.toFixed() : file.percent.toFixed(2);
            file.percentClass = file.percent > 75 ? 'high' : (file.percent > 50 ? 'medium' : (file.percent > 25 ? 'low' : 'terrible'));
        }
        else {
            file.percentClass = 'hide';
        }

        if (file.segments.length) {
            file.dirname = file.segments.join('/') + '/';
        }
github hapijs / podium / lib / index.js View on Github external
internals.Podium.prototype.registerEvent = function (events, options = {}) {

    events = Hoek.flatten([].concat(events));
    events.forEach((event) => {

        if (!event) {
            return;
        }

        if (event instanceof internals.Podium) {
            return this.registerPodium(event);
        }

        if (typeof event === 'string') {
            event = { name: event };
        }

        if (options.validate !== false) {                                                       // Defaults to true
            event = Joi.attempt(event, internals.schema.event, 'Invalid event options');
github hapijs / lab / lib / runner.js View on Github external
const settings = Object.assign({}, internals.defaults, options);

    scripts = [].concat(scripts);

    if (settings.shuffle) {
        internals.shuffle(scripts, settings.seed);
    }

    const experiments = scripts.map((script) => {

        script._executed = true;
        return script._root;
    });

    const onlyNodes = Hoek.flatten(scripts.map((script) => script._onlyNodes));
    if (onlyNodes.length) {
        onlyNodes.forEach((onlyNode) => {

            internals.markParentsAsOnly(onlyNode.experiment);
        });

        onlyNodes.forEach((onlyNode) => {

            internals.skipAllButOnly(scripts, onlyNode);
        });
    }

    reporter = reporter || { test: function () { }, start: function () { } };

    if (settings.environment) {
        process.env.NODE_ENV = settings.environment;