Files
ueblueprint/js/entity/primitive/Integer.js
barsdeveloper 418630255e Various fixes
2021-10-27 19:27:19 +02:00

26 lines
609 B
JavaScript
Executable File

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()
}
}