How to use the regExpLiteral function from @babel/types
Find comprehensive JavaScript @babel/types.regExpLiteral code examples handpicked from public code repositorys.
GitHub: qooxdoo/qooxdoo
128 129 130 131 132 133 134 135 136 137
} if (typeof value == "string") { return types.stringLiteral(value); } if (qx.lang.Type.isRegExp(value)) { return types.regExpLiteral(value.toString()); } if (qx.lang.Type.isDate(value)) { return types.stringLiteral(value.toString()); }
+ 21 other calls in file
GitHub: gxlmyacc/react-vue-like
![gxlmyacc profile picture](/gxlmyacc.png?size=40)
84 85 86 87 88 89 90 91 92 93
case 'string': return t.stringLiteral(v); case 'boolean': return t.booleanLiteral(v); case 'number': return t.numericLiteral(v); case 'object': if (v === null) return t.nullLiteral(); if (v instanceof RegExp) return t.regExpLiteral(v.source, v.flags); if (v instanceof Date) return template('new Date(TIME)')({ TIME: t.numericLiteral(v.getTime()) }); if (v instanceof Function) return template(v.toString())(); return obj2Expression(v, parent); default: return t.identifier('undefined');
+ 8 other calls in file
GitHub: icai/vue-to-react
![icai profile picture](/icai.png?size=40)
158 159 160 161 162 163 164 165 166 167
t.memberExpression( t.identifier(value), t.identifier('replace') ), [ t.regExpLiteral('<[^>]+>', 'g'), t.stringLiteral('') ] ) )
+ 3 other calls in file
GitHub: overlookmotel/livepack
![overlookmotel profile picture](/overlookmotel.png?size=40)
19 20 21 22 23 24 25 26 27 28
URLToString = URL.prototype.toString, URLSearchParamsToString = URLSearchParams.prototype.toString; module.exports = { serializeRegex(regex, record) { const node = t.regExpLiteral(regexSourceGetter.call(regex), regexFlagsGetter.call(regex)); return this.wrapWithProperties( regex, record, node, RegExp.prototype, [{name: 'lastIndex', value: 0, writable: true, enumerable: false, configurable: false}] );
8 9 10 11 12 13 14 15 16 17
const buildLiteral = R.cond([ [ R.is(Number), types.numericLiteral ], [ R.is(String), types.stringLiteral ], [ R.is(Boolean), types.booleanLiteral ], [ R.is(RegExp), (re) => types.regExpLiteral(re.source, re.flags) ], [ R.is(Array), buildArrayLiteral ], [ R.is(Object), buildObjectLiteral ], [ R.T, nullary(types.nullLiteral) ] ]);
@babel/types.identifier is the most popular function in @babel/types (20936 examples)