lib/packs.js
function (baseUrl, cardsDirectory) {
    var packs = _.filter(FS.readdirSync(cardsDirectory), function (dir) { return _.startsWith(dir, 'hashdo-'); });
      
    console.log('PACKS: Cards will be loaded from %s.', cardsDirectory);
    
    var packCounter = 0,
      cardCounter = 0,
      hiddenCounter = 0;

    for (var i = 0; i < packs.length; i++) {
      var isPackage = false,
        packDir = Path.join(cardsDirectory, packs[i]);
      
      // Check if the directory has a package.json file, otherwise ignore it, it's not a pack.
      try {
        FS.statSync(Path.join(packDir, 'package.json'));
        isPackage = true;
      }
      catch (err) {}
      
      if (isPackage) {
        var packageJson = FS.readFileSync(Path.join(packDir, 'package.json')),
          packageInfo = JSON.parse(packageJson.toString()),
          packInfo = packageInfo.pack,
          packCardsDir = Path.join(cardsDirectory, packs[i]),
          packCards = getPackCardFiles(packCardsDir),
          packName = packageInfo.name.replace('hashdo-', '');
    
        if (packInfo) {
          packCounter++;
          
          if (!packInfo.hidden) {
            cardPacks[packName] = { 
              name: packInfo.friendlyName,
              cards: {}
            };
        
            for (var j = 0; j < packCards.length; j++) {
              var card = require(Path.join(packCardsDir, packCards[j])),
                cardName = packCards[j];
      
              cardCounter++;
              cardPacks[packName].cards[cardName] = {
                pack: packName,
                card: cardName,
                name: card.name,
                description: card.description || '',
                icon: card.icon || _.trimEnd(baseUrl, '/') + '/' + packName + '/' + cardName + '/icon.png',
                baseUrl: _.trimEnd(baseUrl, '/') + '/' + packName + '/' + cardName,
                inputs: card.inputs
              };
            }
          }
          else {
            hiddenCounter++;
          }
        }
      }
    }
    
    console.log('PACKS: %d packs and %d card(s) have been loaded (%d hidden).', packCounter, cardCounter, hiddenCounter);
  }
function (baseUrl, cardsDirectory) {
    var packs = _.filter(FS.readdirSync(cardsDirectory), function (dir) { return _.startsWith(dir, 'hashdo-'); });
      
    console.log('PACKS: Cards will be loaded from %s.', cardsDirectory);
    
    var packCounter = 0,
      cardCounter = 0,
      hiddenCounter = 0;

    for (var i = 0; i < packs.length; i++) {
      var isPackage = false,
        packDir = Path.join(cardsDirectory, packs[i]);
      
      // Check if the directory has a package.json file, otherwise ignore it, it's not a pack.
      try {
        FS.statSync(Path.join(packDir, 'package.json'));
        isPackage = true;
      }
      catch (err) {}
      
      if (isPackage) {
        var packageJson = FS.readFileSync(Path.join(packDir, 'package.json')),
          packageInfo = JSON.parse(packageJson.toString()),
          packInfo = packageInfo.pack,
          packCardsDir = Path.join(cardsDirectory, packs[i]),
          packCards = getPackCardFiles(packCardsDir),
          packName = packageInfo.name.replace('hashdo-', '');
    
        if (packInfo) {
          packCounter++;
          
          if (!packInfo.hidden) {
            cardPacks[packName] = { 
              name: packInfo.friendlyName,
              cards: {}
            };
        
            for (var j = 0; j < packCards.length; j++) {
              var card = require(Path.join(packCardsDir, packCards[j])),
                cardName = packCards[j];
      
              cardCounter++;
              cardPacks[packName].cards[cardName] = {
                pack: packName,
                card: cardName,
                name: card.name,
                description: card.description || '',
                icon: card.icon || _.trimEnd(baseUrl, '/') + '/' + packName + '/' + cardName + '/icon.png',
                baseUrl: _.trimEnd(baseUrl, '/') + '/' + packName + '/' + cardName,
                inputs: card.inputs
              };
            }
          }
          else {
            hiddenCounter++;
          }
        }
      }
    }
    
    console.log('PACKS: %d packs and %d card(s) have been loaded (%d hidden).', packCounter, cardCounter, hiddenCounter);
  }
function ( baseUrl , cardsDirectory ) { var packs = _ . filter ( FS . readdirSync ( cardsDirectory ) , function ( dir ) { return _ . startsWith ( dir , 'hashdo-' ) ; } ) ; console . log ( 'PACKS: Cards will be loaded from %s.' , cardsDirectory ) ; var packCounter = 0 , cardCounter = 0 , hiddenCounter = 0 ; for ( var i = 0 ; i < packs . length ; i ++ ) { var isPackage = false , packDir = Path . join ( cardsDirectory , packs [ i ] ) ; // Check if the directory has a package.json file, otherwise ignore it, it's not a pack. try { FS . statSync ( Path . join ( packDir , 'package.json' ) ) ; isPackage = true ; } catch ( err ) { } if ( isPackage ) { var packageJson = FS . readFileSync ( Path . join ( packDir , 'package.json' ) ) , packageInfo = JSON . parse ( packageJson . toString ( ) ) , packInfo = packageInfo . pack , packCardsDir = Path . join ( cardsDirectory , packs [ i ] ) , packCards = getPackCardFiles ( packCardsDir ) , packName = packageInfo . name . replace ( 'hashdo-' , '' ) ; if ( packInfo ) { packCounter ++ ; if ( ! packInfo . hidden ) { cardPacks [ packName ] = { name : packInfo . friendlyName , cards : { } } ; for ( var j = 0 ; j < packCards . length ; j ++ ) { var card = require ( Path . join ( packCardsDir , packCards [ j ] ) ) , cardName = packCards [ j ] ; cardCounter ++ ; cardPacks [ packName ] . cards [ cardName ] = { pack : packName , card : cardName , name : card . name , description : card . description || '' , icon : card . icon || _ . trimEnd ( baseUrl , '/' ) + '/' + packName + '/' + cardName + '/icon.png' , baseUrl : _ . trimEnd ( baseUrl , '/' ) + '/' + packName + '/' + cardName , inputs : card . inputs } ; } } else { hiddenCounter ++ ; } } } } console . log ( 'PACKS: %d packs and %d card(s) have been loaded (%d hidden).' , packCounter , cardCounter , hiddenCounter ) ; }
Initializes and caches the packs and card data.
This function should be called before any other functions in the packs API.

@method init
@param {String}  baseUrl         The protocol and host name where your cards are being hosted. Eg: https://hashdo.com
@param {String}  cardsDirectory  The directory where you packs and cards can be found and loaded from.
Initializes and caches the packs and card data . This function should be called before any other functions in the packs API .