Commit 57a16b23 authored by Emrah Kaya's avatar Emrah Kaya
Browse files

stringsOnlyObject does typechecking before coercion to string

parent 270fdfb6
Loading
Loading
Loading
Loading
+23 −0
Changes for Video.js: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,29 @@ export default class Video extends Component {
    this._root.setNativeProps(nativeProps);
  }
  
  toTypeString(x) {
    switch (typeof x) {
      case "object":
        return x instanceof Date 
          ? x.toISOString() 
          : JSON.stringify(x); // object, null
      case "undefined":
        return "";
      default: // boolean, number, string
        return x.toString();      
    }
  }

  stringsOnlyObject(obj) {
    const strObj = {};

    Object.keys(obj).forEach(x => {
      strObj[x] = this.toTypeString(obj[x]);
    });

    return strObj;
  }

  stringsOnlyObject(obj) {
    const strObj = {};