mirror of
https://github.com/thangisme/notes.git
synced 2025-09-24 01:44:05 -04:00
Initial commit
This commit is contained in:
31
node_modules/clone-regexp/index.js
generated
vendored
Normal file
31
node_modules/clone-regexp/index.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict';
|
||||
var isRegexp = require('is-regexp');
|
||||
var isSupportedRegexpFlag = require('is-supported-regexp-flag');
|
||||
|
||||
var flagMap = {
|
||||
global: 'g',
|
||||
ignoreCase: 'i',
|
||||
multiline: 'm'
|
||||
};
|
||||
|
||||
if (isSupportedRegexpFlag('y')) {
|
||||
flagMap.sticky = 'y';
|
||||
}
|
||||
|
||||
if (isSupportedRegexpFlag('u')) {
|
||||
flagMap.unicode = 'u';
|
||||
}
|
||||
|
||||
module.exports = function (re, opts) {
|
||||
if (!isRegexp(re)) {
|
||||
throw new TypeError('Expected a RegExp instance');
|
||||
}
|
||||
|
||||
opts = opts || {};
|
||||
|
||||
var flags = Object.keys(flagMap).map(function (el) {
|
||||
return (typeof opts[el] === 'boolean' ? opts[el] : re[el]) ? flagMap[el] : '';
|
||||
}).join('');
|
||||
|
||||
return new RegExp(opts.source || re.source, flags);
|
||||
};
|
Reference in New Issue
Block a user