How to use the extend function from underscore
Find comprehensive JavaScript underscore.extend code examples handpicked from public code repositorys.
GitHub: cliss/camel
119 120 121 122 123 124 125 126 127 128 129 130
return renderedPosts[normalizedFileName(file)] || null; } function addRenderedPostToCache(file, postData) { //console.log('Adding to cache: ' + normalizedFileName(file)); renderedPosts[normalizedFileName(file)] = _.extend({ file: normalizedFileName(file), date: new Date() }, postData); if (_.size(renderedPosts) > maxCacheSize) { var sorted = _.sortBy(renderedPosts, function (post) { return post.date; }); delete renderedPosts[sorted.first().file];
+ 38 other calls in file
GitHub: pmlrsg/GISportal
357 358 359 360 361 362 363 364 365 366
if (utils.fileExists(dict_path)) { var dict_file = JSON.parse(fs.readFileSync(dict_path)); if (utils.fileExists(user_dict_path)) { var user_dict_file = JSON.parse(fs.readFileSync(user_dict_path)); _.extend(dict_file, user_dict_file); } res.send(dict_file); } else { res.send({});
44 45 46 47 48 49 50 51 52 53
accelerometer: { mode: 3 }, gyroscope: { mode: 0 }, debug: true }; _.extend(this, defaults, options); var accelerometerModes = [ [MPU6050.ACCEL_FS_2, 16384], [MPU6050.ACCEL_FS_4, 8192],
+ 2 other calls in file
GitHub: Ashteki/ashteki
796 797 798 799 800 801 802 803 804 805
if (this.clock) { playerState.clock = this.clock.getState(); } playerState.promptState = promptState; return _.extend(playerState, promptState); } getTypeValue(cardType) { switch (cardType) {
GitHub: GeraldWodni/kern.js
574 575 576 577 578 579 580 581 582 583
} else if( crud.type === "sql" ) opts = _.extend( opts, { getCrud: function _getCrudSql( req ) { /* overwrite sql-crud for this very call (bind req) */ return _.extend( {}, crud, { read: function _crudManager_sql_read( key, callback ) { crud.read( { req: req, key: key }, callback ); } });
+ 119 other calls in file
GitHub: johnnypez/nerd
47 48 49 50 51 52 53 54 55 56 57 58
exports.get_config = function(env){ return _.extend(_config['defaults'], _config[env || process.env.NODE_ENV]); }; exports.configure = function(env, options){ _config[env] = _.extend({}, _config[env], options); } exports.default_route = {controller: undefined, action: undefined};
+ 7 other calls in file
GitHub: johnnypez/nerd
47 48 49 50 51 52 53 54 55 56
this.after(); this.rendered = true; var controller = this; var defaults = {layout: this.layout, status: 200}; var config = _.extend({}, defaults, options); if(config.json != undefined){ this.render_json(options); }
+ 19 other calls in file
GitHub: johnnypez/nerd
56 57 58 59 60 61 62 63 64 65 66
} function route(req, res, next, params){ var controller = null; var defaults = {format: "html"}; req.params = _.extend(defaults, req.params, params); controller = nerd.modules[req.params.controller + "_controller"]; if(req.params.controller == "application" || controller == undefined){ res.writeHead(404); res.end();
+ 5 other calls in file
GitHub: wotcity/automationjs
52 53 54 55 56 57 58 59 60 61 62 63 64
// Copy the *extend* function used by Backbone's classes EA.extend = Backbone.Model.extend; // Copy the basic Backbone.Events on to the event aggregator _.extend(EA.prototype, Backbone.Events); return new EA(); };
+ 5 other calls in file
7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517
completedColor: '#C8F2BE' // base color for permenant features generated from completed measure }; _.extend(Symbology.prototype, { setOptions: function (options) { this._options = _.extend({}, Symbology.DEFAULTS, this._options, options); return this; }, getSymbol: function (name) { var symbols = {
+ 7 other calls in file
GitHub: Cloud-V/Backend
4 5 6 7 8 9 10 11 12 13 14 15
let createToken, getToken, getValidToken; module.exports.createToken = createToken = function (tokenData, cb) { let newToken = new callbackTokenModel(); newToken = _.extend( newToken, _.pick( _.omit(tokenData, Utils.nonCloneable), _.pickSchema(callbackTokenModel)
+ 3 other calls in file
GitHub: Cloud-V/Backend
18 19 20 21 22 23 24 25 26 27
} newOrganization.owner = organization.owner; newOrganization.description = ""; newOrganization = _.extend( newOrganization, _.pick( _.omit(organization, Utils.nonCloneable), _.pickSchema(organizationModel)
GitHub: Cloud-V/Backend
23 24 25 26 27 28 29 30 31
newTeam.repoVisibilty = team.repoVisibilty; } newTeam.description = ""; newTeam = _.extend( newTeam, _.pick(_.omit(team, Utils.nonCloneable), _.pickSchema(teamModel)) );
GitHub: Cloud-V/Backend
27 28 29 30 31 32 33 34 35
newProject.repoVisibilty = project.repoVisibilty; } newProject.description = ""; newProject = _.extend( newProject, _.pick(_.omit(project, Utils.nonCloneable), _.pickSchema(projectModel)) );
GitHub: Cloud-V/Backend
2939 2940 2941 2942 2943 2944 2945 2946 2947 2948
const validPaths = _.pickSchema( ipModel, Utils.nonCloneable.concat(["inputs", "outputs"]) ); const extension = _.pick(ip, validPaths); newIp = _.extend(newIp, extension); newIp.title = newIp.title.trim(); version = parseInt(ip.version); if (isNaN(version)) {
+ 19 other calls in file
GitHub: Cloud-V/Backend
101 102 103 104 105 106 107 108 109 110
const valid = await user.isValidPassword(password); if (!valid) { return resolve(null); } const profile = await user.getProfile(); const merged = _.extend( profile.toJSON(), _.omit(user.toJSON(), ["password"]) ); return resolve(merged);
+ 3 other calls in file
21 22 23 24 25 26 27 28 29 30
run (opts) { if (opts === undefined) { opts = {} } this._settings = _.extend(this._defaults, opts) this._createProxy() this._createServer() }
+ 3 other calls in file
GitHub: Cloud-V/Backend
4998 4999 5000 5001 5002 5003 5004 5005 5006 5007
repoId: repository._id, accessLevel, }; const files = await repository[functionName](); return res.status(200).json( _.extend( { files, }, metaData
+ 17 other calls in file
GitHub: Cloud-V/Backend
524 525 526 527 528 529 530 531 532 533
); user.token = token; const profile = await User.getUserProfile({ user: user._id, }); const merged = _.extend(profile.toJSON(), _.omit(user, ["password"])); return res.json(merged); } catch (err) { return res.status(500).json(err); }
+ 7 other calls in file
53 54 55 56 57 58 59 60 61 62
// Transform codepoints to hex strings var codepoints = _.object(_.map(options.codepoints, function(codepoint, name) { return [name, codepoint.toString(16)] })) return _.extend({ fontName: options.fontName, src: makeSrc(options, urls), codepoints: codepoints }, options.templateOptions)
underscore.keys is the most popular function in underscore (11266 examples)