How to use the underscore.extend function in underscore

To help you get started, we’ve selected a few underscore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mrodrig / json-2-csv / test / testQuoted.js View on Github external
it('should parse the specified keys to CSV', function (done) {
                // Create a copy so we don't modify the actual options object
                var opts = _.extend(JSON.parse(JSON.stringify(options)), {KEYS: ['info.name', 'year']});
                converter.json2csv(json_arrayValue, function (err, csv) {
                    csv.should.equal(csv_arrayValue_specificKeys);
                    csv.split(options.EOL).length.should.equal(5);
                    done();
                }, opts);
            });
github ironbane / IronbaneServerLegacy / src / server / game / world / worldHandler.js View on Github external
doFullBackup: function() {
        chatHandler.announceRoom('mods', "Backing up server...", "blue");

        var deploySh = spawn('sh', [ 'serverbackup.sh' ], {
          //cwd: process.env.HOME + '/myProject',
          cwd: '/root',
          env:_.extend(process.env, {
            PATH: process.env.PATH + ':/usr/local/bin'
          })
        });

        deploySh.stderr.on('data', function (data) {
          chatHandler.announceRoom('mods', data, "red");
          //console.log('stderr: ' + data);
        });

        // handle error so server doesn't crash...
        deploySh.on('error', function(err) {
            log('Error doing full backup!', err);
        });

        deploySh.on('exit', function (code) {
            chatHandler.announceRoom('mods', "Backup complete!", "blue");
github jkphl / node-iconizr / lib / iconizr.js View on Github external
// Check arguments
	if (arguments.length != 4) {
		var error			= new Error('Please call svg-sprite.createSprite() with exactly 4 arguments');
		error.errno			= 1391852448;
		return error;
	}
	
	// Keep the intermediate files
	options				= _.extend({}, defaultOptions, options || {});
	options.verbose		= Math.max(0, Math.min(3, parseInt(options.verbose, 10) || 0));
	
	// Temporarily alter the configuration options to keep intermediate files and suppress all output rendering
	options._keep		= options.keep;
	options.keep		= 1;
	options._render		= _.extend({css: true}, options.render);
	options.render		= {css: false};
	
	// Create the SVG sprite
	var sprite			= SVGSprite.createSprite(inputDir, outputDir, options, function(error, results) {
		
		// Restore configuration options
		results.options	= restoreOptions(results.options);
		
		// If an error occured while creating the SVG sprite: Abort
		if (error) {
			callback(error, results);
			
		// Else: Create icon kit
		} else {
			new Iconizr(results).createIconKit(callback);
		}
github ummon-server / ummon-server / lib / ummon.js View on Github external
if (!options) options = {};

  if (options.configPath) {
    if (fs.existsSync(options.configPath)) {
      config = require(options.configPath);
    } else {
      // self.log isn't setup until after config is loaded
      console.warn('');
      console.warn('The config file you passed does not exist: %s'.yellow, options.configPath);
      console.warn('');
    }
  } else if (fs.existsSync(defaults.configPath)) {
    config = require(path.resolve(defaults.configPath));
  }

  return _.extend(defaults, config, options);
}
github megawac / qwebirc-enhancements / demo / node / qwebirc / irc.js View on Github external
Client.setDefaults = function(opts) {
    _.extend(DEFAULT_OPTIONS, opts);
};
github atg / choc-support / building / javascript / node [default] / node_modules / jshint / src / cli.js View on Github external
_.each(config.overrides, function (options, pattern) {
        if (minimatch(path.normalize(file), pattern, { nocase: true, matchBase: true })) {
          if (options.globals) {
            globals = _.extend(globals || {}, options.globals);
            delete options.globals;
          }
          _.extend(config, options);
        }
      });
    }
github ql-io / ql.io / modules / mon / lib / mon.js View on Github external
function getStats(master) {
    return _.extend({},
        {
            master : {
                host: os.hostname(),
                os: os.type(),
                state: master.state,
                pid: master.pid,
                started: master.stats.start.toUTCString(),
                restarts: master.stats.restarts,
                workers: master.children.length,
                workersKilled: master.stats.workersKilled,
                averageLoad: os.loadavg().map(
                    function(n) {
                        return n.toFixed(2);
                    }).join(' '),
                coresUsed: master.children.length + ' of ' + os.cpus().length,
                memoryUsageAtBoot: forMemoryNum(master.stats.freemem) + ' of ' +
github respectTheCode / node-caspar-cg / index.js View on Github external
var ccg = module.exports = function (host, port) {
	events.EventEmitter.call(this);

	this.options = _.extend({}, this.options);

	if (typeof(host) == "string") {
		this.options.host = host;
	} else if (typeof(host) == "object") {
		_.extend(this.options, host);
	}

	if (port) {
		this.options.port = port;
	}

	this.index = count++;
};
github CartoDB / carto.js / src / vis / overlays.js View on Github external
Overlay.register('fullscreen', function (data, vis) {
  var options = _.extend(data, {
    doc: vis.$el.find('> div').get(0),
    allowWheelOnFullscreen: false,
    mapView: vis.mapView
  });

  if (data.template) {
    options.template = Template.compile(
      data.template,
      data.templateType || 'mustache'
    );
  }

  var fullscreen = new FullScreen(options);
  return fullscreen.render();
});
github arokor / barn / lib / barn.js View on Github external
function Barn(namespace, storage, opts){
  var _this = this;
  this._storage = NSStorage.createNamespace(namespace, storage);
  this._keys = {};
  this._idx = 0;
  this._keySet;
  this._opts = {
    maxKeys: 1000
  };

  _.extend(this._opts, opts);

  this._cmds = {
    DEL: {
      fn: function(key){
        var count = 0;
        _this._keys[key] && count++;
        delete _this._keys[key];
        return count;
      },
      mutating: true
    },
    GET: {
      fn: function(key){
        return _this._getValExpectingType(key, 'string');
      },
      mutating: false