"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../Class/Functional");
const _ids_1 = require("../../../_ids");
class Match extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['str', 'regex'],
            o: ['results', 'meta'],
        }, {}, system, _ids_1.ID_MATCH);
    }
    f({ str, regex }, done) {
        const results = str.match(new RegExp(regex));
        if (!results) {
            done({
                results: [],
                meta: {
                    index: -1,
                    groups: {},
                    input: str,
                },
            });
            return;
        }
        const { index, groups = {}, input } = results;
        const meta = {
            index,
            groups,
            input,
        };
        done({ results, meta });
    }
}
exports.default = Match;
//# sourceMappingURL=index.js.map