mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Prefer ES5 methods over underscore utilities
Since 07cc454 (ie the switch to Meteor 1.2) we includes the `es5-shim`
polyfill to support methods like `Array.prototype.forEach` in a
consistent way across all supported browsers (IE8+).
MDG recently released a blog post recommending the use of these native
methods instead of underscore [0]. We know follow this recommendation.
This commit also favor some ES6 features (argument defaults,
destructing assignment) in places where we didn’t use them.
[0]: http://info.meteor.com/blog/es2015-get-started
This commit is contained in:
parent
c6b12dc5ad
commit
aa974aa54a
14 changed files with 33 additions and 31 deletions
|
|
@ -14,13 +14,13 @@ Users.helpers({
|
|||
},
|
||||
|
||||
starredBoards() {
|
||||
const starredBoardIds = this.profile.starredBoards || [];
|
||||
return Boards.find({archived: false, _id: {$in: starredBoardIds}});
|
||||
const {starredBoards = []} = this.profile;
|
||||
return Boards.find({archived: false, _id: {$in: starredBoards}});
|
||||
},
|
||||
|
||||
hasStarred(boardId) {
|
||||
const starredBoardIds = this.profile.starredBoards || [];
|
||||
return _.contains(starredBoardIds, boardId);
|
||||
const {starredBoards = []} = this.profile;
|
||||
return _.contains(starredBoards, boardId);
|
||||
},
|
||||
|
||||
isBoardMember() {
|
||||
|
|
@ -54,9 +54,9 @@ Users.helpers({
|
|||
return profile.initials;
|
||||
|
||||
else if (profile.fullname) {
|
||||
return _.reduce(profile.fullname.split(/\s+/), (memo, word) => {
|
||||
return profile.fullname.split(/\s+/).reduce((memo = '', word) => {
|
||||
return memo + word[0];
|
||||
}, '').toUpperCase();
|
||||
}).toUpperCase();
|
||||
|
||||
} else {
|
||||
return this.username[0].toUpperCase();
|
||||
|
|
@ -130,7 +130,7 @@ if (Meteor.isServer) {
|
|||
// b. We use it to find deleted and newly inserted ids by using it in one
|
||||
// direction and then in the other.
|
||||
function incrementBoards(boardsIds, inc) {
|
||||
_.forEach(boardsIds, (boardId) => {
|
||||
boardsIds.forEach((boardId) => {
|
||||
Boards.update(boardId, {$inc: {stars: inc}});
|
||||
});
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ if (Meteor.isServer) {
|
|||
// Insert the Welcome Board
|
||||
Boards.insert(ExampleBoard, (err, boardId) => {
|
||||
|
||||
_.forEach(['Basics', 'Advanced'], (title) => {
|
||||
['Basics', 'Advanced'].forEach((title) => {
|
||||
const list = {
|
||||
title,
|
||||
boardId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue