4get.js
/**
 * This follows the observer design pattern. We take arguments first from options, then argv then resort to defaults
 * @constructor
 */
This follows the observer design pattern. We take arguments first from options, then argv then resort to defaults
@constructor
This follows the observer design pattern . We take arguments first from options then argv then resort to defaults @constructor
function Fourget(options) {
	options = options || {};
	this.url = options.url || process.argv[2] || false;
	this.workers = options.workers || process.argv[3] || require('os').cpus().length;
	this.concurrentDownloads = options.concurrentDownloads || process.argv[4] || 8;
	this.retryEvery = 30e3; 
	this.useOriginal = true; 
	if (this.workers > 4)
		this.workers = 4;
	if (this.workers > this.concurrentDownloads)
		this.concurrentDownloads = this.workers;
	this._dir = process.cwd() + path.sep;
	this._files = [];
	this._workersFinished = 0;
	this._runEvery = 0;
	this._watch = true;
	this._downloaded = 0;
	this._startTime = new Date().getTime();
	this._ignoreOriginalFileName = ['image.jpg','image.png','image.gif','image.webm'];
	EventEmitter.call(this);
}
function Fourget ( options ) { options = options || { } ; this . url = options . url || process . argv [ 2 ] || false ; this . workers = options . workers || process . argv [ 3 ] || require ( 'os' ) . cpus ( ) . length ; this . concurrentDownloads = options . concurrentDownloads || process . argv [ 4 ] || 8 ; this . retryEvery = 30e3 ; this . useOriginal = true ; if ( this . workers > 4 ) this . workers = 4 ; if ( this . workers > this . concurrentDownloads ) this . concurrentDownloads = this . workers ; this . _dir = process . cwd ( ) + path . sep ; this . _files = [ ] ; this . _workersFinished = 0 ; this . _runEvery = 0 ; this . _watch = true ; this . _downloaded = 0 ; this . _startTime = new Date ( ) . getTime ( ) ; this . _ignoreOriginalFileName = [ 'image.jpg' , 'image.png' , 'image.gif' , 'image.webm' ] ; EventEmitter . call ( this ) ; }
This follows the observer design pattern.
This follows the observer design pattern .
// 30 secs // use original names // hard limit, feel free to remove this, but I find anymore than 4 is overkill // No point having workers that do nothing, so set the no. of concurrent downloads to match the no. of workers // internal variables /**
	 * If an image is called image.jpg we will use the 4chan generated filename.
	 * Many 4chan mobile apps default the upload image filename to image.jpg.
	 */