@strong-roots-capital/random-record-stream
v1.0.1
Published
Create a Readable stream of random records
Downloads
3
Readme
random-record-stream
Create a Readable stream of random records
Install
npm install @strong-roots-capital/random-record-stream
Use
import randomRecordStream from '@strong-roots-capital/random-record-stream'
import Record from 'timeseries-record'
import moment from 'moment'
let records: Record[] = []
const sink = new Writable({
objectMode: true,
write(record: Record, _: any, callback: any) {
records.push(record)
callback()
}
})
const start = moment.utc().startOf('year')
const end = moment.utc().startOf('day')
randomRecordStream(start.toDate(), end.toDate()).pipe(sink)
sink.on('finish', () => {
console.log('Records streamed:')
console.log(records)
})