1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00
java2js/jdk/java/lang/String.js

25 lines
585 B
JavaScript
Raw Normal View History

2021-09-24 00:36:29 -05:00
jdk.imports['java.lang.String'].load = async () => {};
2021-09-23 01:41:44 -05:00
// 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;
2021-09-23 23:26:42 -05:00
};
2021-09-23 01:41:44 -05:00
String.prototype.isEmpty = () => {
2021-09-23 23:26:42 -05:00
return this.length == 0;
};
2021-09-23 01:41:44 -05:00
String.prototype.contains = (substr) => {
return this.includes(substr);
2021-09-23 23:26:42 -05:00
};
2021-09-23 01:41:44 -05:00
// static methods
String.valueOf = (c) => {
return c.toString();
2021-09-23 23:26:42 -05:00
};
jdk.java.lang.String = String;