w.cacheInit = function () {
     this.discoverListElement = _.memoize(this._discoverListElement);
     this.discoverListName = _.memoize(this._discoverListName);
     this.discoverListType = _.memoize(this._discoverListType);
     this.discoverListItemsElement =
         _.memoize(this._discoverListItemsElement);
 };
Example #2
0
Git.init = function (rootPath) {
  this.rootPath = rootPath;
  if (!this.rootPath || this.rootPath.length === 0) {
    console.error('You probably don\'t mean to set rootPath to ' + this.rootPath);
    process.exit(1);
  }
  this.ready = async.memoize(readyGen(this));
  this.repo = _.memoize(getRepoGen(this));
};
Example #3
0
  return function (cb) {
    exec('mkdir', ['-p', self.rootPath], { cwd: './' }, function() {
      cb(null, self);
    });
  };
}

function getRepoGen (self) {
  return function (url) {
    var shasum = crypto.createHash('sha1');
    var urlSafe = crypto.createHash('sha1').update(url).digest('hex');
    var repoPath = path.join(self.rootPath, urlSafe);
    return Repo.make(self, repoPath, url);
  };
}

function getGit(tmpDir) {
  return Git.make(tmpDir || 'gitfs-var/');
}
var getGitMemo = _.memoize(getGit);

// By default, gitfs will just use the gitfs-var subdirectory
// of the working directory.
module.exports = getGitMemo();

// You can specify your own working folder using
// `var gitfs = require('gitfs').workspace('some/other/folder');`
module.exports.workspace = getGitMemo;

module.exports.workspaceNoMemo = getGit;
Example #4
0
  // remove the argument 'this' from our list of passed arguments, because it is a reserved word
  functionArgs.splice(functionArgs.indexOf('this'), 1);

  functionArgs.push(this.scriptSourceCode);
  var func = this.getFunction(functionArgs);

  // pass our arguments from the sandbox to the function
  var args = [];
  functionArgs.forEach(function (p) {
    args.push(context[p]);
  });
  return func.apply(context._this || {}, args);
};

Script.prototype.getFunction = _.memoize(function(functionArgs) {
  return Function.apply(null, functionArgs);
});

/**
 * Run the current script in the given sandbox. An optional domain may be provided to extend the sandbox exposed to the script.
 */

Script.prototype.run = function (ctx, domain, fn) {

  if (this.error) { fn(this.error); }

  if(typeof domain === 'function') {
    fn = domain;
    domain = undefined;
  }