index.js
function(seriesCallback) {
                async.eachLimit(groupedPinIds, 50, function(groupOfPinIds, eachCallback) {
                    var pinIdsString = groupOfPinIds.join(',');
                    getCache(pinIdsString, true, function (cacheData) {
                        if (cacheData === null) {
                            get('http://api.pinterest.com/v3/pidgets/pins/info/?pin_ids=' + pinIdsString, true, function (response) {
                                putCache(pinIdsString, JSON.stringify(response));
                                allPinsData = allPinsData.concat(response.data ? response.data : []);
                                eachCallback();
                                return;
                            });
                        } else {
                            allPinsData = allPinsData.concat(cacheData.data ? cacheData.data : []);
                            eachCallback();
                            return;
                        }
                    });
                }, function (err) {
                    if(err) {
                        throw err;
                    }
                    seriesCallback();
                    return;
                });             
            }
function(seriesCallback) {
                async.eachLimit(groupedPinIds, 50, function(groupOfPinIds, eachCallback) {
                    var pinIdsString = groupOfPinIds.join(',');
                    getCache(pinIdsString, true, function (cacheData) {
                        if (cacheData === null) {
                            get('http://api.pinterest.com/v3/pidgets/pins/info/?pin_ids=' + pinIdsString, true, function (response) {
                                putCache(pinIdsString, JSON.stringify(response));
                                allPinsData = allPinsData.concat(response.data ? response.data : []);
                                eachCallback();
                                return;
                            });
                        } else {
                            allPinsData = allPinsData.concat(cacheData.data ? cacheData.data : []);
                            eachCallback();
                            return;
                        }
                    });
                }, function (err) {
                    if(err) {
                        throw err;
                    }
                    seriesCallback();
                    return;
                });             
            }
function ( seriesCallback ) { async . eachLimit ( groupedPinIds , 50 , function ( groupOfPinIds , eachCallback ) { var pinIdsString = groupOfPinIds . join ( ',' ) ; getCache ( pinIdsString , true , function ( cacheData ) { if ( cacheData === null ) { get ( 'http://api.pinterest.com/v3/pidgets/pins/info/?pin_ids=' + pinIdsString , true , function ( response ) { putCache ( pinIdsString , JSON . stringify ( response ) ) ; allPinsData = allPinsData . concat ( response . data ? response . data : [ ] ) ; eachCallback ( ) ; return ; } ) ; } else { allPinsData = allPinsData . concat ( cacheData . data ? cacheData . data : [ ] ) ; eachCallback ( ) ; return ; } } ) ; } , function ( err ) { if ( err ) { throw err ; } seriesCallback ( ) ; return ; } ) ; }
get pin data from API
get pin data from API