DEV: removes _.map from codebase (#6616)

This commit is contained in:
Joffrey JAFFEUX 2018-11-19 10:46:46 +01:00 committed by Régis Hanol
parent 907cf3ee2f
commit c4ed353fae
9 changed files with 23 additions and 21 deletions

View File

@ -27,7 +27,7 @@ EmailLog.reopenClass({
return ajax(`/admin/email/${status}.json?offset=${offset}`, { return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter data: filter
}).then(logs => _.map(logs, log => EmailLog.create(log))); }).then(logs => logs.map(log => EmailLog.create(log)));
} }
}); });

View File

@ -32,7 +32,7 @@ IncomingEmail.reopenClass({
return ajax(`/admin/email/${status}.json?offset=${offset}`, { return ajax(`/admin/email/${status}.json?offset=${offset}`, {
data: filter data: filter
}).then(incomings => }).then(incomings =>
_.map(incomings, incoming => IncomingEmail.create(incoming)) incomings.map(incoming => IncomingEmail.create(incoming))
); );
}, },

View File

@ -13,7 +13,7 @@ const keyValueStore = new KeyValueStore("discourse_emojis_");
const EMOJI_USAGE = "emojiUsage"; const EMOJI_USAGE = "emojiUsage";
const EMOJI_SELECTED_DIVERSITY = "emojiSelectedDiversity"; const EMOJI_SELECTED_DIVERSITY = "emojiSelectedDiversity";
const PER_ROW = 11; const PER_ROW = 11;
const customEmojis = _.map(_.keys(extendedEmojiList()), code => { const customEmojis = _.keys(extendedEmojiList()).map(code => {
return { code, src: emojiUrlFor(code) }; return { code, src: emojiUrlFor(code) };
}); });
@ -148,7 +148,7 @@ export default Ember.Component.extend({
$recentSection.css("height", "auto").show(); $recentSection.css("height", "auto").show();
} }
const recentEmojis = _.map(this.get("recentEmojis"), code => { const recentEmojis = this.get("recentEmojis").map(code => {
return { code, src: emojiUrlFor(code) }; return { code, src: emojiUrlFor(code) };
}); });
const template = findRawTemplate("emoji-picker-recent")({ recentEmojis }); const template = findRawTemplate("emoji-picker-recent")({ recentEmojis });
@ -235,7 +235,7 @@ export default Ember.Component.extend({
this.$results this.$results
.empty() .empty()
.html( .html(
_.map(filteredCodes, code => { filteredCodes.map(code => {
const hasDiversity = isSkinTonableEmoji(code); const hasDiversity = isSkinTonableEmoji(code);
const diversity = hasDiversity ? "diversity" : ""; const diversity = hasDiversity ? "diversity" : "";
const scaledCode = this._codeWithDiversity(code, hasDiversity); const scaledCode = this._codeWithDiversity(code, hasDiversity);

View File

@ -72,14 +72,16 @@ export default Ember.Component.extend(
if (notices.length > 0) { if (notices.length > 0) {
buffer.push( buffer.push(
_.map(notices, n => { notices
var html = `<div class='row'><div class='alert alert-info ${ .map(n => {
n[1] var html = `<div class='row'><div class='alert alert-info ${
}'>`; n[1]
if (n[2]) html += n[2]; }'>`;
html += `${n[0]}</div></div>`; if (n[2]) html += n[2];
return html; html += `${n[0]}</div></div>`;
}).join("") return html;
})
.join("")
); );
} }
}, },

View File

@ -119,7 +119,7 @@ Site.reopenClass(Singleton, {
let subcatMap = {}; let subcatMap = {};
result.categoriesById = {}; result.categoriesById = {};
result.categories = _.map(result.categories, c => { result.categories = result.categories.map(c => {
if (c.parent_category_id) { if (c.parent_category_id) {
subcatMap[c.parent_category_id] = subcatMap[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) { if (result.post_action_types) {
result.postActionByIdLookup = Em.Object.create(); 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); const actionType = PostActionType.create(p);
result.postActionByIdLookup.set("action" + p.id, actionType); result.postActionByIdLookup.set("action" + p.id, actionType);
return actionType; return actionType;
@ -167,7 +167,7 @@ Site.reopenClass(Singleton, {
if (result.topic_flag_types) { if (result.topic_flag_types) {
result.topicFlagByIdLookup = Em.Object.create(); 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); const actionType = PostActionType.create(p);
result.topicFlagByIdLookup.set("action" + p.id, actionType); result.topicFlagByIdLookup.set("action" + p.id, actionType);
return actionType; return actionType;
@ -175,7 +175,7 @@ Site.reopenClass(Singleton, {
} }
if (result.archetypes) { if (result.archetypes) {
result.archetypes = _.map(result.archetypes, a => { result.archetypes = result.archetypes.map(a => {
a.site = result; a.site = result;
return Archetype.create(a); return Archetype.create(a);
}); });

View File

@ -469,7 +469,7 @@ const User = RestModel.extend({
}).then(json => { }).then(json => {
if (!Em.isEmpty(json.user.stats)) { if (!Em.isEmpty(json.user.stats)) {
json.user.stats = Discourse.User.groupStats( 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); if (s.count) s.count = parseInt(s.count, 10);
return UserActionStat.create(s); return UserActionStat.create(s);
}) })

View File

@ -33,7 +33,7 @@ function _loadCachedShortUrls($images) {
} }
function _loadShortUrls($images, ajax) { 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(() => lookupUncachedUploadUrls(urls, ajax).then(() =>
_loadCachedShortUrls($images) _loadCachedShortUrls($images)
); );

View File

@ -71,7 +71,7 @@ export default Ember.Component.extend({
@computed() @computed()
allTimezones() { allTimezones() {
return _.map(moment.tz.names(), z => z); return moment.tz.names();
}, },
@observes( @observes(

View File

@ -5,7 +5,7 @@ QUnit.module("Report");
function reportWithData(data) { function reportWithData(data) {
return Report.create({ return Report.create({
type: "topics", type: "topics",
data: _.map(data, (val, index) => { data: data.map((val, index) => {
return { return {
x: moment() x: moment()
.subtract(index, "days") .subtract(index, "days")