isRegExp property

bool isRegExp

Implementation

bool get isRegExp {
  final JSObject func;
  if (_context.globalObject.hasProperty('_flutter_js_inject_isRegExp')) {
    func = _context.globalObject.getProperty('_flutter_js_inject_isRegExp').object;
  } else {
    func = JSObject.makeFunction(
      _context,
      parameterNames: <String>['v'],
      body: '''
      var t = typeof v;
      if(t === 'object'){
        return v instanceof RegExp;
      }
      return false;
      ''',
    );
    _context.globalObject.setProperty('_flutter_js_inject_isRegExp', func.value);
  }
  final JSValue result = func.callAsFunction(arguments: <JSValue>[this]);
  return result.isBoolean && result.boolean;
}