stringsOnlyObject does typechecking before coercion to string

This commit is contained in:
Emrah Kaya 2018-01-13 21:28:24 +01:00
parent 270fdfb657
commit 57a16b23c5

View File

@ -24,6 +24,29 @@ export default class Video extends Component {
this._root.setNativeProps(nativeProps); 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) { stringsOnlyObject(obj) {
const strObj = {}; const strObj = {};