stringsOnlyObject does typechecking before coercion to string
This commit is contained in:
parent
270fdfb657
commit
57a16b23c5
23
Video.js
23
Video.js
@ -23,6 +23,29 @@ export default class Video extends Component {
|
||||
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) {
|
||||
const strObj = {};
|
||||
|
Loading…
Reference in New Issue
Block a user