This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var Readable = require('stream').Readable; | |
/** | |
* Create a stream from batching a Sequelize select query. | |
* | |
* @param {Function} query - Function that returns a promise. | |
* @param {object} options | |
* @param {number} options.limit - The limit for the number of rows to return in each "batch" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SafeObserver { | |
constructor(private _next: (value: any) => void = () => {}, | |
public error: (errorValue: any) => void = (e: any) => { throw e; }, | |
private _complete: (completeValue?: any) => void = () => {}) {} | |
public next(value: any) { | |
try { | |
this._next(value); | |
} | |
catch (e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PrimaryGeneratedColumn, Entity, Column } from 'typeorm'; | |
@Entity('foo') | |
export class Foo { | |
@PrimaryGeneratedColumn() | |
public id: number; | |
@Column({ default: '' }) | |
public get link(): string { | |
let value = this._link; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { parse } from 'csv-parse' | |
import fs from 'fs' | |
import { pipeline } from 'stream/promises' | |
/** | |
* Do something async with a row. | |
* | |
* @param {*} row A row of the CSV as an object. | |
*/ | |
async function handleRow(row) { |
OlderNewer