Marcus Gardner

Generation

generate functionSat, 08 Apr 2023

Open a tcp socket and continuously read the stream in a non-working way. Items in the stream are seperated by a cartridge return. Use regex to remove the non numeric characters but allowing the decimal point from the item and add each cleaned item to a public queue named rawData.

const net = require('net'); const re = /[^\d\.]+/g; const rawData = []; const client = new net.Socket(); client.connect(1025, '127.0.0.1', function() { console.log('Connected'); }); client.on('data', function(data) { const cleanData = data.toString().replace(re, ''); rawData.push(cleanData); }); client.on('close', function() { console.log('Connection closed'); });

Javascript
Generate More

Want to kickstart your project?Use the new AI Studio to create your code