@scx-js/scx-data 0.1.6 → 0.1.8

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.
@@ -1,10 +1,10 @@
1
1
  class FieldPolicy {
2
2
 
3
- included(...fieldNames) {
3
+ include(...fieldNames) {
4
4
  return this;
5
5
  }
6
6
 
7
- excluded(...fieldNames) {
7
+ exclude(...fieldNames) {
8
8
  return this;
9
9
  }
10
10
 
@@ -17,20 +17,35 @@ class FieldPolicy {
17
17
  clearFieldNames() {
18
18
  }
19
19
 
20
- ignoreNullValue(ignoreNullValue) {
20
+ ignoreNull(ignoreNullValue) {
21
21
  return this;
22
22
  }
23
23
 
24
- ignoreNullValue_() {
24
+ ignoreNull_() {
25
25
  }
26
26
 
27
- fieldExpression(fieldName, expression) {
27
+ ignoreNull__(fieldName, ignoreNullValue) {
28
28
  }
29
29
 
30
- fieldExpressions() {
30
+ removeIgnoreNull(fieldName) {
31
31
  }
32
32
 
33
- clearFieldExpressions() {
33
+ ignoreNulls() {
34
+ }
35
+
36
+ clearIgnoreNulls() {
37
+ }
38
+
39
+ expression(fieldName, expression) {
40
+ }
41
+
42
+ expressions() {
43
+ }
44
+
45
+ removeExpression(fieldName) {
46
+ }
47
+
48
+ clearExpressions() {
34
49
  }
35
50
 
36
51
  }
@@ -1,11 +1,11 @@
1
1
  import {FieldPolicyImpl} from "./FieldPolicyImpl.js";
2
2
  import {EXCLUDED, INCLUDED} from "./FilterMode.js";
3
3
 
4
- function includedAll() {
4
+ function includeAll() {
5
5
  return new FieldPolicyImpl(EXCLUDED);
6
6
  }
7
7
 
8
- function excludedAll() {
8
+ function excludeAll() {
9
9
  return new FieldPolicyImpl(INCLUDED);
10
10
  }
11
11
 
@@ -14,8 +14,8 @@ function excludedAll() {
14
14
  * @param fieldNames
15
15
  * @return {FieldPolicy}
16
16
  */
17
- function included(...fieldNames) {
18
- return excludedAll().included(...fieldNames);
17
+ function include(...fieldNames) {
18
+ return excludeAll().include(...fieldNames);
19
19
  }
20
20
 
21
21
  /**
@@ -23,23 +23,28 @@ function included(...fieldNames) {
23
23
  * @param fieldNames
24
24
  * @return {FieldPolicy}
25
25
  */
26
- function excluded(...fieldNames) {
27
- return includedAll().excluded(...fieldNames);
26
+ function exclude(...fieldNames) {
27
+ return includeAll().exclude(...fieldNames);
28
28
  }
29
29
 
30
- function ignoreNullValue(ignoreNullValue) {
31
- return includedAll().ignoreNullValue(ignoreNullValue);
30
+ function ignoreNull(ignoreNull) {
31
+ return includeAll().ignoreNull(ignoreNull);
32
32
  }
33
33
 
34
- function fieldExpression(fieldName, expression) {
35
- return includedAll().fieldExpression(fieldName, expression);
34
+ function ignoreNull__(fieldName, ignoreNull) {
35
+ return includeAll().ignoreNull__(fieldName, ignoreNull);
36
+ }
37
+
38
+ function expression(fieldName, expression) {
39
+ return includeAll().expression(fieldName, expression);
36
40
  }
37
41
 
38
42
  export {
39
- includedAll,
40
- excludedAll,
41
- included,
42
- excluded,
43
- ignoreNullValue,
44
- fieldExpression,
43
+ includeAll,
44
+ excludeAll,
45
+ include,
46
+ exclude,
47
+ ignoreNull,
48
+ ignoreNull__,
49
+ expression,
45
50
  };
@@ -5,18 +5,20 @@ class FieldPolicyImpl extends FieldPolicy {
5
5
 
6
6
  #filterMode;
7
7
  #fieldNames;
8
- #fieldExpressions;
9
- #ignoreNullValue;
8
+ #expressions;
9
+ #ignoreNulls;
10
+ #ignoreNull;
10
11
 
11
12
  constructor(filterMode) {
12
13
  super();
13
14
  this.#filterMode = filterMode;
14
15
  this.#fieldNames = new Set();
15
- this.#fieldExpressions = new Map();
16
- this.#ignoreNullValue = true;
16
+ this.#expressions = new Map();
17
+ this.#ignoreNulls = new Map();
18
+ this.#ignoreNull = true;
17
19
  }
18
20
 
19
- included(...fieldNames) {
21
+ include(...fieldNames) {
20
22
  if (this.#filterMode === INCLUDED) {
21
23
  this.addFieldNames(...fieldNames);
22
24
  } else if (this.#filterMode === EXCLUDED) {
@@ -25,7 +27,7 @@ class FieldPolicyImpl extends FieldPolicy {
25
27
  return this;
26
28
  }
27
29
 
28
- excluded(...fieldNames) {
30
+ exclude(...fieldNames) {
29
31
  if (this.#filterMode === EXCLUDED) {
30
32
  this.addFieldNames(...fieldNames);
31
33
  } else if (this.#filterMode === INCLUDED) {
@@ -47,26 +49,50 @@ class FieldPolicyImpl extends FieldPolicy {
47
49
  return this;
48
50
  }
49
51
 
50
- ignoreNullValue(ignoreNullValue) {
51
- this.#ignoreNullValue = ignoreNullValue;
52
+ ignoreNull(ignoreNullValue) {
53
+ this.#ignoreNull = ignoreNullValue;
52
54
  return this;
53
55
  }
54
56
 
55
- ignoreNullValue_() {
56
- return this.#ignoreNullValue;
57
+ ignoreNull_() {
58
+ return this.#ignoreNull;
57
59
  }
58
60
 
59
- fieldExpression(fieldName, expression) {
60
- this.#fieldExpressions.set(fieldName, expression);
61
+ ignoreNull__(fieldName, ignoreNull) {
62
+ this.#ignoreNulls.set(fieldName, ignoreNull);
61
63
  return this;
62
64
  }
63
65
 
64
- fieldExpressions() {
65
- return this.#fieldExpressions;
66
+ removeIgnoreNull(fieldName) {
67
+ this.#ignoreNulls.delete(fieldName);
68
+ return this;
69
+ }
70
+
71
+ ignoreNulls() {
72
+ return this.#ignoreNulls;
73
+ }
74
+
75
+ clearIgnoreNulls() {
76
+ this.#ignoreNulls.clear();
77
+ return this;
78
+ }
79
+
80
+ expression(fieldName, expression) {
81
+ this.#expressions.set(fieldName, expression);
82
+ return this;
83
+ }
84
+
85
+ expressions() {
86
+ return this.#expressions;
87
+ }
88
+
89
+ removeExpression(fieldName) {
90
+ this.#expressions.delete(fieldName);
91
+ return this;
66
92
  }
67
93
 
68
- clearFieldExpressions() {
69
- this.#fieldExpressions.clear();
94
+ clearExpressions() {
95
+ this.#expressions.clear();
70
96
  return this;
71
97
  }
72
98
 
@@ -14,8 +14,9 @@ class FieldPolicySerializer {
14
14
  "@type": "FieldPolicy",
15
15
  "filterMode": fieldPolicy.filterMode(),
16
16
  "fieldNames": fieldPolicy.fieldNames(),
17
- "ignoreNullValue": fieldPolicy.ignoreNullValue_(),
18
- "fieldExpressions": fieldPolicy.fieldExpressions(),
17
+ "ignoreNull": fieldPolicy.ignoreNull_(),
18
+ "ignoreNulls": fieldPolicy.ignoreNulls(),
19
+ "expressions": fieldPolicy.expressions(),
19
20
  };
20
21
  }
21
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scx-js/scx-data",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "SCX Data",
5
5
  "license": "MIT",
6
6
  "author": "scx567888",
@@ -11,6 +11,6 @@
11
11
  "url": "https://github.com/scx567888/scx-js.git"
12
12
  },
13
13
  "dependencies": {
14
- "@scx-js/scx-common": "0.1.6"
14
+ "@scx-js/scx-common": "0.1.8"
15
15
  }
16
16
  }