From c4ed353fae4280541f8f4c52d9ab43486bd11ba2 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 19 Nov 2018 10:46:46 +0100 Subject: [PATCH] DEV: removes _.map from codebase (#6616) --- .../javascripts/admin/models/email-log.js.es6 | 2 +- .../admin/models/incoming-email.js.es6 | 2 +- .../discourse/components/emoji-picker.js.es6 | 6 +++--- .../discourse/components/global-notice.js.es6 | 18 ++++++++++-------- .../javascripts/discourse/models/site.js.es6 | 8 ++++---- .../javascripts/discourse/models/user.js.es6 | 2 +- .../pretty-text/image-short-url.js.es6 | 2 +- .../discourse-local-dates-create-form.js.es6 | 2 +- test/javascripts/models/report-test.js.es6 | 2 +- 9 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/admin/models/email-log.js.es6 b/app/assets/javascripts/admin/models/email-log.js.es6 index 4b6db3c6c1d..f1ac52ac8dc 100644 --- a/app/assets/javascripts/admin/models/email-log.js.es6 +++ b/app/assets/javascripts/admin/models/email-log.js.es6 @@ -27,7 +27,7 @@ EmailLog.reopenClass({ return ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter - }).then(logs => _.map(logs, log => EmailLog.create(log))); + }).then(logs => logs.map(log => EmailLog.create(log))); } }); diff --git a/app/assets/javascripts/admin/models/incoming-email.js.es6 b/app/assets/javascripts/admin/models/incoming-email.js.es6 index 931258fb119..fd9d68730b7 100644 --- a/app/assets/javascripts/admin/models/incoming-email.js.es6 +++ b/app/assets/javascripts/admin/models/incoming-email.js.es6 @@ -32,7 +32,7 @@ IncomingEmail.reopenClass({ return ajax(`/admin/email/${status}.json?offset=${offset}`, { data: filter }).then(incomings => - _.map(incomings, incoming => IncomingEmail.create(incoming)) + incomings.map(incoming => IncomingEmail.create(incoming)) ); }, diff --git a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 b/app/assets/javascripts/discourse/components/emoji-picker.js.es6 index 67f36873987..628588ef202 100644 --- a/app/assets/javascripts/discourse/components/emoji-picker.js.es6 +++ b/app/assets/javascripts/discourse/components/emoji-picker.js.es6 @@ -13,7 +13,7 @@ const keyValueStore = new KeyValueStore("discourse_emojis_"); const EMOJI_USAGE = "emojiUsage"; const EMOJI_SELECTED_DIVERSITY = "emojiSelectedDiversity"; const PER_ROW = 11; -const customEmojis = _.map(_.keys(extendedEmojiList()), code => { +const customEmojis = _.keys(extendedEmojiList()).map(code => { return { code, src: emojiUrlFor(code) }; }); @@ -148,7 +148,7 @@ export default Ember.Component.extend({ $recentSection.css("height", "auto").show(); } - const recentEmojis = _.map(this.get("recentEmojis"), code => { + const recentEmojis = this.get("recentEmojis").map(code => { return { code, src: emojiUrlFor(code) }; }); const template = findRawTemplate("emoji-picker-recent")({ recentEmojis }); @@ -235,7 +235,7 @@ export default Ember.Component.extend({ this.$results .empty() .html( - _.map(filteredCodes, code => { + filteredCodes.map(code => { const hasDiversity = isSkinTonableEmoji(code); const diversity = hasDiversity ? "diversity" : ""; const scaledCode = this._codeWithDiversity(code, hasDiversity); diff --git a/app/assets/javascripts/discourse/components/global-notice.js.es6 b/app/assets/javascripts/discourse/components/global-notice.js.es6 index 5041da17131..0a506cbc6cb 100644 --- a/app/assets/javascripts/discourse/components/global-notice.js.es6 +++ b/app/assets/javascripts/discourse/components/global-notice.js.es6 @@ -72,14 +72,16 @@ export default Ember.Component.extend( if (notices.length > 0) { buffer.push( - _.map(notices, n => { - var html = `
`; - if (n[2]) html += n[2]; - html += `${n[0]}
`; - return html; - }).join("") + notices + .map(n => { + var html = `
`; + if (n[2]) html += n[2]; + html += `${n[0]}
`; + return html; + }) + .join("") ); } }, diff --git a/app/assets/javascripts/discourse/models/site.js.es6 b/app/assets/javascripts/discourse/models/site.js.es6 index f44e92da37a..a2de542fa4e 100644 --- a/app/assets/javascripts/discourse/models/site.js.es6 +++ b/app/assets/javascripts/discourse/models/site.js.es6 @@ -119,7 +119,7 @@ Site.reopenClass(Singleton, { let subcatMap = {}; result.categoriesById = {}; - result.categories = _.map(result.categories, c => { + result.categories = result.categories.map(c => { if (c.parent_category_id) { subcatMap[c.parent_category_id] = subcatMap[c.parent_category_id] || []; @@ -158,7 +158,7 @@ Site.reopenClass(Singleton, { if (result.post_action_types) { result.postActionByIdLookup = Em.Object.create(); - result.post_action_types = _.map(result.post_action_types, p => { + result.post_action_types = result.post_action_types.map(p => { const actionType = PostActionType.create(p); result.postActionByIdLookup.set("action" + p.id, actionType); return actionType; @@ -167,7 +167,7 @@ Site.reopenClass(Singleton, { if (result.topic_flag_types) { result.topicFlagByIdLookup = Em.Object.create(); - result.topic_flag_types = _.map(result.topic_flag_types, p => { + result.topic_flag_types = result.topic_flag_types.map(p => { const actionType = PostActionType.create(p); result.topicFlagByIdLookup.set("action" + p.id, actionType); return actionType; @@ -175,7 +175,7 @@ Site.reopenClass(Singleton, { } if (result.archetypes) { - result.archetypes = _.map(result.archetypes, a => { + result.archetypes = result.archetypes.map(a => { a.site = result; return Archetype.create(a); }); diff --git a/app/assets/javascripts/discourse/models/user.js.es6 b/app/assets/javascripts/discourse/models/user.js.es6 index acb2ad2ff41..3bb87992028 100644 --- a/app/assets/javascripts/discourse/models/user.js.es6 +++ b/app/assets/javascripts/discourse/models/user.js.es6 @@ -469,7 +469,7 @@ const User = RestModel.extend({ }).then(json => { if (!Em.isEmpty(json.user.stats)) { json.user.stats = Discourse.User.groupStats( - _.map(json.user.stats, s => { + json.user.stats.map(s => { if (s.count) s.count = parseInt(s.count, 10); return UserActionStat.create(s); }) diff --git a/app/assets/javascripts/pretty-text/image-short-url.js.es6 b/app/assets/javascripts/pretty-text/image-short-url.js.es6 index 7aa4c931442..60403bafc1e 100644 --- a/app/assets/javascripts/pretty-text/image-short-url.js.es6 +++ b/app/assets/javascripts/pretty-text/image-short-url.js.es6 @@ -33,7 +33,7 @@ function _loadCachedShortUrls($images) { } function _loadShortUrls($images, ajax) { - const urls = _.map($images, img => $(img).data("orig-src")); + const urls = $images.map(img => $(img).data("orig-src")); lookupUncachedUploadUrls(urls, ajax).then(() => _loadCachedShortUrls($images) ); diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 index c6e3712de5e..6c2010bd152 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/discourse-local-dates-create-form.js.es6 @@ -71,7 +71,7 @@ export default Ember.Component.extend({ @computed() allTimezones() { - return _.map(moment.tz.names(), z => z); + return moment.tz.names(); }, @observes( diff --git a/test/javascripts/models/report-test.js.es6 b/test/javascripts/models/report-test.js.es6 index 888b9fef146..f3117d3a3ee 100644 --- a/test/javascripts/models/report-test.js.es6 +++ b/test/javascripts/models/report-test.js.es6 @@ -5,7 +5,7 @@ QUnit.module("Report"); function reportWithData(data) { return Report.create({ type: "topics", - data: _.map(data, (val, index) => { + data: data.map((val, index) => { return { x: moment() .subtract(index, "days")