mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 16:44:49 +08:00
Circular dependecy break
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
import Utility from "../Utility"
|
||||
import Integer from "./primitive/Integer"
|
||||
|
||||
export default class TypeInitialization {
|
||||
|
||||
static sanitize(value) {
|
||||
if (!(value instanceof Object)) {
|
||||
return value // Is already primitive
|
||||
}
|
||||
if (value instanceof Boolean || value instanceof Integer || value instanceof Number) {
|
||||
return value.valueOf()
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return value.toString()
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {typeof Object} type
|
||||
@@ -10,7 +23,7 @@ export default class TypeInitialization {
|
||||
*/
|
||||
constructor(type, showDefault = true, value = undefined) {
|
||||
if (value === undefined) {
|
||||
value = Utility.sanitize(new type())
|
||||
value = TypeInitialization.sanitize(new type())
|
||||
}
|
||||
this.value = value
|
||||
this.showDefault = showDefault
|
||||
|
||||
Reference in New Issue
Block a user