Class: DataToFile

DataToFile

Record input frames into a file.

Constructor

new DataToFile(options)

Parameters:
Name Type Description
options Object

Override default parameters.

Properties
Name Type Attributes Default Description
filename String <optional>
null

Path of the output file.

format String <optional>
'txt'

Format in which the data should be stored. Available options: 'txt', 'json' or 'csv'.

Source:
To Do:
  • - add an option to store the `streamParams`
Example
import path from 'path';
import EventIn from '../src/common/source/EventIn';
import Logger from '../src/common/sink/Logger';
import DataToFile from '../src/node/sink/DataToFile';

const eventIn = new EventIn({
  frameSize: 2,
  frameRate: 1,
  frameType: 'vector',
});

const dataToFile = new DataToFile({
  filename: path.join(__dirname, './node_sink.DataToFile.test.json'),
  format: 'json',
});

const logger = new Logger({
  data: true,
});

eventIn.connect(logger);
eventIn.connect(dataToFile);
eventIn.start();

let time = 0;
const period = 1;

(function loop(){
  const data = [Math.random(), Math.random()];
  eventIn.process(time, data);

  time += period;

  if (time < 20)
    setTimeout(loop, 300);
  else
    eventIn.stop();
}());