jtcsv 2.2.7 → 3.0.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 +31 -1
- package/bin/jtcsv.js +891 -821
- package/bin/jtcsv.ts +2534 -0
- package/csv-to-json.js +168 -145
- package/dist/jtcsv-core.cjs.js +1407 -0
- package/dist/jtcsv-core.cjs.js.map +1 -0
- package/dist/jtcsv-core.esm.js +1379 -0
- package/dist/jtcsv-core.esm.js.map +1 -0
- package/dist/jtcsv-core.umd.js +1413 -0
- package/dist/jtcsv-core.umd.js.map +1 -0
- package/dist/jtcsv-full.cjs.js +1912 -0
- package/dist/jtcsv-full.cjs.js.map +1 -0
- package/dist/jtcsv-full.esm.js +1880 -0
- package/dist/jtcsv-full.esm.js.map +1 -0
- package/dist/jtcsv-full.umd.js +1918 -0
- package/dist/jtcsv-full.umd.js.map +1 -0
- package/dist/jtcsv-workers.esm.js +759 -0
- package/dist/jtcsv-workers.esm.js.map +1 -0
- package/dist/jtcsv-workers.umd.js +773 -0
- package/dist/jtcsv-workers.umd.js.map +1 -0
- package/dist/jtcsv.cjs.js +61 -19
- package/dist/jtcsv.cjs.js.map +1 -1
- package/dist/jtcsv.esm.js +61 -19
- package/dist/jtcsv.esm.js.map +1 -1
- package/dist/jtcsv.umd.js +61 -19
- package/dist/jtcsv.umd.js.map +1 -1
- package/errors.js +188 -2
- package/examples/advanced/conditional-transformations.js +446 -0
- package/examples/advanced/conditional-transformations.ts +446 -0
- package/examples/advanced/csv-parser.worker.js +89 -0
- package/examples/advanced/csv-parser.worker.ts +89 -0
- package/examples/advanced/nested-objects-example.js +306 -0
- package/examples/advanced/nested-objects-example.ts +306 -0
- package/examples/advanced/performance-optimization.js +504 -0
- package/examples/advanced/performance-optimization.ts +504 -0
- package/examples/advanced/run-demo-server.js +116 -0
- package/examples/advanced/run-demo-server.ts +116 -0
- package/examples/advanced/web-worker-usage.html +874 -0
- package/examples/async-multithreaded-example.ts +335 -0
- package/examples/cli-advanced-usage.md +288 -0
- package/examples/cli-batch-processing.ts +38 -0
- package/examples/cli-tool.js +0 -3
- package/examples/cli-tool.ts +183 -0
- package/examples/error-handling.js +21 -7
- package/examples/error-handling.ts +356 -0
- package/examples/express-api.js +0 -3
- package/examples/express-api.ts +164 -0
- package/examples/large-dataset-example.js +0 -3
- package/examples/large-dataset-example.ts +204 -0
- package/examples/ndjson-processing.js +1 -1
- package/examples/ndjson-processing.ts +456 -0
- package/examples/plugin-excel-exporter.js +3 -4
- package/examples/plugin-excel-exporter.ts +406 -0
- package/examples/react-integration.tsx +637 -0
- package/examples/schema-validation.ts +640 -0
- package/examples/simple-usage.js +254 -254
- package/examples/simple-usage.ts +194 -0
- package/examples/streaming-example.js +4 -5
- package/examples/streaming-example.ts +419 -0
- package/examples/web-workers-advanced.ts +28 -0
- package/index.d.ts +1 -3
- package/index.js +15 -1
- package/json-save.js +9 -3
- package/json-to-csv.js +168 -21
- package/package.json +69 -10
- package/plugins/express-middleware/README.md +21 -2
- package/plugins/express-middleware/example.js +3 -4
- package/plugins/express-middleware/example.ts +135 -0
- package/plugins/express-middleware/index.d.ts +1 -1
- package/plugins/express-middleware/index.js +270 -118
- package/plugins/express-middleware/index.ts +557 -0
- package/plugins/fastify-plugin/index.js +2 -4
- package/plugins/fastify-plugin/index.ts +443 -0
- package/plugins/hono/index.ts +226 -0
- package/plugins/nestjs/index.ts +201 -0
- package/plugins/nextjs-api/examples/ConverterComponent.tsx +386 -0
- package/plugins/nextjs-api/examples/api-convert.js +0 -2
- package/plugins/nextjs-api/examples/api-convert.ts +67 -0
- package/plugins/nextjs-api/index.tsx +339 -0
- package/plugins/nextjs-api/route.js +2 -3
- package/plugins/nextjs-api/route.ts +370 -0
- package/plugins/nuxt/index.ts +94 -0
- package/plugins/nuxt/runtime/composables/useJtcsv.ts +100 -0
- package/plugins/nuxt/runtime/plugin.ts +71 -0
- package/plugins/remix/index.js +1 -1
- package/plugins/remix/index.ts +260 -0
- package/plugins/sveltekit/index.js +1 -1
- package/plugins/sveltekit/index.ts +301 -0
- package/plugins/trpc/index.ts +267 -0
- package/src/browser/browser-functions.ts +402 -0
- package/src/browser/core.js +92 -0
- package/src/browser/core.ts +152 -0
- package/src/browser/csv-to-json-browser.d.ts +3 -0
- package/src/browser/csv-to-json-browser.js +36 -14
- package/src/browser/csv-to-json-browser.ts +264 -0
- package/src/browser/errors-browser.ts +303 -0
- package/src/browser/extensions/plugins.js +92 -0
- package/src/browser/extensions/plugins.ts +93 -0
- package/src/browser/extensions/workers.js +39 -0
- package/src/browser/extensions/workers.ts +39 -0
- package/src/browser/globals.d.ts +5 -0
- package/src/browser/index.ts +192 -0
- package/src/browser/json-to-csv-browser.d.ts +3 -0
- package/src/browser/json-to-csv-browser.js +13 -3
- package/src/browser/json-to-csv-browser.ts +262 -0
- package/src/browser/streams.js +12 -2
- package/src/browser/streams.ts +336 -0
- package/src/browser/workers/csv-parser.worker.ts +377 -0
- package/src/browser/workers/worker-pool.ts +548 -0
- package/src/core/delimiter-cache.js +22 -8
- package/src/core/delimiter-cache.ts +310 -0
- package/src/core/node-optimizations.ts +449 -0
- package/src/core/plugin-system.js +29 -11
- package/src/core/plugin-system.ts +400 -0
- package/src/core/transform-hooks.ts +558 -0
- package/src/engines/fast-path-engine-new.ts +347 -0
- package/src/engines/fast-path-engine.ts +854 -0
- package/src/errors.ts +72 -0
- package/src/formats/ndjson-parser.ts +469 -0
- package/src/formats/tsv-parser.ts +334 -0
- package/src/index-with-plugins.js +16 -9
- package/src/index-with-plugins.ts +395 -0
- package/src/types/index.ts +255 -0
- package/src/utils/bom-utils.js +259 -0
- package/src/utils/bom-utils.ts +373 -0
- package/src/utils/encoding-support.js +124 -0
- package/src/utils/encoding-support.ts +155 -0
- package/src/utils/schema-validator.js +19 -19
- package/src/utils/schema-validator.ts +819 -0
- package/src/utils/transform-loader.js +1 -1
- package/src/utils/transform-loader.ts +389 -0
- package/src/utils/zod-adapter.js +170 -0
- package/src/utils/zod-adapter.ts +280 -0
- package/src/web-server/index.js +10 -10
- package/src/web-server/index.ts +683 -0
- package/src/workers/csv-multithreaded.ts +310 -0
- package/src/workers/csv-parser.worker.ts +227 -0
- package/src/workers/worker-pool.ts +409 -0
- package/stream-csv-to-json.js +26 -8
- package/stream-json-to-csv.js +1 -0
package/examples/simple-usage.js
CHANGED
|
@@ -9,273 +9,273 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
;(async () => {
|
|
12
|
-
console.log('🚀 JTCSV 2.1.0 - Демонстрация новых возможностей\n');
|
|
13
|
-
|
|
14
|
-
// ============================================================================
|
|
15
|
-
// 1. Базовое использование (обратная совместимость)
|
|
16
|
-
// ============================================================================
|
|
17
|
-
|
|
18
|
-
console.log('1. 📦 Базовое использование (обратная совместимость)');
|
|
19
|
-
console.log('='.repeat(60));
|
|
20
|
-
|
|
21
|
-
const { jsonToCsv, csvToJson } = require('jtcsv');
|
|
22
|
-
|
|
23
|
-
const sampleData = [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
// Конвертация JSON → CSV
|
|
30
|
-
const csv = jsonToCsv(sampleData, { delimiter: ',' });
|
|
31
|
-
console.log('📄 CSV результат:');
|
|
32
|
-
console.log(csv);
|
|
33
|
-
console.log();
|
|
34
|
-
|
|
35
|
-
// Конвертация CSV → JSON
|
|
36
|
-
const json = csvToJson(csv, { delimiter: ',' });
|
|
37
|
-
console.log('📊 JSON результат:');
|
|
38
|
-
console.log(JSON.stringify(json, null, 2));
|
|
39
|
-
console.log();
|
|
40
|
-
|
|
41
|
-
// ============================================================================
|
|
42
|
-
// 2. Fast-Path Engine (оптимизированный парсинг)
|
|
43
|
-
// ============================================================================
|
|
44
|
-
|
|
45
|
-
console.log('\n2. ⚡ Fast-Path Engine (оптимизированный парсинг)');
|
|
46
|
-
console.log('='.repeat(60));
|
|
47
|
-
|
|
48
|
-
const FastPathEngine = require('../src/engines/fast-path-engine');
|
|
49
|
-
const engine = new FastPathEngine();
|
|
50
|
-
|
|
51
|
-
// Создаем тестовый CSV
|
|
52
|
-
let testCsv = 'id,name,description\n';
|
|
53
|
-
for (let i = 1; i <= 1000; i++) {
|
|
54
|
-
testCsv += `${i},User${i},"Description for user ${i}"\n`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
console.log('📊 Анализ структуры CSV...');
|
|
58
|
-
const sample = testCsv.substring(0, 500);
|
|
59
|
-
const structure = engine.analyzeStructure(sample);
|
|
60
|
-
console.log('Структура:', {
|
|
61
|
-
delimiter: structure.delimiter,
|
|
62
|
-
hasQuotes: structure.hasQuotes,
|
|
63
|
-
recommendedEngine: structure.recommendedEngine,
|
|
64
|
-
complexity: structure.complexity
|
|
65
|
-
});
|
|
12
|
+
console.log('🚀 JTCSV 2.1.0 - Демонстрация новых возможностей\n');
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// 1. Базовое использование (обратная совместимость)
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
console.log('1. 📦 Базовое использование (обратная совместимость)');
|
|
19
|
+
console.log('='.repeat(60));
|
|
20
|
+
|
|
21
|
+
const { jsonToCsv, csvToJson } = require('jtcsv');
|
|
22
|
+
|
|
23
|
+
const sampleData = [
|
|
24
|
+
{ id: 1, name: 'John Doe', age: 30, city: 'New York' },
|
|
25
|
+
{ id: 2, name: 'Jane Smith', age: 25, city: 'London' },
|
|
26
|
+
{ id: 3, name: 'Bob Johnson', age: 35, city: 'Tokyo' }
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
// Конвертация JSON → CSV
|
|
30
|
+
const csv = jsonToCsv(sampleData, { delimiter: ',' });
|
|
31
|
+
console.log('📄 CSV результат:');
|
|
32
|
+
console.log(csv);
|
|
33
|
+
console.log();
|
|
34
|
+
|
|
35
|
+
// Конвертация CSV → JSON
|
|
36
|
+
const json = csvToJson(csv, { delimiter: ',' });
|
|
37
|
+
console.log('📊 JSON результат:');
|
|
38
|
+
console.log(JSON.stringify(json, null, 2));
|
|
39
|
+
console.log();
|
|
66
40
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
console.log(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
console.log();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
console.log(
|
|
108
|
-
console.log(`
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// ============================================================================
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
41
|
+
// ============================================================================
|
|
42
|
+
// 2. Fast-Path Engine (оптимизированный парсинг)
|
|
43
|
+
// ============================================================================
|
|
44
|
+
|
|
45
|
+
console.log('\n2. ⚡ Fast-Path Engine (оптимизированный парсинг)');
|
|
46
|
+
console.log('='.repeat(60));
|
|
47
|
+
|
|
48
|
+
const FastPathEngine = require('../src/engines/fast-path-engine');
|
|
49
|
+
const engine = new FastPathEngine();
|
|
50
|
+
|
|
51
|
+
// Создаем тестовый CSV
|
|
52
|
+
let testCsv = 'id,name,description\n';
|
|
53
|
+
for (let i = 1; i <= 1000; i++) {
|
|
54
|
+
testCsv += `${i},User${i},"Description for user ${i}"\n`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
console.log('📊 Анализ структуры CSV...');
|
|
58
|
+
const sample = testCsv.substring(0, 500);
|
|
59
|
+
const structure = engine.analyzeStructure(sample);
|
|
60
|
+
console.log('Структура:', {
|
|
61
|
+
delimiter: structure.delimiter,
|
|
62
|
+
hasQuotes: structure.hasQuotes,
|
|
63
|
+
recommendedEngine: structure.recommendedEngine,
|
|
64
|
+
complexity: structure.complexity
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log('\n⚡ Парсинг 1000 строк с оптимизацией...');
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
const parsed = engine.parse(testCsv);
|
|
70
|
+
const duration = Date.now() - startTime;
|
|
71
|
+
|
|
72
|
+
console.log(`✅ Парсинг завершен за ${duration}ms`);
|
|
73
|
+
console.log(`📈 Скорость: ${Math.round(1000 / (duration / 1000))} строк/сек`);
|
|
74
|
+
console.log(`📊 Результат: ${parsed.length} строк (${parsed[0].length} колонок)`);
|
|
75
|
+
|
|
76
|
+
const stats = engine.getStats();
|
|
77
|
+
console.log('\n📊 Статистика Fast-Path Engine:');
|
|
78
|
+
console.log(` Simple парсеры: ${stats.simpleParserCount}`);
|
|
79
|
+
console.log(` Quote-aware парсеры: ${stats.quoteAwareParserCount}`);
|
|
80
|
+
console.log(` Cache hits: ${stats.cacheHits}`);
|
|
81
|
+
console.log(` Cache miss: ${stats.cacheMisses}`);
|
|
82
|
+
console.log(` Hit rate: ${(stats.hitRate * 100).toFixed(1)}%`);
|
|
83
|
+
|
|
84
|
+
// ============================================================================
|
|
85
|
+
// 3. NDJSON поддержка (потоковая обработка)
|
|
86
|
+
// ============================================================================
|
|
87
|
+
|
|
88
|
+
console.log('\n3. 📝 NDJSON поддержка (потоковая обработка)');
|
|
89
|
+
console.log('='.repeat(60));
|
|
90
|
+
|
|
91
|
+
const NdjsonParser = require('../src/formats/ndjson-parser');
|
|
92
|
+
|
|
93
|
+
// Конвертация в NDJSON
|
|
94
|
+
const ndjson = NdjsonParser.toNdjson(sampleData, { space: 2 });
|
|
95
|
+
console.log('📄 NDJSON результат:');
|
|
96
|
+
console.log(ndjson);
|
|
97
|
+
console.log();
|
|
98
|
+
|
|
99
|
+
// Обратная конвертация
|
|
100
|
+
const fromNdjson = NdjsonParser.fromNdjson(ndjson);
|
|
101
|
+
console.log('🔁 Обратная конвертация:');
|
|
102
|
+
console.log(JSON.stringify(fromNdjson, null, 2));
|
|
103
|
+
console.log();
|
|
104
|
+
|
|
105
|
+
// Статистика
|
|
106
|
+
const ndjsonStats = NdjsonParser.getStats(ndjson);
|
|
107
|
+
console.log('📊 Статистика NDJSON:');
|
|
108
|
+
console.log(` Строк: ${ndjsonStats.totalLines}`);
|
|
109
|
+
console.log(` Валидных: ${ndjsonStats.validLines}`);
|
|
110
|
+
console.log(` Успешность: ${ndjsonStats.successRate}%`);
|
|
111
|
+
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// 4. Plugin System (расширяемость)
|
|
114
|
+
// ============================================================================
|
|
115
|
+
|
|
116
|
+
console.log('\n4. 🔌 Plugin System (расширяемость)');
|
|
117
|
+
console.log('='.repeat(60));
|
|
118
|
+
|
|
119
|
+
const PluginManager = require('../src/core/plugin-system');
|
|
120
|
+
|
|
121
|
+
// Создаем простой плагин для логирования
|
|
122
|
+
const loggingPlugin = {
|
|
123
|
+
name: 'Logging Plugin',
|
|
124
|
+
version: '1.0.0',
|
|
125
|
+
description: 'Логирование операций конвертации',
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
hooks: {
|
|
128
|
+
'before:csvToJson': (csv, context) => {
|
|
129
|
+
console.log(` 📥 Начало csvToJson (${csv.length} байт)`);
|
|
130
|
+
return csv;
|
|
131
|
+
},
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
'after:csvToJson': (result, context) => {
|
|
134
|
+
console.log(` 📤 Завершение csvToJson (${result.length} записей)`);
|
|
135
|
+
return result;
|
|
136
|
+
},
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
'before:jsonToCsv': (json, context) => {
|
|
139
|
+
console.log(` 📥 Начало jsonToCsv (${json.length} записей)`);
|
|
140
|
+
return json;
|
|
141
|
+
},
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
'after:jsonToCsv': (csv, context) => {
|
|
144
|
+
console.log(` 📤 Завершение jsonToCsv (${csv.length} байт)`);
|
|
145
|
+
return csv;
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
// Создаем плагин для трансформации данных
|
|
161
|
-
const transformPlugin = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
149
|
+
middlewares: [
|
|
150
|
+
async (ctx, next) => {
|
|
151
|
+
console.log(` 🔄 Middleware: ${ctx.operation} начат`);
|
|
152
|
+
const start = Date.now();
|
|
153
|
+
await next();
|
|
154
|
+
const duration = Date.now() - start;
|
|
155
|
+
console.log(` ✅ Middleware: ${ctx.operation} завершен за ${duration}ms`);
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Создаем плагин для трансформации данных
|
|
161
|
+
const transformPlugin = {
|
|
162
|
+
name: 'Transform Plugin',
|
|
163
|
+
version: '1.0.0',
|
|
164
|
+
description: 'Трансформация данных перед обработкой',
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
hooks: {
|
|
167
|
+
'before:jsonToCsv': (json, context) => {
|
|
168
168
|
// Добавляем timestamp к каждой записи
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
return json.map(item => ({
|
|
170
|
+
...item,
|
|
171
|
+
processedAt: new Date().toISOString(),
|
|
172
|
+
processedBy: 'transform-plugin'
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
174
175
|
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
pluginManager.use('
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// Инициализируем менеджер плагинов
|
|
179
|
+
const pluginManager = new PluginManager();
|
|
180
|
+
pluginManager.use('logging', loggingPlugin);
|
|
181
|
+
pluginManager.use('transform', transformPlugin);
|
|
182
|
+
|
|
183
|
+
console.log('📋 Зарегистрированные плагины:');
|
|
184
|
+
pluginManager.listPlugins().forEach(plugin => {
|
|
185
|
+
console.log(` • ${plugin.name} v${plugin.version} - ${plugin.description}`);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
console.log('\n🔄 Выполнение с плагинами...');
|
|
189
|
+
|
|
190
|
+
// Основная функция для демонстрации
|
|
191
|
+
const processData = async () => {
|
|
192
|
+
const testJson = [
|
|
193
|
+
{ id: 1, value: 'test1' },
|
|
194
|
+
{ id: 2, value: 'test2' }
|
|
195
|
+
];
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
// Выполняем с плагинами
|
|
198
|
+
const result = await pluginManager.executeWithPlugins(
|
|
199
|
+
'jsonToCsv',
|
|
200
|
+
testJson,
|
|
201
|
+
{ delimiter: '|' },
|
|
202
|
+
(data, options) => {
|
|
203
203
|
// Имитация основной функции
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
const headers = Object.keys(data[0]);
|
|
205
|
+
const rows = data.map(item => headers.map(h => item[h]).join(options.delimiter));
|
|
206
|
+
return [headers.join(options.delimiter), ...rows].join('\n');
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
await processData();
|
|
215
|
-
|
|
216
|
-
// Статистика плагинов
|
|
217
|
-
const pluginStats = pluginManager.getStats();
|
|
218
|
-
console.log('\n📊 Статистика Plugin System:');
|
|
219
|
-
console.log(` Плагинов: ${pluginStats.plugins}`);
|
|
220
|
-
console.log(` Hooks выполнено: ${pluginStats.hookExecutions}`);
|
|
221
|
-
console.log(` Middleware выполнено: ${pluginStats.middlewareExecutions}`);
|
|
222
|
-
console.log(` Уникальных hooks: ${pluginStats.uniqueHooks}`);
|
|
223
|
-
|
|
224
|
-
// ============================================================================
|
|
225
|
-
// 5. JTCSV с плагинами (полная интеграция)
|
|
226
|
-
// ============================================================================
|
|
227
|
-
|
|
228
|
-
console.log('\n5. 🎯 JTCSV с плагинами (полная интеграция)');
|
|
229
|
-
console.log('='.repeat(60));
|
|
230
|
-
|
|
231
|
-
// Проверяем доступность полной интеграции
|
|
232
|
-
try {
|
|
233
|
-
|
|
210
|
+
console.log('\n📄 Результат с плагинами:');
|
|
211
|
+
console.log(result);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
await processData();
|
|
215
|
+
|
|
216
|
+
// Статистика плагинов
|
|
217
|
+
const pluginStats = pluginManager.getStats();
|
|
218
|
+
console.log('\n📊 Статистика Plugin System:');
|
|
219
|
+
console.log(` Плагинов: ${pluginStats.plugins}`);
|
|
220
|
+
console.log(` Hooks выполнено: ${pluginStats.hookExecutions}`);
|
|
221
|
+
console.log(` Middleware выполнено: ${pluginStats.middlewareExecutions}`);
|
|
222
|
+
console.log(` Уникальных hooks: ${pluginStats.uniqueHooks}`);
|
|
223
|
+
|
|
224
|
+
// ============================================================================
|
|
225
|
+
// 5. JTCSV с плагинами (полная интеграция)
|
|
226
|
+
// ============================================================================
|
|
227
|
+
|
|
228
|
+
console.log('\n5. 🎯 JTCSV с плагинами (полная интеграция)');
|
|
229
|
+
console.log('='.repeat(60));
|
|
230
|
+
|
|
231
|
+
// Проверяем доступность полной интеграции
|
|
232
|
+
try {
|
|
233
|
+
const JtcsvWithPlugins = require('../src/index-with-plugins');
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
} catch (error) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// ============================================================================
|
|
247
|
-
// Итоги
|
|
248
|
-
// ============================================================================
|
|
249
|
-
|
|
250
|
-
console.log('\n' + '='.repeat(60));
|
|
251
|
-
console.log('🎉 ДЕМОНСТРАЦИЯ ЗАВЕРШЕНА!');
|
|
252
|
-
console.log('='.repeat(60));
|
|
253
|
-
|
|
254
|
-
console.log('\n📈 ИТОГИ JTCSV 2.1.0:');
|
|
255
|
-
console.log('✅ Обратная совместимость с 2.0.0');
|
|
256
|
-
console.log('✅ Fast-Path Engine (до 3-4x быстрее)');
|
|
257
|
-
console.log('✅ NDJSON поддержка для потоковой обработки');
|
|
258
|
-
console.log('✅ Plugin System для расширяемости');
|
|
259
|
-
console.log('✅ Excel интеграция (через плагины)');
|
|
260
|
-
console.log('✅ Детальная статистика и мониторинг');
|
|
261
|
-
|
|
262
|
-
console.log('\n🚀 Следующие шаги:');
|
|
263
|
-
console.log('1. Изучите README-PLUGINS.md для подробной документации');
|
|
264
|
-
console.log('2. Запустите тесты: npm test');
|
|
265
|
-
console.log('3. Попробуйте примеры: npm run example:plugins');
|
|
266
|
-
console.log('4. Создайте свой плагин!');
|
|
267
|
-
|
|
268
|
-
console.log('\n💡 Совет: Для production используйте:');
|
|
269
|
-
console.log(' const jtcsv = require("jtcsv/plugins").create();');
|
|
270
|
-
console.log(' jtcsv.use("your-plugin", yourPluginConfig);');
|
|
271
|
-
|
|
272
|
-
console.log('\n📚 Документация: https://github.com/Linol-Hamelton/jtcsv');
|
|
273
|
-
console.log('🐛 Issues: https://github.com/Linol-Hamelton/jtcsv/issues');
|
|
274
|
-
console.log('⭐ Star на GitHub если понравилось!');
|
|
275
|
-
|
|
276
|
-
console.log('\n' + '✨'.repeat(30));
|
|
277
|
-
console.log('✨ JTCSV 2.1.0 - Next Generation JSON/CSV Converter ✨');
|
|
278
|
-
console.log('✨'.repeat(30));
|
|
235
|
+
console.log('✅ Полная интеграция доступна');
|
|
236
|
+
console.log('Запустите для полной демонстрации:');
|
|
237
|
+
console.log(' npm run example:plugins');
|
|
238
|
+
console.log('\nИли посмотрите пример:');
|
|
239
|
+
console.log(' examples/plugin-excel-exporter.js');
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.log('⚠️ Полная интеграция требует дополнительных зависимостей');
|
|
242
|
+
console.log('Установите @jtcsv/excel и exceljs для демонстрации Excel плагина:');
|
|
243
|
+
console.log(' npm install @jtcsv/excel exceljs');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ============================================================================
|
|
247
|
+
// Итоги
|
|
248
|
+
// ============================================================================
|
|
249
|
+
|
|
250
|
+
console.log('\n' + '='.repeat(60));
|
|
251
|
+
console.log('🎉 ДЕМОНСТРАЦИЯ ЗАВЕРШЕНА!');
|
|
252
|
+
console.log('='.repeat(60));
|
|
253
|
+
|
|
254
|
+
console.log('\n📈 ИТОГИ JTCSV 2.1.0:');
|
|
255
|
+
console.log('✅ Обратная совместимость с 2.0.0');
|
|
256
|
+
console.log('✅ Fast-Path Engine (до 3-4x быстрее)');
|
|
257
|
+
console.log('✅ NDJSON поддержка для потоковой обработки');
|
|
258
|
+
console.log('✅ Plugin System для расширяемости');
|
|
259
|
+
console.log('✅ Excel интеграция (через плагины)');
|
|
260
|
+
console.log('✅ Детальная статистика и мониторинг');
|
|
261
|
+
|
|
262
|
+
console.log('\n🚀 Следующие шаги:');
|
|
263
|
+
console.log('1. Изучите README-PLUGINS.md для подробной документации');
|
|
264
|
+
console.log('2. Запустите тесты: npm test');
|
|
265
|
+
console.log('3. Попробуйте примеры: npm run example:plugins');
|
|
266
|
+
console.log('4. Создайте свой плагин!');
|
|
267
|
+
|
|
268
|
+
console.log('\n💡 Совет: Для production используйте:');
|
|
269
|
+
console.log(' const jtcsv = require("jtcsv/plugins").create();');
|
|
270
|
+
console.log(' jtcsv.use("your-plugin", yourPluginConfig);');
|
|
271
|
+
|
|
272
|
+
console.log('\n📚 Документация: https://github.com/Linol-Hamelton/jtcsv');
|
|
273
|
+
console.log('🐛 Issues: https://github.com/Linol-Hamelton/jtcsv/issues');
|
|
274
|
+
console.log('⭐ Star на GitHub если понравилось!');
|
|
275
|
+
|
|
276
|
+
console.log('\n' + '✨'.repeat(30));
|
|
277
|
+
console.log('✨ JTCSV 2.1.0 - Next Generation JSON/CSV Converter ✨');
|
|
278
|
+
console.log('✨'.repeat(30));
|
|
279
279
|
})().catch((error) => {
|
|
280
280
|
console.error('Demo failed:', error);
|
|
281
281
|
process.exitCode = 1;
|