-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBool.js
40 lines (40 loc) · 1014 Bytes
/
Bool.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"use strict";
class Bool {
constructor(...args) {
if (!args.length) {
this.bool = false;
}
else {
switch (typeof args[0]) {
case 'boolean':
this.bool = args[0];
break;
case 'number':
this.bool = Boolean(args[0]);
break;
case 'string':
this.bool = (args[0].toLowerCase().trim() == 'true') || Boolean(Number(args[0]));
break;
}
}
}
static isThis(obj) {
return 'bool' in obj;
}
static parse(...args) {
return new Bool(args[0]);
}
static unparse(value) {
return String(Number(value.bool));
}
static unparseML(value) {
return "<mn>" + String(Number(value.bool)) + "</mn>";
}
static false() {
return new Bool();
}
static true() {
return new Bool(true);
}
}
//export default Bool;