transformToBrowserJSObject static method

dynamic transformToBrowserJSObject(
  1. dynamic obj
)

Implementation

static dynamic transformToBrowserJSObject(dynamic obj) {
  if (obj is Map) {
    return obj.map(
        (key, value) => MapEntry(key, transformToBrowserJSObject(value)));
  } else if (obj is List) {
    return obj.map((e) => transformToBrowserJSObject(e)).toList();
  } else {
    if (obj is Function) {
      if (Context.functionMap[obj.hashCode.toString()] == null) {
        Context.createFunctionArgN(obj);
      }
      return {
        "clazz": "function",
        "ref": "func:" + obj.hashCode.toString(),
      };
    }
    if (obj is JSObject) {
      return obj.objectRef;
    }
    return obj;
  }
}