This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// This file should actually be called '.eslintrc' | |
// Create it at the root directory of your Meteor app | |
// I want to use babel-eslint for parsing! | |
"parser": "babel-eslint", | |
"env": { | |
// I write for browser | |
"browser": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
Template.stats.onCreated(function () { | |
var self = this; | |
this.autorun(function () { | |
var filter = { limit: Session.get('options.limit') }; | |
self.subscribe('tweets', filter); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
Template.stats.onCreated(function () { | |
this.autorun(() => { | |
const filter = { limit: Session.get('options.limit') }; | |
this.subscribe('tweets', filter); // same "this" as in line 3 | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
var versionsMap = {}; | |
lines.forEach(function (line) { | |
// split name@version into [name, version] | |
var lineContents = line.split('@'); | |
var name = lineContents[0]; | |
var version = lineContents[1]; | |
versionsMap[name] = version; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
const versionsMap = new Map(); | |
lines.forEach((line) => { | |
const [name, version] = line.split(‘@’); // destructuring | |
versionsMap.set(name, version); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
const versionsMap = new Map(); | |
lines.forEach( line => versionsMap.set(...line.split(‘@’)) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES5 | |
UI.registerHelper('sum', function (/* arguments */) { | |
var summands = Array.prototype.slice.call(arguments); | |
summands.pop(); // remove last argument hash (Spacebars.kw) | |
var sum = 0; | |
for (var i = 0; i < summands.length; i++) { | |
sum += summands[i]; | |
} | |
return sum; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
UI.registerHelper('sum', function (...summands) { | |
summands.pop(); // remove last argument hash (Spacebars.kw) | |
return summands.reduce((previousValue, currentValue) => { | |
return previousValue + currentValue; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
Template.lead.helpers({ | |
twitterLink () { | |
return this.getTwitterLink(); | |
}, | |
weekday (timestamp) { | |
return moment(timestamp).format(‘dddd’); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ES6 | |
class Tweet { | |
constructor (doc) { | |
_.extend(this, doc); | |
} | |
} | |
Tweets = new Mongo.Collection('tweets', { | |
transform (doc) { | |
return new Tweet(doc); |
OlderNewer