wrap function Null safety

dynamic wrap(
  1. dynamic value,
  2. WebJsScript script
)

Implementation

wrap(dynamic value, WebJsScript script) {
  if (value is js.JsObject) {
    if (value[script.privateKey] != null) {
      return WebJsValue(script, value,
          type: JsValueType.DartInstance,
          dartObject: value[script.privateKey]
      );
    } else if (value[script.classPrivateKey] != null) {
      return WebJsValue(script, value,
          type: JsValueType.DartClass,
          dartObject: value[script.classPrivateKey].type
      );
    }
    return WebJsValue(script, value);
  } else {
    return value;
  }
}