r/javascript • u/brexitjs • Jul 23 '16
[Project] fart.io (suggestions welcome)
https://github.com/toiletjs/fart.io5
u/Nebril Jul 23 '16
Literally a shitpost. Well played.
3
u/brexitjs Jul 23 '16
Yeah it's a silly subject but I'm learning a lot about ES6 in the process. I think I mentioned it in another reply but this project was the first time I got to use the new class syntax. I'm taking it seriously as a learning experience. I didn't mean for it to be a shitpost.
2
u/mick0n Jul 23 '16
I feel that fart.io may be lacking a definition of input. The output fart may depend on what framework was used as input, i.e. beansJS may produce a more explosive output than say rice.io (Which may override console.log and thus silence output completely)
2
u/brexitjs Jul 23 '16
That's definitely a concern. WDYT of using something like the decorator pattern to wrap fart.io with framework-specific IO implementations? (accepting pull requests as well, nudge nudge ;)
3
u/Dmnevius Jul 23 '16
Revolutionary framework. Definitely going to use this in my next project. Keep up the good work!
2
u/brexitjs Jul 23 '16
Thanks! Changed to ES6 with an AbstractBaseFart and a Shart subclass. First time using class syntax but definitely a joy; much easier than dealing with prototypes!
2
u/saadq_ Jul 24 '16
Since you seem to be new to ES6, just want to point out that you're still actually using prototypes. The
classsyntax is just sugar over it, so if you do something like:class Car { constructor (color, mileage) { this.color = color this.mileage = mileage } paint (color) { this.color = color } drive (miles) { this.mileage += miles } }It's simply syntax sugar for this behind the scenes:
function Car (color, mileage) { this.color = color this.mileage = mileage } Car.prototype.paint = function (color) { this.color = color } Car.prototype.drive = function (miles) { this.mileage += miles }So even if you use the
classsyntax, you can still add on methods to the prototype dynamically, etc. So ES6 classes aren't really "blueprints" of an object like you might be accustomed to from a language like Java or something similar.1
u/brexitjs Jul 24 '16
Helpful, thanks! The MDN docs I looked up did mention that it's all still prototypes in the background but this is a good example to reinforce that it can be written both ways.
17
u/joshmanders Full Snack Developer Jul 23 '16
I giggled, but I looked into your post history and found brexitjs, and well that's just genius.
var GB = document.querySelector('script[src$=brexit.js]');
var EU = GB.parentNode;
EU.removeChild(GB);4
10
u/veswill3 Jul 23 '16
// Note that this.isWet is not checked here as all sharts are considered wet.
Legit.
4
u/bogdan5844 Jul 23 '16
A React-based JS framework that makes farts.
TODO(toiletjs): Use React. See #4 (v2).
Something's smelly here.
7
u/Pantstown (pants) => (town) => pantstown Jul 23 '16
.silentButDeadly()--> no logs, crashes browser