senselogic-gson 0.1.7 → 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.
package/building.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // -- VARIABLES
2
2
 
3
- let cachedIndentationText = ' ';
3
+ let cachedIndentationText = " ";
4
4
 
5
5
  // -- FUNCTIONS
6
6
 
@@ -10,7 +10,7 @@ export function getIndentationText(
10
10
  {
11
11
  while ( cachedIndentationText.length < indentationSpaceCount )
12
12
  {
13
- cachedIndentationText += ' ';
13
+ cachedIndentationText += " ";
14
14
  }
15
15
 
16
16
  return cachedIndentationText.slice( 0, indentationSpaceCount );
@@ -23,11 +23,11 @@ function getEscapedLine(
23
23
  primedTextIsEscaped = true
24
24
  )
25
25
  {
26
- let escapedLine = JSON.stringify( line ).slice( 1, -1 ).replaceAll( '', '\\u2034' );
26
+ let escapedLine = JSON.stringify( line ).slice( 1, -1 ).replaceAll( "", "\\u2034" );
27
27
 
28
28
  if ( primedTextIsEscaped )
29
29
  {
30
- return escapedLine.replaceAll( '', '\\u203C' ).replaceAll( '', '\\u2017' );
30
+ return escapedLine.replaceAll( "", "\\u203C" ).replaceAll( "", "\\u2017" );
31
31
  }
32
32
  else
33
33
  {
@@ -43,9 +43,9 @@ function getMultilineString(
43
43
  indentationText
44
44
  )
45
45
  {
46
- let lineArray = value.replaceAll( '\r', '' ).split( '\n' );
46
+ let lineArray = value.replaceAll( "\r", "" ).split( "\n" );
47
47
  let lineCount = lineArray.length;
48
- let multilineString = indentationText + '';
48
+ let multilineString = indentationText + "";
49
49
 
50
50
  for ( let lineIndex = 0;
51
51
  lineIndex < lineCount;
@@ -55,7 +55,7 @@ function getMultilineString(
55
55
  let startingSpaceCount = 0;
56
56
 
57
57
  while ( startingSpaceCount < line.length
58
- && line[ startingSpaceCount ] === ' ' )
58
+ && line[ startingSpaceCount ] === " " )
59
59
  {
60
60
  ++startingSpaceCount;
61
61
  }
@@ -68,29 +68,29 @@ function getMultilineString(
68
68
 
69
69
  if ( startingSpaceCount > 0 )
70
70
  {
71
- linePrefix = '' + getIndentationText( startingSpaceCount - 1 );
71
+ linePrefix = "" + getIndentationText( startingSpaceCount - 1 );
72
72
  }
73
73
  else
74
74
  {
75
- linePrefix = '';
75
+ linePrefix = "";
76
76
  }
77
77
 
78
78
  let lineSuffix;
79
79
 
80
80
  if ( endingSpaceCount > 0 )
81
81
  {
82
- lineSuffix = getIndentationText( endingSpaceCount - 1 ) + '';
82
+ lineSuffix = getIndentationText( endingSpaceCount - 1 ) + "";
83
83
  }
84
84
  else
85
85
  {
86
- lineSuffix = '';
86
+ lineSuffix = "";
87
87
  }
88
88
 
89
89
  let multilineStringLine = linePrefix + getEscapedLine( lineContent, primedTextIsEscaped ) + lineSuffix;
90
90
 
91
91
  if ( lineIndex === lineCount - 1 )
92
92
  {
93
- multilineStringLine = multilineStringLine + '';
93
+ multilineStringLine = multilineStringLine + "";
94
94
  }
95
95
 
96
96
  if ( lineIndex === 0 )
@@ -99,7 +99,7 @@ function getMultilineString(
99
99
  }
100
100
  else
101
101
  {
102
- multilineString += '\n' + indentationText + multilineStringLine;
102
+ multilineString += "\n" + indentationText + multilineStringLine;
103
103
  }
104
104
  }
105
105
 
@@ -114,24 +114,24 @@ function buildGsonString(
114
114
  primedTextIsEscaped = true,
115
115
  context,
116
116
  level,
117
- lineSuffix = ''
117
+ lineSuffix = ""
118
118
  )
119
119
  {
120
120
  let indentationText = getIndentationText( level * context.levelSpaceCount );
121
121
 
122
122
  if ( primedTextIsGenerated
123
- && ( value.startsWith( '' )
124
- || value.includes( '\n' ) ) )
123
+ && ( value.startsWith( "" )
124
+ || value.includes( "\n" ) ) )
125
125
  {
126
- if ( value.startsWith( '' ) )
126
+ if ( value.startsWith( "" ) )
127
127
  {
128
- let text = '' + getEscapedLine( value, primedTextIsEscaped ) + '' + lineSuffix;
128
+ let text = "" + getEscapedLine( value, primedTextIsEscaped ) + "" + lineSuffix;
129
129
  context.lineArray.push( indentationText + text );
130
130
  }
131
131
  else
132
132
  {
133
133
  let multilineString = getMultilineString( value, primedTextIsEscaped, indentationText );
134
- let lineArray = multilineString.split( '\n' );
134
+ let lineArray = multilineString.split( "\n" );
135
135
  let lastIndex = lineArray.length - 1;
136
136
 
137
137
  for ( let lineIndex = 0;
@@ -170,13 +170,13 @@ function buildGsonValue(
170
170
  {
171
171
  let indentationText = getIndentationText( level * context.levelSpaceCount );
172
172
 
173
- if ( typeof value === 'string' )
173
+ if ( typeof value === "string" )
174
174
  {
175
- buildGsonString( value, primedTextIsGenerated, primedTextIsEscaped, context, level, '' );
175
+ buildGsonString( value, primedTextIsGenerated, primedTextIsEscaped, context, level, "" );
176
176
  }
177
177
  else if ( Array.isArray( value ) )
178
178
  {
179
- context.lineArray.push( indentationText + '[' );
179
+ context.lineArray.push( indentationText + "[" );
180
180
 
181
181
  let elementCount = value.length;
182
182
 
@@ -185,7 +185,7 @@ function buildGsonValue(
185
185
  ++elementIndex )
186
186
  {
187
187
  let element = value[ elementIndex ];
188
- let lineSuffix = ( elementIndex < elementCount - 1 ) ? ',' : '';
188
+ let lineSuffix = ( elementIndex < elementCount - 1 ) ? "," : "";
189
189
 
190
190
  buildGsonValue(
191
191
  element,
@@ -202,12 +202,12 @@ function buildGsonValue(
202
202
  }
203
203
  }
204
204
 
205
- context.lineArray.push( indentationText + ']' );
205
+ context.lineArray.push( indentationText + "]" );
206
206
  }
207
207
  else if ( value !== null
208
- && typeof value === 'object' )
208
+ && typeof value === "object" )
209
209
  {
210
- context.lineArray.push( indentationText + '{' );
210
+ context.lineArray.push( indentationText + "{" );
211
211
 
212
212
  let keyArray = Object.keys( value );
213
213
  let keyCount = keyArray.length;
@@ -219,9 +219,9 @@ function buildGsonValue(
219
219
  let key = keyArray[ keyIndex ];
220
220
  let keyIndentationText = getIndentationText( ( level + 1 ) * context.levelSpaceCount );
221
221
  let valueIndentLevel = level + 2;
222
- let lineSuffix = ( keyIndex < keyCount - 1 ) ? ',' : '';
222
+ let lineSuffix = ( keyIndex < keyCount - 1 ) ? "," : "";
223
223
 
224
- context.lineArray.push( keyIndentationText + JSON.stringify( key ) + ':' );
224
+ context.lineArray.push( keyIndentationText + JSON.stringify( key ) + ":" );
225
225
 
226
226
  buildGsonValue(
227
227
  value[ key ],
@@ -238,7 +238,7 @@ function buildGsonValue(
238
238
  }
239
239
  }
240
240
 
241
- context.lineArray.push( indentationText + '}' );
241
+ context.lineArray.push( indentationText + "}" );
242
242
  }
243
243
  else
244
244
  {
@@ -269,5 +269,5 @@ export function buildGsonText(
269
269
  0
270
270
  );
271
271
 
272
- return context.lineArray.join( '\n' );
272
+ return context.lineArray.join( "\n" );
273
273
  }
package/equivalence.js CHANGED
@@ -72,8 +72,8 @@ export function haveSameValue(
72
72
 
73
73
  return true;
74
74
  }
75
- else if ( typeof firstValue === 'object'
76
- && typeof secondValue === 'object' )
75
+ else if ( typeof firstValue === "object"
76
+ && typeof secondValue === "object" )
77
77
  {
78
78
  let firstValueKeyArray = Object.keys( firstValue );
79
79
  let secondValueKeyArray = Object.keys( secondValue );
package/fetching.js CHANGED
@@ -22,7 +22,7 @@ async function getUnprimedFetchedText(
22
22
  {
23
23
  if ( primedTextIsProcessed
24
24
  && fetchFileTextFunction !== null
25
- && primedText.startsWith( '‼@' ) )
25
+ && primedText.startsWith( "‼@" ) )
26
26
  {
27
27
  let filePath = folderPath + primedText.slice( 2 );
28
28
  let fileText = fetchFileTextFunction( filePath );
@@ -31,23 +31,23 @@ async function getUnprimedFetchedText(
31
31
  }
32
32
  else if ( primedTextIsProcessed
33
33
  && processPrimedTextFunction !== null
34
- && primedText.startsWith( '' ) )
34
+ && primedText.startsWith( "" ) )
35
35
  {
36
36
  return '"' + processPrimedTextFunction( primedText ) + '"';
37
37
  }
38
38
  else
39
39
  {
40
- let lineArray = primedText.split( '\n' );
40
+ let lineArray = primedText.split( "\n" );
41
41
 
42
42
  for ( let lineIndex = 0;
43
43
  lineIndex < lineArray.length;
44
44
  ++lineIndex )
45
45
  {
46
46
  lineArray[ lineIndex ]
47
- = lineArray[ lineIndex ].trim().replaceAll( '', ' ' );
47
+ = lineArray[ lineIndex ].trim().replaceAll( "", " " );
48
48
  }
49
49
 
50
- return '"' + lineArray.join( '\\n' ) + '"';
50
+ return '"' + lineArray.join( "\\n" ) + '"';
51
51
  }
52
52
  }
53
53
 
@@ -61,11 +61,11 @@ export async function getFetchedJsonText(
61
61
  primedTextIsProcessed = true
62
62
  )
63
63
  {
64
- gsonText = gsonText.replaceAll( '\r', '' ).trim();
65
- filePath = filePath.replaceAll( '\\', '/' );
64
+ gsonText = gsonText.replaceAll( "\r", "" ).trim();
65
+ filePath = filePath.replaceAll( "\\", "/" );
66
66
 
67
- let folderPath = filePath.slice( 0, filePath.lastIndexOf( '/' ) + 1 );
68
- let primedTextArray = gsonText.split( '' );
67
+ let folderPath = filePath.slice( 0, filePath.lastIndexOf( "/" ) + 1 );
68
+ let primedTextArray = gsonText.split( "" );
69
69
 
70
70
  for ( let primedTextIndex = 1;
71
71
  primedTextIndex < primedTextArray.length;
@@ -75,7 +75,7 @@ export async function getFetchedJsonText(
75
75
  = await getUnprimedFetchedText( primedTextArray[ primedTextIndex ], folderPath, primedTextIsProcessed, fetchFileTextFunction, processPrimedTextFunction );
76
76
  }
77
77
 
78
- return primedTextArray.join( '' );
78
+ return primedTextArray.join( "" );
79
79
  }
80
80
 
81
81
  // ~~
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // -- IMPORTS
2
2
 
3
- import { buildGsonText } from './building.js';
4
- import { getDumpText } from './dumping.js';
5
- import { haveSameValue } from './equivalence.js';
6
- import { fetchFileText, getFetchedJsonText, fetchGsonFileText, fetchGsonFileValue } from './fetching.js';
7
- import { readFileText, getReadJsonText, readGsonFileText, readGsonFileValue } from './reading.js';
8
- import { getTextHash, getTextUuid, getTextTuid, processPrimedText } from './processing.js';
9
- import { writeFileText, writeGsonValue } from './writing.js';
3
+ import { buildGsonText } from "./building.js";
4
+ import { getDumpText } from "./dumping.js";
5
+ import { haveSameValue } from "./equivalence.js";
6
+ import { fetchFileText, getFetchedJsonText, fetchGsonFileText, fetchGsonFileValue } from "./fetching.js";
7
+ import { readFileText, getReadJsonText, readGsonFileText, readGsonFileValue } from "./reading.js";
8
+ import { getTextHash, getTextUuid, getTextTuid, processPrimedText } from "./processing.js";
9
+ import { writeFileText, writeGsonValue } from "./writing.js";
10
10
 
11
11
  // -- EXPORTS
12
12
 
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.7",
4
+ "version": "0.1.8",
5
5
  "author": "Eric Pelzer <ecstatic.coder@gmail.com>",
6
6
  "license": "LGPL-3.0-only",
7
7
  "repository": {
package/processing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // -- IMPORTS
2
2
 
3
- import md5 from 'md5';
3
+ import md5 from "md5";
4
4
 
5
5
  // -- FUNCTIONS
6
6
 
@@ -17,9 +17,9 @@ export function getTextUuid(
17
17
  text
18
18
  )
19
19
  {
20
- if ( text === '' )
20
+ if ( text === "" )
21
21
  {
22
- return '';
22
+ return "";
23
23
  }
24
24
  else
25
25
  {
@@ -27,13 +27,13 @@ export function getTextUuid(
27
27
 
28
28
  return (
29
29
  hash.slice( 0, 8 )
30
- + '-'
30
+ + "-"
31
31
  + hash.slice( 8, 12 )
32
- + '-'
32
+ + "-"
33
33
  + hash.slice( 12, 16 )
34
- + '-'
34
+ + "-"
35
35
  + hash.slice( 16, 20 )
36
- + '-'
36
+ + "-"
37
37
  + hash.slice( 20, 32 )
38
38
  );
39
39
  }
@@ -45,9 +45,9 @@ export function getTextTuid(
45
45
  text
46
46
  )
47
47
  {
48
- if ( text === '' )
48
+ if ( text === "" )
49
49
  {
50
- return '';
50
+ return "";
51
51
  }
52
52
  else
53
53
  {
@@ -62,13 +62,13 @@ export function getTextTuid(
62
62
  byteArray[ characterIndex >> 1 ] = String.fromCharCode( parseInt( hash.slice( characterIndex, characterIndex + 2 ), 16 ) );
63
63
  }
64
64
 
65
- let tuid = btoa( byteArray.join( '' ) );
65
+ let tuid = btoa( byteArray.join( "" ) );
66
66
 
67
67
  return (
68
68
  tuid
69
- .replaceAll( '+', '-' )
70
- .replaceAll( '/', '_' )
71
- .replaceAll( '=', '' )
69
+ .replaceAll( "+", "-" )
70
+ .replaceAll( "/", "_" )
71
+ .replaceAll( "=", "" )
72
72
  );
73
73
  }
74
74
  }
@@ -79,11 +79,11 @@ export function processPrimedText(
79
79
  primedText
80
80
  )
81
81
  {
82
- if ( primedText.startsWith( '‼#' ) )
82
+ if ( primedText.startsWith( "‼#" ) )
83
83
  {
84
84
  return getTextUuid( primedText.slice( 2 ) );
85
85
  }
86
- else if ( primedText.startsWith( '‼%' ) )
86
+ else if ( primedText.startsWith( "‼%" ) )
87
87
  {
88
88
  return getTextTuid( primedText.slice( 2 ) );
89
89
  }
package/reading.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // -- IMPORTS
2
2
 
3
- import { readFileSync } from 'node:fs';
4
- import { processPrimedText } from './processing.js';
3
+ import { readFileSync } from "node:fs";
4
+ import { processPrimedText } from "./processing.js";
5
5
 
6
6
  // -- FUNCTIONS
7
7
 
@@ -9,7 +9,7 @@ export function readFileText(
9
9
  filePath
10
10
  )
11
11
  {
12
- return readFileSync( filePath, 'utf8' );
12
+ return readFileSync( filePath, "utf8" );
13
13
  }
14
14
 
15
15
  // ~~
@@ -24,7 +24,7 @@ function getUnprimedReadText(
24
24
  {
25
25
  if ( primedTextIsProcessed
26
26
  && readFileTextFunction !== null
27
- && primedText.startsWith( '‼@' ) )
27
+ && primedText.startsWith( "‼@" ) )
28
28
  {
29
29
  let filePath = folderPath + primedText.slice( 2 );
30
30
  let fileText = readFileTextFunction( filePath );
@@ -33,23 +33,23 @@ function getUnprimedReadText(
33
33
  }
34
34
  else if ( primedTextIsProcessed
35
35
  && processPrimedTextFunction !== null
36
- && primedText.startsWith( '' ) )
36
+ && primedText.startsWith( "" ) )
37
37
  {
38
38
  return '"' + processPrimedTextFunction( primedText ) + '"';
39
39
  }
40
40
  else
41
41
  {
42
- let lineArray = primedText.split( '\n' );
42
+ let lineArray = primedText.split( "\n" );
43
43
 
44
44
  for ( let lineIndex = 0;
45
45
  lineIndex < lineArray.length;
46
46
  ++lineIndex )
47
47
  {
48
48
  lineArray[ lineIndex ]
49
- = lineArray[ lineIndex ].trim().replaceAll( '', ' ' );
49
+ = lineArray[ lineIndex ].trim().replaceAll( "", " " );
50
50
  }
51
51
 
52
- return '"' + lineArray.join( '\\n' ) + '"';
52
+ return '"' + lineArray.join( "\\n" ) + '"';
53
53
  }
54
54
  }
55
55
 
@@ -63,11 +63,11 @@ export function getReadJsonText(
63
63
  processPrimedTextFunction = processPrimedText
64
64
  )
65
65
  {
66
- gsonText = gsonText.replaceAll( '\r', '' ).trim();
67
- filePath = filePath.replaceAll( '\\', '/' );
66
+ gsonText = gsonText.replaceAll( "\r", "" ).trim();
67
+ filePath = filePath.replaceAll( "\\", "/" );
68
68
 
69
- let folderPath = filePath.slice( 0, filePath.lastIndexOf( '/' ) + 1 );
70
- let primedTextArray = gsonText.split( '' );
69
+ let folderPath = filePath.slice( 0, filePath.lastIndexOf( "/" ) + 1 );
70
+ let primedTextArray = gsonText.split( "" );
71
71
 
72
72
  for ( let primedTextIndex = 1;
73
73
  primedTextIndex < primedTextArray.length;
@@ -77,7 +77,7 @@ export function getReadJsonText(
77
77
  = getUnprimedReadText( primedTextArray[ primedTextIndex ], folderPath, primedTextIsProcessed, readFileTextFunction, processPrimedTextFunction );
78
78
  }
79
79
 
80
- return primedTextArray.join( '' );
80
+ return primedTextArray.join( "" );
81
81
  }
82
82
 
83
83
  // ~~
package/test.js CHANGED
@@ -1,31 +1,31 @@
1
1
  // -- IMPORTS
2
2
 
3
- import { buildGsonText, readGsonFileText, readGsonFileValue, writeFileText } from './index.js';
3
+ import { buildGsonText, readGsonFileText, readGsonFileValue, writeFileText } from "./index.js";
4
4
 
5
5
  // -- STATEMENTS
6
6
 
7
- let jsonText = readGsonFileText( '../../../DATA/test.gson' );
7
+ let jsonText = readGsonFileText( "../../DATA/test.gson" );
8
8
  console.log( jsonText );
9
- writeFileText( 'OUT/processed_test.json', jsonText );
9
+ writeFileText( "OUT/processed_test.json", jsonText );
10
10
 
11
- let jsonValue = readGsonFileValue( '../../../DATA/test.gson' );
11
+ let jsonValue = readGsonFileValue( "../../DATA/test.gson" );
12
12
  console.log( JSON.stringify( jsonValue ) );
13
13
 
14
14
  let gsonText = buildGsonText( jsonValue );
15
15
  console.log( gsonText );
16
- writeFileText( 'OUT/processed_test.gson', gsonText, 4 );
16
+ writeFileText( "OUT/processed_test.gson", gsonText, 4 );
17
17
 
18
- jsonText = readGsonFileText( '../../../DATA/test.gson', false );
18
+ jsonText = readGsonFileText( "../../DATA/test.gson", false );
19
19
  console.log( jsonText );
20
- writeFileText( 'OUT/unprocessed_test.json', jsonText );
20
+ writeFileText( "OUT/unprocessed_test.json", jsonText );
21
21
 
22
22
  gsonText = buildGsonText( jsonValue, false );
23
23
  console.log( gsonText );
24
- writeFileText( 'OUT/unprocessed_test.gson', gsonText, 4 );
24
+ writeFileText( "OUT/unprocessed_test.gson", gsonText, 4 );
25
25
 
26
- jsonValue = readGsonFileValue( '../../../DATA/test.gson', false );
26
+ jsonValue = readGsonFileValue( "../../DATA/test.gson", false );
27
27
  console.log( JSON.stringify( jsonValue ) );
28
28
 
29
29
  gsonText = buildGsonText( jsonValue, true, false );
30
30
  console.log( gsonText );
31
- writeFileText( 'OUT/unprocessed_test.gson', gsonText, 4 );
31
+ writeFileText( "OUT/unprocessed_test.gson", gsonText, 4 );
package/writing.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // -- IMPORTS
2
2
 
3
- import { writeFileSync } from 'node:fs';
4
- import { buildGsonText } from './building.js';
3
+ import { writeFileSync } from "node:fs";
4
+ import { buildGsonText } from "./building.js";
5
5
 
6
6
  // -- FUNCTIONS
7
7
 
@@ -10,15 +10,14 @@ export function writeFileText(
10
10
  fileText
11
11
  )
12
12
  {
13
- writeFileSync( filePath, fileText, 'utf8' );
13
+ writeFileSync( filePath, fileText, "utf8" );
14
14
  }
15
15
 
16
16
  // ~~
17
17
 
18
18
  export function writeGsonValue(
19
19
  filePath,
20
- value,
21
- writeFileTextFunction = writeFileText
20
+ value
22
21
  )
23
22
  {
24
23
  writeFileText( filePath, buildGsonText( value ) );