master
yutent 2022-03-18 19:04:12 +08:00
parent 5400d17989
commit 92f7e3f0a9
1 changed files with 43 additions and 29 deletions

View File

@ -1,38 +1,52 @@
if (!String.prototype.size) { /**
Object.defineProperty(String.prototype, 'size', { * 增强版 String
get() { */
var n = 0 export class SString {
for (let it of this) { #origin = ''
n++ #list = []
}
return n
}
})
Object.defineProperty(String.prototype, 'at16', { constructor(str = '') {
value(n) { this.#origin = str
var tmp = []
for (let it of this) { for (let it of str) {
tmp.push(it) this.#list.push(it)
}
return tmp[n]
} }
}) }
Object.defineProperty(String.prototype, 'split16', {
value(pipe) { get length() {
if (pipe === '') { return this.#list.length
var tmp = [] }
for (let it of this) {
tmp.push(it) at(index = 0) {
} if (this.length > 0) {
return tmp while (index < 0) {
} else { index += this.length
return this.split(pipe) }
return this.#list[index]
}
}
split() {
return this.#list
}
forEach(callback) {
for (let i in this.#list) {
if (callback(this.#list[i], i) === false) {
break
} }
} }
}) return this
}
toString() {
return this.#origin
}
} }
/**
* 特殊版 Enum
*/
export class Enum { export class Enum {
#dict_k = Object.create(null) #dict_k = Object.create(null)
#dict_v = Object.create(null) #dict_v = Object.create(null)