billboard-top-100.js
function listCharts(cb) {
	if (typeof cb !== 'function') {
		cb('Specified callback is not a function.', null);
		return;
	}
	request(BILLBOARD_CHARTS_URL, function completedRequest(error, response, html) {
		if (error) {
			cb(error, null);
			return;
		}
		var $ = cheerio.load(html);
		/**
		 * A chart
		 * @typedef {Object} Chart
		 * @property {string} name - The name of the chart
		 * @property {string} url - The url of the chat
		 */

		/**
		 * Array of charts
		 */
		var charts = [];
		// push charts into charts array
		$('.chart-panel__link').each(function(index, item) {
			var chart = {};
			chart.name = toTitleCase($(this)[0].attribs.href.replace('/charts/', '').replace(/-/g, ' '));
			chart.url = "https://www.billboard.com" + $(this)[0].attribs.href;
			charts.push(chart);
		});
		// callback with charts if charts array was populated
		if (charts.length > 0){
			cb(null, charts);
			return;
		} else {
			cb("No charts found.", null);
			return;
		}
	});
}
function listCharts(cb) {
	if (typeof cb !== 'function') {
		cb('Specified callback is not a function.', null);
		return;
	}
	request(BILLBOARD_CHARTS_URL, function completedRequest(error, response, html) {
		if (error) {
			cb(error, null);
			return;
		}
		var $ = cheerio.load(html);
		/**
		 * A chart
		 * @typedef {Object} Chart
		 * @property {string} name - The name of the chart
		 * @property {string} url - The url of the chat
		 */

		/**
		 * Array of charts
		 */
		var charts = [];
		// push charts into charts array
		$('.chart-panel__link').each(function(index, item) {
			var chart = {};
			chart.name = toTitleCase($(this)[0].attribs.href.replace('/charts/', '').replace(/-/g, ' '));
			chart.url = "https://www.billboard.com" + $(this)[0].attribs.href;
			charts.push(chart);
		});
		// callback with charts if charts array was populated
		if (charts.length > 0){
			cb(null, charts);
			return;
		} else {
			cb("No charts found.", null);
			return;
		}
	});
}
function listCharts ( cb ) { if ( typeof cb !== 'function' ) { cb ( 'Specified callback is not a function.' , null ) ; return ; } request ( BILLBOARD_CHARTS_URL , function completedRequest ( error , response , html ) { if ( error ) { cb ( error , null ) ; return ; } var $ = cheerio . load ( html ) ; /**
		 * A chart
		 * @typedef {Object} Chart
		 * @property {string} name - The name of the chart
		 * @property {string} url - The url of the chat
		 */ /**
		 * Array of charts
		 */ var charts = [ ] ; // push charts into charts array $ ( '.chart-panel__link' ) . each ( function ( index , item ) { var chart = { } ; chart . name = toTitleCase ( $ ( this ) [ 0 ] . attribs . href . replace ( '/charts/' , '' ) . replace ( / - / g , ' ' ) ) ; chart . url = "https://www.billboard.com" + $ ( this ) [ 0 ] . attribs . href ; charts . push ( chart ) ; } ) ; // callback with charts if charts array was populated if ( charts . length > 0 ) { cb ( null , charts ) ; return ; } else { cb ( "No charts found." , null ) ; return ; } } ) ; }
Gets all charts available via Billboard

@param {string} chart - The specified chart
@param {string} date - Date represented as string in format 'YYYY-MM-DD'
@param {function} cb - The specified callback method

@example

listCharts(function(err, charts) {...})
Gets all charts available via Billboard