qtail-js
Version:
一个轻量级的用于生成带小尾巴的 qq 昵称的 JavaScript 库
31 lines (30 loc) • 936 B
JavaScript
import retail from './libs/retail.js';
class qtail {
constructor(nick, tail, compatible) {
this.compatible = false;
this.upd = this.update;
this.gen = this.generate;
if (!nick || !tail)
throw new Error(':( prams cannot be empty.');
this.nick = nick;
this.tail = tail;
this.compatible = compatible || false;
}
update(nick, tail, compatible) {
if (!nick || !tail)
throw new Error(':( prams cannot be empty.');
this.nick = nick;
this.tail = tail;
this.compatible = compatible || false;
}
generate() {
const chart = this.compatible ? qtail.UnicodeCtrlChars[1] : qtail.UnicodeCtrlChars[0];
return `${this.nick}${chart[1]}${retail(this.tail)}${chart[0]}`;
}
}
qtail.version = [2, 0, 0];
qtail.UnicodeCtrlChars = [
['\u202a', '\u202b'],
['\u2066', '\u2067']
];
export default qtail;