1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jre/java/lang/String.js
Quinton Ashley fcf49e5a8d 1.0.1
2021-09-23 01:41:44 -05:00

25 lines
574 B
JavaScript
Executable File

jre.imports['java.lang.String'].load = () => {};
// String is special, I just extended js String prototype
String.prototype.hashCode = () => {
let h = this._hashCode;
if (!h && this.length > 0) {
const val = this;
for (let i = 0; i < this.length; i++) {
h = 31 * h + this.charCodeAt(i);
}
this._hashCode = h;
}
return h;
}
String.prototype.isEmpty = () => {
return this.length == 0
}
String.prototype.contains = (substr) => {
return this.includes(substr);
}
// static methods
String.valueOf = (c) => {
return c.toString();
}
jre.java.lang.String = String;