let chunksMerge = '{"1": "1"}'
let indexSymbol = 0;
let isValueScan = false;
let isEscape = false;
let objStr = '';
let indexLast = 0;
for (const symbol of str) {
indexSymbol += 1;
objStr += symbol;
if (isValueScan && (isEscape || symbol === '\\')) {
isEscape = !isEscape;
} else {
if (symbol === '"') isValueScan = !isValueScan;
if (isValueScan === false && symbol === '{') objStr = symbol;
if (isValueScan === false && symbol === '}') {
const json = (indexRecord === 1 ? '' : ',\n') + objStr;
const buffer = Buffer.from(json);
await writeStream.write(buffer);
indexRecord = +1;
JSON.parse(objStr);
indexLast = indexSymbol;
objStr = '';
}
}
}
chunksMerge = chunksMerge.slice(indexLast);
version: '3.8'
services:
server:
image: node:15.5.0
command: >
bash -c "
cd /app
&& npm install --production
&& node index.js"
ports:
- "127.0.0.1:3001:3001"
volumes:
- ./:/app
env_file: .env
depends_on:
- db
db:
image: postgres:13.1-alpine
ports:
- "127.0.0.1:5432:5432"
volumes:
- db:/var/lib/postgresql/data
environment:
POSTGRES_USER: $DB_USER
POSTGRES_PASSWORD: $DB_PASSWORD
POSTGRES_DB: $DB_NAME
volumes:
db: