flex-json 0.0.2 → 0.0.4

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/FlexJsonClass.js CHANGED
@@ -3,6 +3,7 @@ const FlexJsonPosition = require("./FlexJsonPosition.js");
3
3
  const FlexJsonMeta = require("./FlexJsonMeta.js");
4
4
  const fs = require("fs");
5
5
  const StringBuilder = require("string-builder");
6
+ const { trackingStats, statusMsg,tmpStatusMsg } = require( "./get/index.js");
6
7
 
7
8
  class FlexJson {
8
9
  _status = 0;
@@ -40,19 +41,26 @@ class FlexJson {
40
41
  }
41
42
  }
42
43
 
44
+ // get trackingStats() {
45
+ // if (this._meta == null) return false;
46
+ // if (this._meta.stats == null) return false;
47
+ // return true;
48
+ // }
49
+ // use the imported trackingStats function instead
50
+
43
51
  get trackingStats() {
44
- if (this._meta == null) return false;
45
- if (this._meta.stats == null) return false;
46
- return true;
52
+ return trackingStats(this._meta);
47
53
  }
48
54
 
55
+
49
56
  get statusMsg() {
50
- if (this._meta != null) {
51
- if (this._meta.statusMsg != null) {
52
- return this._meta.statusMsg;
53
- }
54
- }
55
- return "";
57
+ // if (this._meta != null) {
58
+ // if (this._meta.statusMsg != null) {
59
+ // return this._meta.statusMsg;
60
+ // }
61
+ // }
62
+ // return "";
63
+ return statusMsg(this._meta);
56
64
  }
