UNPKG

pretty-var-export

Version:

Export any value to valid and equivalent JavaScript code

17 lines (14 loc) 383 B
import colors from '../../colors/colors'; const RegExpHandler = { test: (value: unknown) => value instanceof RegExp, format: (regex: RegExp) => { const [, expression, flags] = String(regex).match(/^\/(.+?)\/([a-z]*)$/)!; return ( colors.symbol('/') + colors.regexp(expression) + colors.symbol('/') + colors.string(flags) ); }, }; export default RegExpHandler;