Posts / mergeRegExps#8

Merge RegExps

By Toby Hinloopen at 2021-03-18 11:59

Installation

# npm
npm i https://boomm.io/p/8-merge-reg-exps.tar.gz
# yarn
yarn add https://boomm.io/p/8-merge-reg-exps.tar.gz

Usage

const mergeRegExps = require("8-merge-reg-exps");

Source

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeRegExps = void 0;
const { uniq } = require("lodash");
function mergeRegExps(regExps) {
    return new RegExp(regExps.map((_) => _.source).join("|"), uniq(regExps.map((_) => _.flags)).join(""));
}
exports.mergeRegExps = mergeRegExps;