modules/feedRSSAtom.js
function callbackParser(err, out) {
	if (err) {
		error += err + '\n\n';
	} else {
		results[counter] = out;
	}

	counter++;
	if (counter === urlLength) {
		let result = {sources: [], feeds: []};
		let i = 0;
		_.each(results, feed => {
			feed.metadata.lastBuildDate = moment(feed.metadata.lastBuildDate).format('x');
			feed.metadata.update = moment(feed.metadata.update).format('x');
			result.sources.push({type: feed.type, metadata: feed.metadata});
			_.each(feed.items, function (item) {
				item.source = i;
				result.feeds.push(item);
			});
			i++;
		});

		// Sort value
		switch (allowSortValue[sortByDate]) {
			case allowSortValue.asc:
				result.feeds.sort((a, b) => (a.date > b.date) ? 1 : ((b.date > a.date) ? -1 : 0));
				break;
			case allowSortValue.desc:
				result.feeds.sort((a, b) => (a.date < b.date) ? 1 : ((b.date < a.date) ? -1 : 0));
				break;
			default:
				break;
		}

		if (error !== '') {
			finishCallback(error);
		} else {
			finishCallback(null, {feedRSSAtom: result});
		}
	}
}
function callbackParser(err, out) {
	if (err) {
		error += err + '\n\n';
	} else {
		results[counter] = out;
	}

	counter++;
	if (counter === urlLength) {
		let result = {sources: [], feeds: []};
		let i = 0;
		_.each(results, feed => {
			feed.metadata.lastBuildDate = moment(feed.metadata.lastBuildDate).format('x');
			feed.metadata.update = moment(feed.metadata.update).format('x');
			result.sources.push({type: feed.type, metadata: feed.metadata});
			_.each(feed.items, function (item) {
				item.source = i;
				result.feeds.push(item);
			});
			i++;
		});

		// Sort value
		switch (allowSortValue[sortByDate]) {
			case allowSortValue.asc:
				result.feeds.sort((a, b) => (a.date > b.date) ? 1 : ((b.date > a.date) ? -1 : 0));
				break;
			case allowSortValue.desc:
				result.feeds.sort((a, b) => (a.date < b.date) ? 1 : ((b.date < a.date) ? -1 : 0));
				break;
			default:
				break;
		}

		if (error !== '') {
			finishCallback(error);
		} else {
			finishCallback(null, {feedRSSAtom: result});
		}
	}
}
function callbackParser ( err , out ) { if ( err ) { error += err + '\n\n' ; } else { results [ counter ] = out ; } counter ++ ; if ( counter === urlLength ) { let result = { sources : [ ] , feeds : [ ] } ; let i = 0 ; _ . each ( results , feed => { feed . metadata . lastBuildDate = moment ( feed . metadata . lastBuildDate ) . format ( 'x' ) ; feed . metadata . update = moment ( feed . metadata . update ) . format ( 'x' ) ; result . sources . push ( { type : feed . type , metadata : feed . metadata } ) ; _ . each ( feed . items , function ( item ) { item . source = i ; result . feeds . push ( item ) ; } ) ; i ++ ; } ) ; // Sort value switch ( allowSortValue [ sortByDate ] ) { case allowSortValue . asc : result . feeds . sort ( ( a , b ) => ( a . date > b . date ) ? 1 : ( ( b . date > a . date ) ? - 1 : 0 ) ) ; break ; case allowSortValue . desc : result . feeds . sort ( ( a , b ) => ( a . date < b . date ) ? 1 : ( ( b . date < a . date ) ? - 1 : 0 ) ) ; break ; default : break ; } if ( error !== '' ) { finishCallback ( error ) ; } else { finishCallback ( null , { feedRSSAtom : result } ) ; } } }
Callback call when parser is finished
@param err {string} Error reported
@param out {json} Data returned
Callback call when parser is finished