mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-28 11:44:44 +08:00
Entities cleanup, Primitive concept introduced
This commit is contained in:
25
js/entity/primitive/Integer.js
Normal file
25
js/entity/primitive/Integer.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Primitive from "./Primitive"
|
||||
|
||||
export default class Integer extends Primitive {
|
||||
|
||||
constructor(value) {
|
||||
super()
|
||||
// Using constructor equality and not instanceof in order to consider both primitives and objects
|
||||
if (value?.constructor === String) {
|
||||
value = Number(value)
|
||||
}
|
||||
if (value?.constructor === Number) {
|
||||
value = Math.round(value)
|
||||
}
|
||||
/** @type {number} */
|
||||
this.value = value
|
||||
}
|
||||
|
||||
valueOf() {
|
||||
this.value
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value.toString()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user