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()); }
257
758
0
+ 21 other calls in file
GitHub: gxlmyacc/react-vue-like
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');
3
6
1
+ 8 other calls in file
GitHub: icai/vue-to-react
158 159 160 161 162 163 164 165 166 167
t.memberExpression( t.identifier(value), t.identifier('replace') ), [ t.regExpLiteral('<[^>]+>', 'g'), t.stringLiteral('') ] ) )
65
1
1
+ 3 other calls in file
GitHub: overlookmotel/livepack
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}] );
0
23
2
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) ] ]);
4
0
1
@babel/types.identifier is the most popular function in @babel/types (20936 examples)