Jandodev commited on
Commit
b5d0cc0
·
1 Parent(s): 11dd039

Update output.json

Browse files
Files changed (1) hide show
  1. output.json +406 -7
output.json CHANGED
@@ -1,30 +1,429 @@
1
  [
2
  {
3
  "id": 0,
4
- "text": "sadsadsad\r"
 
 
 
5
  },
6
  {
7
  "id": 1,
8
- "text": "ds\r"
 
 
 
9
  },
10
  {
11
  "id": 2,
12
- "text": "ad\r"
 
 
 
13
  },
14
  {
15
  "id": 3,
16
- "text": "sadsadsadd\r"
 
 
 
17
  },
18
  {
19
  "id": 4,
20
- "text": "sadsadsadds\r"
 
 
 
21
  },
22
  {
23
  "id": 5,
24
- "text": "add\r"
 
 
 
25
  },
26
  {
27
  "id": 6,
28
- "text": "sad"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
  ]
 
1
  [
2
  {
3
  "id": 0,
4
+ "text": "const fs = require(\"fs\");",
5
+ "meta": {
6
+ "functionName": null
7
+ }
8
  },
9
  {
10
  "id": 1,
11
+ "text": "",
12
+ "meta": {
13
+ "functionName": null
14
+ }
15
  },
16
  {
17
  "id": 2,
18
+ "text": "const inputFile = \"input.txt\";",
19
+ "meta": {
20
+ "functionName": null
21
+ }
22
  },
23
  {
24
  "id": 3,
25
+ "text": "const outputFile = \"output.json\";",
26
+ "meta": {
27
+ "functionName": null
28
+ }
29
  },
30
  {
31
  "id": 4,
32
+ "text": "",
33
+ "meta": {
34
+ "functionName": null
35
+ }
36
  },
37
  {
38
  "id": 5,
39
+ "text": "async function processLines(lines) {",
40
+ "meta": {
41
+ "functionName": "processLines"
42
+ }
43
  },
44
  {
45
  "id": 6,
46
+ "text": " let currentFunctionName = null;",
47
+ "meta": {
48
+ "functionName": "processLines"
49
+ }
50
+ },
51
+ {
52
+ "id": 7,
53
+ "text": " let braceCounter = 0;",
54
+ "meta": {
55
+ "functionName": "processLines"
56
+ }
57
+ },
58
+ {
59
+ "id": 8,
60
+ "text": "",
61
+ "meta": {
62
+ "functionName": "processLines"
63
+ }
64
+ },
65
+ {
66
+ "id": 9,
67
+ "text": " return lines.map((line, index) => {",
68
+ "meta": {
69
+ "functionName": "processLines"
70
+ }
71
+ },
72
+ {
73
+ "id": 10,
74
+ "text": " const text = line.replace(/[\\r\\n]+$/, \"\");",
75
+ "meta": {
76
+ "functionName": "processLines"
77
+ }
78
+ },
79
+ {
80
+ "id": 11,
81
+ "text": "",
82
+ "meta": {
83
+ "functionName": "processLines"
84
+ }
85
+ },
86
+ {
87
+ "id": 12,
88
+ "text": " const matchFunction = text.match(/(?:function|async)\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s*\\(/);",
89
+ "meta": {
90
+ "functionName": "processLines"
91
+ }
92
+ },
93
+ {
94
+ "id": 13,
95
+ "text": "",
96
+ "meta": {
97
+ "functionName": "processLines"
98
+ }
99
+ },
100
+ {
101
+ "id": 14,
102
+ "text": " if (matchFunction) {",
103
+ "meta": {
104
+ "functionName": "processLines"
105
+ }
106
+ },
107
+ {
108
+ "id": 15,
109
+ "text": " currentFunctionName = matchFunction[1];",
110
+ "meta": {
111
+ "functionName": "processLines"
112
+ }
113
+ },
114
+ {
115
+ "id": 16,
116
+ "text": " braceCounter++;",
117
+ "meta": {
118
+ "functionName": "processLines"
119
+ }
120
+ },
121
+ {
122
+ "id": 17,
123
+ "text": " }",
124
+ "meta": {
125
+ "functionName": "processLines"
126
+ }
127
+ },
128
+ {
129
+ "id": 18,
130
+ "text": "",
131
+ "meta": {
132
+ "functionName": "processLines"
133
+ }
134
+ },
135
+ {
136
+ "id": 19,
137
+ "text": " // Increment the braceCounter when it encounters new opening brace",
138
+ "meta": {
139
+ "functionName": "processLines"
140
+ }
141
+ },
142
+ {
143
+ "id": 20,
144
+ "text": " if (text.includes(\"{\")) {",
145
+ "meta": {
146
+ "functionName": "processLines"
147
+ }
148
+ },
149
+ {
150
+ "id": 21,
151
+ "text": " braceCounter++;",
152
+ "meta": {
153
+ "functionName": "processLines"
154
+ }
155
+ },
156
+ {
157
+ "id": 22,
158
+ "text": " }",
159
+ "meta": {
160
+ "functionName": "processLines"
161
+ }
162
+ },
163
+ {
164
+ "id": 23,
165
+ "text": "",
166
+ "meta": {
167
+ "functionName": "processLines"
168
+ }
169
+ },
170
+ {
171
+ "id": 24,
172
+ "text": " // Decrement the braceCounter when it encounters closing brace",
173
+ "meta": {
174
+ "functionName": "processLines"
175
+ }
176
+ },
177
+ {
178
+ "id": 25,
179
+ "text": " if (text.includes(\"}\")) {",
180
+ "meta": {
181
+ "functionName": "processLines"
182
+ }
183
+ },
184
+ {
185
+ "id": 26,
186
+ "text": " braceCounter--;",
187
+ "meta": {
188
+ "functionName": "processLines"
189
+ }
190
+ },
191
+ {
192
+ "id": 27,
193
+ "text": " }",
194
+ "meta": {
195
+ "functionName": "processLines"
196
+ }
197
+ },
198
+ {
199
+ "id": 28,
200
+ "text": "",
201
+ "meta": {
202
+ "functionName": "processLines"
203
+ }
204
+ },
205
+ {
206
+ "id": 29,
207
+ "text": " // Update current function name to null if closing brace found and braceCounter is 0",
208
+ "meta": {
209
+ "functionName": "processLines"
210
+ }
211
+ },
212
+ {
213
+ "id": 30,
214
+ "text": " if (braceCounter === 0) {",
215
+ "meta": {
216
+ "functionName": "processLines"
217
+ }
218
+ },
219
+ {
220
+ "id": 31,
221
+ "text": " currentFunctionName = null;",
222
+ "meta": {
223
+ "functionName": "processLines"
224
+ }
225
+ },
226
+ {
227
+ "id": 32,
228
+ "text": " }",
229
+ "meta": {
230
+ "functionName": "processLines"
231
+ }
232
+ },
233
+ {
234
+ "id": 33,
235
+ "text": "",
236
+ "meta": {
237
+ "functionName": "processLines"
238
+ }
239
+ },
240
+ {
241
+ "id": 34,
242
+ "text": " return {",
243
+ "meta": {
244
+ "functionName": "processLines"
245
+ }
246
+ },
247
+ {
248
+ "id": 35,
249
+ "text": " id: index,",
250
+ "meta": {
251
+ "functionName": "processLines"
252
+ }
253
+ },
254
+ {
255
+ "id": 36,
256
+ "text": " text: text,",
257
+ "meta": {
258
+ "functionName": "processLines"
259
+ }
260
+ },
261
+ {
262
+ "id": 37,
263
+ "text": " meta: { functionName: currentFunctionName },",
264
+ "meta": {
265
+ "functionName": "processLines"
266
+ }
267
+ },
268
+ {
269
+ "id": 38,
270
+ "text": " };",
271
+ "meta": {
272
+ "functionName": "processLines"
273
+ }
274
+ },
275
+ {
276
+ "id": 39,
277
+ "text": " });",
278
+ "meta": {
279
+ "functionName": "processLines"
280
+ }
281
+ },
282
+ {
283
+ "id": 40,
284
+ "text": "}",
285
+ "meta": {
286
+ "functionName": null
287
+ }
288
+ },
289
+ {
290
+ "id": 41,
291
+ "text": "",
292
+ "meta": {
293
+ "functionName": null
294
+ }
295
+ },
296
+ {
297
+ "id": 42,
298
+ "text": "async function readFileAndProcess(inputFile, outputFile) {",
299
+ "meta": {
300
+ "functionName": "readFileAndProcess"
301
+ }
302
+ },
303
+ {
304
+ "id": 43,
305
+ "text": " fs.readFile(inputFile, \"utf8\", async (err, contents) => {",
306
+ "meta": {
307
+ "functionName": "readFileAndProcess"
308
+ }
309
+ },
310
+ {
311
+ "id": 44,
312
+ "text": " if (err) throw err;",
313
+ "meta": {
314
+ "functionName": "readFileAndProcess"
315
+ }
316
+ },
317
+ {
318
+ "id": 45,
319
+ "text": "",
320
+ "meta": {
321
+ "functionName": "readFileAndProcess"
322
+ }
323
+ },
324
+ {
325
+ "id": 46,
326
+ "text": " const lines = contents.trim().split(\"\\n\");",
327
+ "meta": {
328
+ "functionName": "readFileAndProcess"
329
+ }
330
+ },
331
+ {
332
+ "id": 47,
333
+ "text": "",
334
+ "meta": {
335
+ "functionName": "readFileAndProcess"
336
+ }
337
+ },
338
+ {
339
+ "id": 48,
340
+ "text": " const jsonArray = await processLines(lines);",
341
+ "meta": {
342
+ "functionName": "readFileAndProcess"
343
+ }
344
+ },
345
+ {
346
+ "id": 49,
347
+ "text": "",
348
+ "meta": {
349
+ "functionName": "readFileAndProcess"
350
+ }
351
+ },
352
+ {
353
+ "id": 50,
354
+ "text": " const jsonString = JSON.stringify(jsonArray, null, 2);",
355
+ "meta": {
356
+ "functionName": "readFileAndProcess"
357
+ }
358
+ },
359
+ {
360
+ "id": 51,
361
+ "text": "",
362
+ "meta": {
363
+ "functionName": "readFileAndProcess"
364
+ }
365
+ },
366
+ {
367
+ "id": 52,
368
+ "text": " fs.writeFile(outputFile, jsonString, (err) => {",
369
+ "meta": {
370
+ "functionName": "readFileAndProcess"
371
+ }
372
+ },
373
+ {
374
+ "id": 53,
375
+ "text": " if (err) throw err;",
376
+ "meta": {
377
+ "functionName": "readFileAndProcess"
378
+ }
379
+ },
380
+ {
381
+ "id": 54,
382
+ "text": "",
383
+ "meta": {
384
+ "functionName": "readFileAndProcess"
385
+ }
386
+ },
387
+ {
388
+ "id": 55,
389
+ "text": " console.log(\"JSON output file created:\", outputFile);",
390
+ "meta": {
391
+ "functionName": "readFileAndProcess"
392
+ }
393
+ },
394
+ {
395
+ "id": 56,
396
+ "text": " });",
397
+ "meta": {
398
+ "functionName": "readFileAndProcess"
399
+ }
400
+ },
401
+ {
402
+ "id": 57,
403
+ "text": " });",
404
+ "meta": {
405
+ "functionName": "readFileAndProcess"
406
+ }
407
+ },
408
+ {
409
+ "id": 58,
410
+ "text": "}",
411
+ "meta": {
412
+ "functionName": "readFileAndProcess"
413
+ }
414
+ },
415
+ {
416
+ "id": 59,
417
+ "text": "",
418
+ "meta": {
419
+ "functionName": "readFileAndProcess"
420
+ }
421
+ },
422
+ {
423
+ "id": 60,
424
+ "text": "readFileAndProcess(inputFile, outputFile);",
425
+ "meta": {
426
+ "functionName": "readFileAndProcess"
427
+ }
428
  }
429
  ]