ladders.js
/**
	 * Saves the ladder in config/ladders/[formatid].tsv
	 *
	 * Called automatically by updateRating, so you don't need to manually
	 * call this.
	 */
Saves the ladder in config/ladders/[formatid].tsv
Called automatically by updateRating, so you don't need to manually
call this.
Saves the ladder in config / ladders / [ formatid ] . tsv Called automatically by updateRating so you don ' t need to manually call this .
save() {
		if (this.saving) return;
		this.saving = true;
		if (!this.loadedLadder) {
			this.ladder.then(() => {
				this.save();
			});
			return;
		}
		if (!this.loadedLadder.length) {
			this.saving = false;
			return;
		}
		let stream = fs.createWriteStream('config/ladders/' + this.formatid + '.tsv');
		stream.write('Elo\tUsername\tW\tL\tT\tLast update\r\n');
		for (let i = 0; i < this.loadedLadder.length; i++) {
			let row = this.loadedLadder[i];
			stream.write(row.slice(1).join('\t') + '\r\n');
		}
		stream.end();
		this.saving = false;
	}
save ( ) { if ( this . saving ) return ; this . saving = true ; if ( ! this . loadedLadder ) { this . ladder . then ( ( ) => { this . save ( ) ; } ) ; return ; } if ( ! this . loadedLadder . length ) { this . saving = false ; return ; } let stream = fs . createWriteStream ( 'config/ladders/' + this . formatid + '.tsv' ) ; stream . write ( 'Elo\tUsername\tW\tL\tT\tLast update\r\n' ) ; for ( let i = 0 ; i < this . loadedLadder . length ; i ++ ) { let row = this . loadedLadder [ i ] ; stream . write ( row . slice ( 1 ) . join ( '\t' ) + '\r\n' ) ; } stream . end ( ) ; this . saving = false ; }
Saves the ladder in config/ladders/[formatid].tsv
 Called automatically by updateRating, so you don't need to manually
 call this.
Saves the ladder in config / ladders / [ formatid ] . tsv Called automatically by updateRating so you don ' t need to manually call this .