var async = require('async'); var semver = require('semver'); var UError = require('./error').UserError; var Local = require('./st-local'); var Proxy = require('./st-proxy'); var utils = require('./utils'); function Storage(config) { if (!(this instanceof Storage)) return new Storage(config); this.config = config; this.uplinks = {}; for (var p in config.uplinks) { this.uplinks[p] = new Proxy(p, config); } this.local = new Local(config); return this; } Storage.prototype.add_package = function(name, metadata, callback) { var self = this; var uplinks = []; for (var i in this.uplinks) { if (this.config.allow_proxy(name, i)) { uplinks.push(this.uplinks[i]); } } async.map(uplinks, function(up, cb) { up.get_package(name, function(err, res) { cb(null, [err, res]); }); }, function(err, results) { for (var i=0; i