@babel/types
Version:
Babel Types is a Lodash-esque utility library for AST nodes
9 lines (7 loc) • 319 B
JavaScript
const toLowerCase = Function.call.bind("".toLowerCase);
export default function formatBuilderName(type) {
// FunctionExpression -> functionExpression
// JSXIdentifier -> jsxIdentifier
// V8IntrinsicIdentifier -> v8IntrinsicIdentifier
return type.replace(/^([A-Z](?=[a-z0-9])|[A-Z]+(?=[A-Z]))/, toLowerCase);
}