<commit_before>'use strict';

exports.extend = extendApp;

function extendApp(app) {
    if (app['@annotations']) { return app; }

    // Brand.
    Object.defineProperty(app, '@annotations', {value: true});

    // Modifies the Express `app` by adding the `annotate()` and `findAll()`
    // methods.
    app.annotate = annotate;
    app.findAll  = findAll;

    return app;
}

function annotate(routePath, annotations) {
    /* jshint validthis:true */
    var routes = this.routes;

    // For annotation purposes, routes are treated as conceptual resources at a
    // URL, independent of which HTTP verb they were registered under. This
    // means all of this app's routes which match the specified `routePath` will
    // get the specified `annotations` applied.
    Object.keys(routes).forEach(function (method) {
        routes[method].forEach(function (route) {
            if (route.path === routePath) {
                if (!route.annotations) {
                    // Defines this route's "hidden", non-enumerable
                    // `annotations` property to hold its annotations.
                    Object.defineProperty(route, 'annotations', {value: {}});
                }

                // Merge the specified `annotations` onto this route.
                extend(route.annotations, annotations);
            }
        });
    });
}

function findAll(annotations) {
    /* jshint validthis:true */

    // Support a single array of annotations, or var-args.
    if (!Array.isArray(annotations)) {
        annotations = [].slice.call(arguments);
    }

    var allRoutes = this.routes;

    // Reduce the collection of this app's routes down to those which match
    // _all_ of the specified `annotations`, and return them as an array.<commit_msg>Return the `this`, the app from the `app.annotate()` method<commit_after>'use strict';

exports.extend = extendApp;

function extendApp(app) {
    if (app['@annotations']) { return app; }

    // Brand.
    Object.defineProperty(app, '@annotations', {value: true});

    // Modifies the Express `app` by adding the `annotate()` and `findAll()`
    // methods.
    app.annotate = annotate;
    app.findAll  = findAll;

    return app;
}

function annotate(routePath, annotations) {
    /* jshint validthis:true */
    var routes = this.routes;

    // For annotation purposes, routes are treated as conceptual resources at a
    // URL, independent of which HTTP verb they were registered under. This
    // means all of this app's routes which match the specified `routePath` will
    // get the specified `annotations` applied.
    Object.keys(routes).forEach(function (method) {
        routes[method].forEach(function (route) {
            if (route.path === routePath) {
                if (!route.annotations) {
                    // Defines this route's "hidden", non-enumerable
                    // `annotations` property to hold its annotations.
                    Object.defineProperty(route, 'annotations', {value: {}});
                }

                // Merge the specified `annotations` onto this route.
                extend(route.annotations, annotations);
            }
        });
    });

    return this;
}

function findAll(annotations) {
    /* jshint validthis:true */

    // Support a single array of annotations, or var-args.
    if (!Array.isArray(annotations)) {
        annotations = [].slice.call(arguments);
    }

    var allRoutes = this.routes;

    // Reduce the collection of this app's routes down to those which match
    // _all_ of the specified `annotations`, and return them as an array.
{'fraction_non_alphanumeric': 0.11391352549889135, 'fraction_numerical': 0.0, 'mean_word_length': 2.369747899159664, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5031634', 'n_tokens_mistral': 988, 'n_tokens_neox': 939, 'n_words': 315}