How to use the map function from underscore
Find comprehensive JavaScript underscore.map code examples handpicked from public code repositorys.
GitHub: ONLYOFFICE/server
541 542 543 544 545 546 547 548 549 550 551
function sendDataDisconnectReason(ctx, conn, code, description) { sendData(ctx, conn, {type: "disconnectReason", code: code, description: description}); } function sendReleaseLock(ctx, conn, userLocks) { sendData(ctx, conn, {type: "releaseLock", locks: _.map(userLocks, function(e) { return { block: e.block, user: e.user, time: Date.now(),
171
146
32
+ 3 other calls in file
302 303 304 305 306 307 308 309 310 311
return this.player.currentPrompt(); } get currentButtons() { var buttons = this.currentPrompt().buttons; return _.map(buttons, button => button.text.toString()); } /** * Lists cards selectable by the player during the action
18
17
0
+ 3 other calls in file
255 256 257 258 259 260 261 262 263 264
isPageHeading: field.isPageHeading, isWarning: field.isWarning, warning: t(warningValue), detail: detail ? detail : '', hint: conditionalTranslate(getTranslationKey(field, key, 'hint')), options: _.map(field.options, function (obj) { let selected = false; let label; let value; let toggle;
14
13
12
GitHub: GeraldWodni/kern.js
160 161 162 163 164 165 166 167 168 169
readList( function( err, data ) { if( err ) return callback( err ); var items = _.map( data, function( row ) { var name = k.rdb.getField( row, opts.foreignName ); if( opts.foreignBoldName ) name = k.rdb.getField( row, opts.foreignBoldName ) + opts.foreignNameSeparator + name;
3
9
1
+ 11 other calls in file
5761 5762 5763 5764 5765 5766 5767 5768 5769 5770
// Return a copy of the object without the blacklisted properties. _.omit = function(obj, iteratee, context) { if (_.isFunction(iteratee)) { iteratee = _.negate(iteratee); } else { var keys = _.map(flatten(arguments, false, false, 1), String); iteratee = function(value, key) { return !_.contains(keys, key); }; }
0
1
1
+ 8 other calls in file
GitHub: w3security/code-query
114 115 116 117 118 119 120 121 122
this; }, y, this); } f3_outer() { underscore.map(x, function f3_inner() { this; }, this); }
2
0
2
+ 4 other calls in file
GitHub: Cloud-V/Backend
894 895 896 897 898 899 900 901 902 903
); for (let i = 0; i < pathsArrayPromises.length; i++) { await pathsArrayPromises[i](); } const repoEntriesPromises = _.map( repoEntries, (entry) => () => new Promise(async (resolve, reject) => { const entryPath = path.join(
0
2
3
+ 7 other calls in file
396 397 398 399 400 401 402 403 404 405
} } else if (_.isArray(schema)) { if (_.isEmpty(schema)) { throw new InvalidSchemaError('unions must have at least 1 branch'); } var branchTypes = _.map(schema, function(branchType) { return _parseSchema(branchType, schema, namespace); }); return new Union(branchTypes, namespace); } else { throw new InvalidSchemaError('unexpected Javascript type for schema: ' + (typeof schema)); }
0
1
1
+ 2 other calls in file
37 38 39 40 41 42 43 44 45 46
// Order used types according to 'options.order'. var orderedTypes = _.filter(options.order, function(type) { return options.types.indexOf(type) !== -1 }) var src = _.map(orderedTypes, function(type) { return templates[type]({ url: urls[type], fontName: options.fontName })
0
1
1
52 53 54 55 56 57 58 59 60 61
if (!options.files.length) return done(new Error('"options.files" is empty.')) // We modify codepoints later, so we can't use same object from default options. if (options.codepoints === undefined) options.codepoints = {} options.names = _.map(options.files, options.rename) if (options.cssDest === undefined) { options.cssDest = path.join(options.dest, options.fontName + '.css') } if (options.htmlDest === undefined) {
0
1
1
GitHub: yonas/meteor-freebsd
351 352 353 354 355 356 357 358 359 360
}); print(0, "Total: " + grandTotal.toFixed(1)); }; var setupReport = function () { entries = _.map(_.keys(bucketTimes), JSON.parse); _.each(_.filter(entries, hasChildren), function (parent) { injectOtherTime(parent); }); };
0
7
4
+ 5 other calls in file
GitHub: Cloud-V/Backend
461 462 463 464 465 466 467 468 469 470
const promises = [ new Promise(async (resolve, reject) => { try { const roles = await repo.getRoleEntries({}); Promise.all( _.map(roles, (role) => removeRole(role._id)) ) .then(() => {}) .catch(console.error); } catch (err) {
0
2
0
+ 9 other calls in file
729 730 731 732 733 734 735 736 737 738
//add members to group socket.on('add-group-members', function (data, callback) { // ChatroomController.findChatRoom({ chatRoomId: data.chatRoomId }, function (err, chatGroupResponse) { ChatroomController.fineMyName(data, function (err, resp) { ChatroomController.getUserNames(data, function (err,username) { let roomUserIds = _.map(data.users, 'userId'); data['isGroup'] = true; data['createLogs'] = false; data['addUsers'] = true; data['creator_name']=resp
0
1
0
GitHub: HWRobotics/meteor
96 97 98 99 100 101 102 103 104 105
// Prints a package list in a nice format. // Input is an array of objects with keys 'name' and 'description'. exports.printPackageList = function (items, options) { options = options || {}; var rows = _.map(items, function (item) { var name = item.name; var description = item.description || 'No description'; return [name, description]; });
0
0
7
GitHub: okgrow/meteor
196 197 198 199 200 201 202 203 204 205
}; set.directories = _.map(json.directories, function (d) { return { absPath: d.absPath, include: _.map(d.include, reFromJSON), exclude: _.map(d.exclude, reFromJSON), contents: d.contents }; });
0
0
10
+ 11 other calls in file
GitHub: netanelgilad/meteor
281 282 283 284 285 286 287 288 289 290
// - name (entry name, typically a command name) // - body (contents of body, trimmed to end with a newline but no blank lines) var loadHelp = function () { var ret = []; var raw = files.readFile(files.pathJoin(__dirname, 'help.txt'), 'utf8'); return _.map(raw.split(/^>>>/m).slice(1), function (r) { var lines = r.split('\n'); var name = lines.shift().trim(); return { name: name,
0
0
1
GitHub: musically-ut/meteor
193 194 195 196 197 198 199 200 201
return '{}'; } var spacing = new Array(indent + 1).join(' '); // XXX prettyprint! return "{\n" + _.map(node, function (value, key) { return spacing + " " + key + ": " + put(value, indent + 2); }).join(',\n') + "\n" + spacing + "}"; };
0
0
2
+ 11 other calls in file
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
return keys; }; // Retrieve the values of an object's properties. _.values = function(obj) { return _.map(obj, _.identity); }; // Return a sorted list of the function names available on the object. // Aliased as `methods`
0
0
0
+ 7 other calls in file
GitHub: yang-xiaoy/notes
9 10 11 12 13 14 15 16 17 18 19
module1.fn() module2(); console.log(module3.message) console.log(module3.arr) const result = uns.map(module3.arr,(item)=>{ return item*3 }); console.log(result)
0
0
0
+ 9 other calls in file
54 55 56 57 58 59 60 61 62 63
if(!data || !data.attributes) { h = '无属性信息'; return; } else { h = '<table class="table table-striped table-bordered" style="margin-bottom:0;">' + _.map(data.fields, function(field) { if(data.attributes[field.key] == undefined){ return ''; } return '<tr><td>' + field.name + ': </td><td>' + data.attributes[field.key] + '</td></tr>';
0
0
1
+ 2 other calls in file
underscore.keys is the most popular function in underscore (11266 examples)