MCPcopy
hub / github.com/loopbackio/loopback-next / generateValidRegex

Function generateValidRegex

packages/cli/lib/utils.js:50–71  ·  view source on GitHub ↗

* Returns a valid variable name regex; * taken from https://gist.github.com/mathiasbynens/6334847

()

Source from the content-addressed store, hash-verified

48 * taken from https://gist.github.com/mathiasbynens/6334847
49 */
50function generateValidRegex() {
51 const get = function (what) {
52 return require('@unicode/unicode-10.0.0/' + what + '/code-points.js');
53 };
54 const idStart = get('Binary_Property/ID_Start');
55 const idContinue = get('Binary_Property/ID_Continue');
56 const compileRegex = _.template(
57 '^(?:<%= identifierStart %>)(?:<%= identifierPart %>)*$',
58 );
59 const identifierStart = regenerate(idStart).add('$', '_');
60 const identifierPart = regenerate(idContinue).add(
61 '$',
62 '_',
63 '\u200C',
64 '\u200D',
65 );
66 const regex = compileRegex({
67 identifierStart: identifierStart.toString(),
68 identifierPart: identifierPart.toString(),
69 });
70 return new RegExp(regex);
71}
72const validRegex = generateValidRegex();
73exports.validRegex = validRegex;
74

Callers 1

utils.jsFile · 0.85

Calls 3

getFunction · 0.70
addMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected