@less-is-more/less-js 1.2.23 → 1.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ret.js +20 -21
- package/test/test-ret.js +1 -0
package/package.json
CHANGED
package/src/ret.js
CHANGED
|
@@ -6,65 +6,64 @@ module.exports = class Ret {
|
|
|
6
6
|
static CODE_SYSTEM = 1004;
|
|
7
7
|
|
|
8
8
|
constructor(success, message, code) {
|
|
9
|
-
this
|
|
9
|
+
this.success = success;
|
|
10
10
|
if (message) {
|
|
11
|
-
this
|
|
11
|
+
this.message = message;
|
|
12
12
|
}
|
|
13
13
|
if (code) {
|
|
14
|
-
this
|
|
14
|
+
this.code = code;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
#instance = {};
|
|
19
18
|
ok() {
|
|
20
|
-
this
|
|
19
|
+
this.success = true;
|
|
21
20
|
return this;
|
|
22
21
|
}
|
|
23
|
-
isOk(){
|
|
24
|
-
return this
|
|
22
|
+
isOk() {
|
|
23
|
+
return this.success;
|
|
25
24
|
}
|
|
26
25
|
fail() {
|
|
27
|
-
this
|
|
26
|
+
this.success = false;
|
|
28
27
|
return this;
|
|
29
28
|
}
|
|
30
|
-
isFail(){
|
|
31
|
-
return !this
|
|
29
|
+
isFail() {
|
|
30
|
+
return !this.success;
|
|
32
31
|
}
|
|
33
32
|
setMessage(message) {
|
|
34
|
-
this
|
|
33
|
+
this.message = message;
|
|
35
34
|
return this;
|
|
36
35
|
}
|
|
37
36
|
getMessage() {
|
|
38
|
-
return this
|
|
37
|
+
return this.message;
|
|
39
38
|
}
|
|
40
39
|
setCode(code) {
|
|
41
|
-
this
|
|
40
|
+
this.code = code;
|
|
42
41
|
return this;
|
|
43
42
|
}
|
|
44
43
|
setData(data) {
|
|
45
|
-
this
|
|
44
|
+
this.data = data;
|
|
46
45
|
return this;
|
|
47
46
|
}
|
|
48
47
|
getData() {
|
|
49
|
-
return this
|
|
48
|
+
return this.data;
|
|
50
49
|
}
|
|
51
50
|
toString() {
|
|
52
|
-
return JSON.stringify(this
|
|
51
|
+
return JSON.stringify(this);
|
|
53
52
|
}
|
|
54
53
|
getJson() {
|
|
55
|
-
return this
|
|
54
|
+
return this;
|
|
56
55
|
}
|
|
57
56
|
toJson() {
|
|
58
|
-
return this
|
|
57
|
+
return this;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
filter(props = []) {
|
|
62
61
|
if (props.length > 0) {
|
|
63
|
-
const data = this
|
|
62
|
+
const data = this.data;
|
|
64
63
|
if (data instanceof Array) {
|
|
65
|
-
this
|
|
64
|
+
this.data = this._filterArray(data, props);
|
|
66
65
|
} else {
|
|
67
|
-
this
|
|
66
|
+
this.data = this._filterObject(data, props);
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
return this;
|