ranges-regex
Version:
Integrate regex operations into Ranges workflow
11 lines (9 loc) • 1.34 kB
JavaScript
/**
* @name ranges-regex
* @fileoverview Integrate regex operations into Ranges workflow
* @version 6.0.20
* @author Roy Revelt, Codsen Ltd
* @license MIT
* {@link https://codsen.com/os/ranges-regex/}
*/
import{rMerge as l}from"ranges-merge";import{isRegExp as p}from"lodash-es";var i="6.0.20";var c=i;function m(e,r,t){if(e===void 0)throw new TypeError("ranges-regex: [THROW_ID_01] The first input's argument must be a regex object! Currently it is missing!");if(!p(e))throw new TypeError(`ranges-regex: [THROW_ID_02] The first input's argument must be a regex object! Currently its type is: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(typeof r!="string")throw new TypeError(`ranges-regex: [THROW_ID_03] The second input's argument must be a string! Currently its type is: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(t&&typeof t!="string")throw new TypeError(`ranges-regex: [THROW_ID_04] The third input's argument must be a string or null! Currently its type is: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(!r.length)return null;let n,s=[];if(t===null||typeof t=="string"&&t.length)for(;(n=e.exec(r))!==null;)s.push([e.lastIndex-n[0].length,e.lastIndex,t]);else for(;(n=e.exec(r))!==null;)s.push([e.lastIndex-n[0].length,e.lastIndex]);return s.length?l(s):null}export{m as rRegex,c as version};