57
65
  set statusMsg(value) {
58
66
  if (this.NoStatsOrMsgs) {
@@ -70,12 +78,13 @@ class FlexJson {
70
78
  }
71
79
 
72
80
  get tmpStatusMsg() {
73
- if (this._meta != null) {
74
- if (this._meta.tmpStatusMsg != null) {
75
- return this._meta.tmpStatusMsg;
76
- }
77
- }
78
- return "";
81
+ // if (this._meta != null) {
82
+ // if (this._meta.tmpStatusMsg != null) {
83
+ // return this._meta.tmpStatusMsg;
84
+ // }
85
+ // }
86
+ // return "";
87
+ return tmpStatusMsg(this._meta);
79
88
  }
80
89
  set tmpStatusMsg(value) {
81
90
  this.createMetaIfNeeded();
@@ -344,7 +353,7 @@ class FlexJson {
344
353
  v(idx, dotNotation = true) {
345
354
  //if (trackingStats) { IncStats("stat_Value_get"); } // FUTURE-NEW
346
355
  if (!idx) {
347
- // retun the value of this item
356
+ // return the value of this item
348
357
  if (!this.ValidateValue()) {
349
358
  return null;
350
359
  } // *** Unable to validate/Deserialize the value
@@ -356,7 +365,6 @@ class FlexJson {
356
365
  } else {
357
366
  return this.i(idx, dotNotation).v();
358
367
  }
359
- return null;
360
368
  }
361
369
 
362
370
  get thisValue() {
@@ -383,7 +391,7 @@ class FlexJson {
383
391
  toJsonArray(idx, dotNotation = true) {
384
392
  //if (trackingStats) { IncStats("stat_Value_get"); } // FUTURE-NEW
385
393
  if (!idx) {
386
- // retun the value of this item
394
+ // return the value of this item
387
395
  if (!this.ValidateValue()) {
388
396
  return null;
389
397
  } // *** Unable to validate/Deserialize the value
@@ -1727,22 +1735,21 @@ class FlexJson {
1727
1735
  case "bigint":
1728
1736
  case "number":
1729
1737
  return "number";
1730
- break;
1738
+
1731
1739
  case "boolean":
1732
1740
  return "boolean";
1733
- break;
1741
+
1734
1742
  case "object": // must be FlexJson object or it is not a true "object"
1735
1743
  return ""; // indicates an error/invlid type
1736
- break;
1744
+
1737
1745
  case "FlexJson":
1738
1746
  return FlexJson.jsonType;
1739
- break;
1747
+
1740
1748
  case "function":
1741
1749
  return ""; // indicate error/invalid type
1742
- break;
1750
+
1743
1751
  default:
1744
1752
  return "string";
1745
- break;
1746
1753
  }
1747
1754
  }
1748
1755
  }
package/README.md CHANGED
@@ -1,6 +1,13 @@
1
- # FlexJson
1
+ # flex-json
2
2
 
3
- ## Flexible JSON manipulation library for JavaScript.
3
+ ## Flexible JSON manipulation library for JavaScript
4
+
5
+ ## Maintainers
6
+
7
+ | Maintainer | GitHub | LinkedIn |
8
+ | --------------- | ------------------------------------------- | ------------------------------------------------------ |
9
+ | Ted Tyree | [GitHub](https://github.com/tedtyree) |[LinkedIn](https://www.linkedin.com/in/tedtyree/) |
10
+ | Michael Njuguna | [GitHub](https://github.com/michaelnjuguna) |[LinkedIn](https://www.linkedin.com/in/michael-njuguna/)|
4
11
 
5
12
  ## Table of Contents
6
13
 
@@ -97,27 +104,27 @@ It is simply Json with comments! FlexJson was written to make JSON config files
97
104
  - Includes comments in both /* */ and // notation
98
105
  - Simple to edit Json files
99
106
  - Allows for other JavaScript like features such as using either single quotes or double quotes.
100
- - Can also be used within Node.js apps for other uses such as reading/writing JSON to/from database records and parsing loosely formattted Json in web page content.
107
+ - Can also be used within Node.js apps for other uses such as reading/writing JSON to/from database records and parsing loosely formatted Json in web page content.
101
108
 
102
109
  ## How the library works
103
110
 
104
111
  ### Flex-json syntax
105
112
 
106
- BTW FlexJson as a standard of syntax is not really all that new - it is very much in existence within JavaScript and other syntax standards. Here we just make it available in a library and to facilitate config file parsing and editing.
113
+ BTW flex-json as a standard of syntax is not really all that new - it is very much in existence within JavaScript and other syntax standards. Here we just make it available in a library and to facilitate config file parsing and editing.
107
114
 
108
115
  ### Strict Mode
109
116
 
110
- When in strict mode, the FlexJson library reads JSON files in standard JSON format. Comments are not valid and double quotes are required around strings.
117
+ When in strict mode, the flex-json library reads JSON files in standard JSON format. Comments are not valid and double quotes are required around strings.
111
118
 
112
119
  Note: If the library is flagged to preserve spacing, Json that has been read in from a file will be written with the same formatting. In other words, the carriage returns and white space are captured during the parsing process and used to re-format the output during the write process.
113
120
 
114
121
  ### Flex Mode
115
122
 
116
- When in flex mode, the FlexJson library has the following features:
123
+ When in flex mode, the flex-json library has the following features:
117
124
 
118
- - Like JavaScript, comments can be surrounded by /* (start of comment) and */ (end of comment)
125
+ - Like JavaScript, comments can be surrounded by /* (start of comment) and */ (end of comment)
119
126
 
120
- - Like Javasrcipt, when a "//" is encountered, the remainder of the line is considered to be a comment
127
+ - Like JavaScript, when a "//" is encountered, the remainder of the line is considered to be a comment
121
128
 
122
129
  - Strings do not require quotes unless they contain special characters
123
130
 
@@ -152,7 +159,7 @@ __example 3:__
152
159
  ]
153
160
  ```
154
161
 
155
- __Note__ that {number:"2"} is not the same as {number:2} because FlexJson will see that the 2 without quotes is a valid number and load it as a numeric.
162
+ __Note__ that {number:"2"} is not the same as {number:2} because flex-json will see that the 2 without quotes is a valid number and load it as a numeric.
156
163
 
157
164
  ### Contributing
158
165
 
package/get/index.js ADDED
@@ -0,0 +1,27 @@
1
+ function trackingStats(meta) {
2
+ if (meta == null || meta.status == null) {
3
+ return false;
4
+ }
5
+ return true;
6
+ }
7
+
8
+ function statusMsg(meta){
9
+ if(meta != null && meta.statusMsg != null){
10
+ return meta.statusMsg;
11
+ }
12
+ return '';
13
+ }
14
+
15
+ function tmpStatusMsg(meta){
16
+ if(meta != null && meta.tmpStatusMsg != null){
17
+ return meta.tmpStatusMsg;
18
+ }
19
+ return '';
20
+ }
21
+
22
+ // exports
23
+ module.exports = {
24
+ trackingStats: trackingStats,
25
+ statusMsg: statusMsg,
26
+ tmpStatusMsg: tmpStatusMsg
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flex-json",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "This is a library that makes each 'Node' in the JSON Object/Array a JSON Object with a Key/Value pair.",
5
5
  "main": "FlexJsonClass.js",
6
6
  "authors": "[michael njuguna michaelnjuguna184@gmail.com, ted tyree tedtyree@gmail.com]",
@@ -9,7 +9,7 @@
9
9
  "JSON Object",
10
10
  "JSON Array",
11
11
  "JSON Object Array",
12
- "flexjson"
12
+ "flex-json"
13
13
  ],
14
14
  "dependencies": {
15
15
  "string-builder": "^0.1.8"
package/set/index.js ADDED
File without changes