senselogic-gson 0.1.9 → 0.3.0

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/README.md CHANGED
@@ -106,6 +106,16 @@ Command strings are also enclosed by `‴` characters, but start with a `‼` ch
106
106
  * `‴‼%id‴` generates an MD5-based TUID.
107
107
  * `‴‼@path/to/file.gson‴` includes the contents of another GSON file.
108
108
 
109
+ ## Use Cases
110
+
111
+ GSON is designed to extend JSON in scenarios where additional flexibility and expressiveness are beneficial.
112
+
113
+ It is particularly well suited for configuration files where readability matters, especially when working with multiline text.
114
+
115
+ It also helps organize large configurations or datasets by allowing them to be split into multiple files and included where needed.
116
+
117
+ Additionally, GSON supports generating consistent identifiers such as UUIDs and TUIDs directly within the data.
118
+
109
119
  ## Limitations
110
120
 
111
121
  When used as literal text:
@@ -114,7 +124,7 @@ When used as literal text:
114
124
 
115
125
  ## Version
116
126
 
117
- 0.1
127
+ 0.2
118
128
 
119
129
  ## Author
120
130
 
package/building.js CHANGED
@@ -43,7 +43,7 @@ function getMultilineString(
43
43
  indentationText
44
44
  )
45
45
  {
46
- let lineArray = value.replaceAll( "\r", "" ).split( "\n" );
46
+ let lineArray = value.replaceAll( "\r\n", "\n" ).split( "\n" );
47
47
  let lineCount = lineArray.length;
48
48
  let multilineString = indentationText + "‴";
49
49
 
package/fetching.js CHANGED
@@ -1,3 +1,7 @@
1
+ // -- IMPORTS
2
+
3
+ import { processPrimedText } from "./processing.js";
4
+
1
5
  // -- FUNCTIONS
2
6
 
3
7
  export async function fetchFileText(
@@ -25,9 +29,9 @@ async function getUnprimedFetchedText(
25
29
  && primedText.startsWith( "‼@" ) )
26
30
  {
27
31
  let filePath = folderPath + primedText.slice( 2 );
28
- let fileText = fetchFileTextFunction( filePath );
32
+ let fileText = await fetchFileTextFunction( filePath );
29
33
 
30
- return await getFetchedJsonText( fileText, filePath, primedTextIsProcessed, fetchFileTextFunction, processPrimedTextFunction );
34
+ return await getFetchedJsonText( fileText, filePath, fetchFileTextFunction, processPrimedTextFunction, primedTextIsProcessed );
31
35
  }
32
36
  else if ( primedTextIsProcessed
33
37
  && processPrimedTextFunction !== null
@@ -89,7 +93,7 @@ export async function fetchGsonFileText(
89
93
  {
90
94
  let gsonText = await fetchFileTextFunction( filePath );
91
95
 
92
- return await getFetchedJsonText( gsonText, filePath, primedTextIsProcessed, fetchFileTextFunction, processPrimedTextFunction );
96
+ return await getFetchedJsonText( gsonText, filePath, fetchFileTextFunction, processPrimedTextFunction, primedTextIsProcessed );
93
97
  }
94
98
 
95
99
  // ~~
package/index.js CHANGED
@@ -1,12 +1,9 @@
1
1
  // -- IMPORTS
2
2
 
3
3
  import { buildGsonText } from "./building.js";
4
- import { getDumpText } from "./dumping.js";
5
4
  import { haveSameValue } from "./equivalence.js";
6
5
  import { fetchFileText, getFetchedJsonText, fetchGsonFileText, fetchGsonFileValue } from "./fetching.js";
7
- import { readFileText, getReadJsonText, readGsonFileText, readGsonFileValue } from "./reading.js";
8
6
  import { getTextHash, getTextUuid, getTextTuid, processPrimedText } from "./processing.js";
9
- import { writeFileText, writeGsonValue } from "./writing.js";
10
7
 
11
8
  // -- EXPORTS
12
9
 
@@ -14,18 +11,11 @@ export {
14
11
  fetchFileText,
15
12
  fetchGsonFileText,
16
13
  fetchGsonFileValue,
17
- getDumpText,
18
14
  getFetchedJsonText,
19
15
  buildGsonText,
20
- getReadJsonText,
21
16
  getTextHash,
22
17
  getTextTuid,
23
18
  getTextUuid,
24
19
  haveSameValue,
25
20
  processPrimedText,
26
- readFileText,
27
- readGsonFileText,
28
- readGsonFileValue,
29
- writeFileText,
30
- writeGsonValue
31
21
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "senselogic-gson",
3
3
  "description": "Granular Structured Object Notation.",
4
- "version": "0.1.9",
4
+ "version": "0.3.0",
5
5
  "author": "Eric Pelzer <ecstatic.coder@gmail.com>",
6
6
  "license": "LGPL-3.0-only",
7
7
  "repository": {
@@ -21,9 +21,6 @@
21
21
  "index.js",
22
22
  "parsing.js",
23
23
  "processing.js",
24
- "reading.js",
25
- "writing.js",
26
- "test.js",
27
24
  "README.md"
28
25
  ],
29
26
  "keywords": [
package/reading.js DELETED
@@ -1,107 +0,0 @@
1
- // -- IMPORTS
2
-
3
- import { readFileSync } from "node:fs";
4
- import { processPrimedText } from "./processing.js";
5
-
6
- // -- FUNCTIONS
7
-
8
- export function readFileText(
9
- filePath
10
- )
11
- {
12
- return readFileSync( filePath, "utf8" );
13
- }
14
-
15
- // ~~
16
-
17
- function getUnprimedReadText(
18
- primedText,
19
- folderPath,
20
- primedTextIsProcessed = true,
21
- readFileTextFunction = readFileText,
22
- processPrimedTextFunction = processPrimedText
23
- )
24
- {
25
- if ( primedTextIsProcessed
26
- && readFileTextFunction !== null
27
- && primedText.startsWith( "‼@" ) )
28
- {
29
- let filePath = folderPath + primedText.slice( 2 );
30
- let fileText = readFileTextFunction( filePath );
31
-
32
- return getReadJsonText( fileText, filePath, primedTextIsProcessed, readFileTextFunction, processPrimedTextFunction );
33
- }
34
- else if ( primedTextIsProcessed
35
- && processPrimedTextFunction !== null
36
- && primedText.startsWith( "‼" ) )
37
- {
38
- return '"' + processPrimedTextFunction( primedText ) + '"';
39
- }
40
- else
41
- {
42
- let lineArray = primedText.split( "\n" );
43
-
44
- for ( let lineIndex = 0;
45
- lineIndex < lineArray.length;
46
- ++lineIndex )
47
- {
48
- lineArray[ lineIndex ]
49
- = lineArray[ lineIndex ].trim().replaceAll( "‗", " " );
50
- }
51
-
52
- return '"' + lineArray.join( "\\n" ) + '"';
53
- }
54
- }
55
-
56
- // ~~
57
-
58
- export function getReadJsonText(
59
- gsonText,
60
- filePath,
61
- primedTextIsProcessed = true,
62
- readFileTextFunction = readFileText,
63
- processPrimedTextFunction = processPrimedText
64
- )
65
- {
66
- gsonText = gsonText.replaceAll( "\r", "" ).trim();
67
- filePath = filePath.replaceAll( "\\", "/" );
68
-
69
- let folderPath = filePath.slice( 0, filePath.lastIndexOf( "/" ) + 1 );
70
- let primedTextArray = gsonText.split( "‴" );
71
-
72
- for ( let primedTextIndex = 1;
73
- primedTextIndex < primedTextArray.length;
74
- primedTextIndex += 2 )
75
- {
76
- primedTextArray[ primedTextIndex ]
77
- = getUnprimedReadText( primedTextArray[ primedTextIndex ], folderPath, primedTextIsProcessed, readFileTextFunction, processPrimedTextFunction );
78
- }
79
-
80
- return primedTextArray.join( "" );
81
- }
82
-
83
- // ~~
84
-
85
- export function readGsonFileText(
86
- filePath,
87
- primedTextIsProcessed = true,
88
- readFileTextFunction = readFileText,
89
- processPrimedTextFunction = processPrimedText
90
- )
91
- {
92
- let gsonText = readFileTextFunction( filePath );
93
-
94
- return getReadJsonText( gsonText, filePath, primedTextIsProcessed, readFileTextFunction, processPrimedTextFunction );
95
- }
96
-
97
- // ~~
98
-
99
- export function readGsonFileValue(
100
- filePath,
101
- primedTextIsProcessed = true,
102
- readFileTextFunction = readFileText,
103
- processPrimedTextFunction = processPrimedText
104
- )
105
- {
106
- return JSON.parse( readGsonFileText( filePath, primedTextIsProcessed, readFileTextFunction, processPrimedTextFunction ) );
107
- }
package/test.js DELETED
@@ -1,31 +0,0 @@
1
- // -- IMPORTS
2
-
3
- import { buildGsonText, readGsonFileText, readGsonFileValue, writeFileText } from "./index.js";
4
-
5
- // -- STATEMENTS
6
-
7
- let jsonText = readGsonFileText( "../../DATA/test.gson" );
8
- console.log( jsonText );
9
- writeFileText( "OUT/processed_test.json", jsonText );
10
-
11
- let jsonValue = readGsonFileValue( "../../DATA/test.gson" );
12
- console.log( JSON.stringify( jsonValue ) );
13
-
14
- let gsonText = buildGsonText( jsonValue );
15
- console.log( gsonText );
16
- writeFileText( "OUT/processed_test.gson", gsonText, 4 );
17
-
18
- jsonText = readGsonFileText( "../../DATA/test.gson", false );
19
- console.log( jsonText );
20
- writeFileText( "OUT/unprocessed_test.json", jsonText );
21
-
22
- gsonText = buildGsonText( jsonValue, false );
23
- console.log( gsonText );
24
- writeFileText( "OUT/unprocessed_test.gson", gsonText, 4 );
25
-
26
- jsonValue = readGsonFileValue( "../../DATA/test.gson", false );
27
- console.log( JSON.stringify( jsonValue ) );
28
-
29
- gsonText = buildGsonText( jsonValue, true, false );
30
- console.log( gsonText );
31
- writeFileText( "OUT/unprocessed_test.gson", gsonText, 4 );
package/writing.js DELETED
@@ -1,24 +0,0 @@
1
- // -- IMPORTS
2
-
3
- import { writeFileSync } from "node:fs";
4
- import { buildGsonText } from "./building.js";
5
-
6
- // -- FUNCTIONS
7
-
8
- export function writeFileText(
9
- filePath,
10
- fileText
11
- )
12
- {
13
- writeFileSync( filePath, fileText, "utf8" );
14
- }
15
-
16
- // ~~
17
-
18
- export function writeGsonValue(
19
- filePath,
20
- value
21
- )
22
- {
23
- writeFileText( filePath, buildGsonText( value ) );
24
- }