Last active
January 21, 2021 18:18
-
-
Save Zirak/3373067 to your computer and use it in GitHub Desktop.
The Hello World of the future
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
/* | |
* The Hello World of tomorrow | |
* Copyright (C) 2012 Scruffy | |
* | |
* This program is free software: you can redistribute it and/or modify | |
* it under the terms of the GNU General Public License as published by | |
* the Free Software Foundation, either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU General Public License for more details. | |
* | |
* You should have received a copy of the GNU General Public License | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
/* | |
Hi! My name is Mr. Tiddles. I come from QA! | |
So it is my job to tell you that YOU SUCK | |
WHY ARE THERE NO UNIT TESTS? | |
WHY IS YOUR AGILE DRAWING BOARD BLANK!? | |
BLANK I TELL YOU! | |
YOU UNGRATEFUL PIECE OF MOTHERFUCKING TURDWAT | |
I GIVE AWAY MY LIFE TO GIVE YOU AGILE CARDS, AND THIS IS HOW YOU REPAY ME? | |
FUCK YOU | |
I DON'T WANT YOUR LAPDANCES | |
<3, | |
Mr. Tiddles | |
*/ | |
/** | |
@author Scruffy (I'm the janitor) | |
@description The enterprise solution to your SentenceFactory needs! | |
@date 16.8.2012 | |
@arg expr an array of expressions | |
@return the constructed object | |
*/ | |
function SentenceFactory | |
( | |
//the exprs | |
exprs | |
) | |
{ | |
//set this.exprs = exprs | |
this.exprs = exprs; | |
} | |
SentenceFactory.prototype = | |
{ | |
set : function | |
( | |
//the exprs | |
exprs | |
) | |
{ | |
//set this.exprs = exprs | |
this.exprs = exprs; | |
}, | |
/** | |
@author Scruffy (Life goes on, but I believe we'll forever carry the pain | |
on the inside) | |
@description The enterprise solution to your SentenceFactory.prototype.produce needs! | |
@date 16.8.2012 | |
@arg wordSeparator a word separator | |
@return a sentence | |
*/ | |
produce : function | |
( | |
//the wordSeparator | |
wordSeparator | |
) | |
{ | |
//delcare the variables T, A and k | |
var T | |
, A | |
, k; | |
//if this.exprs is null | |
if | |
( | |
this.exprs === null | |
) | |
{ | |
//throw a new TypeError | |
throw new TypeError | |
( | |
"YOU DICK Y U NO PROVIDE EXPRESSIONS AM I TOO FAT NOW FOR " + | |
"YOU AS WELL!?!?" | |
/*added per QA request*/ | |
); | |
} | |
//end if | |
//set O to the result of calling Object, with this.exprs argument | |
var O = Object | |
( | |
this.exprs | |
); | |
//set len to O.length truncated with magic bitwise operations | |
var len = O.length >>> 0; | |
//set A to be a new array of length len | |
A = new Array | |
( | |
len | |
); | |
//set k to 0 | |
k = 0; | |
//while k is less than len | |
while | |
( | |
k < len | |
) | |
{ | |
//declare the variables kValue and mappedValue | |
var kValue | |
, mappedValue; | |
//if k is in O | |
if | |
( | |
k in O | |
) | |
{ | |
//set kValue to O[k] | |
//lol, O[k]. get it, OK? | |
//I'm the only smart person here... | |
//all the rest of you are idiots, just sheeple! | |
kValue = O[ k ]; | |
//set mappedValue to the result of calling this.produceCallback | |
// with the kValue argument | |
mappedValue = this.produceCallback( kValue ); | |
//set A[k] to mappedValue | |
A[ k ] = mappedValue; | |
} | |
//end if | |
k++; //increase k by 1 | |
} | |
//end while | |
//if A.length is greater than 0 | |
if | |
( | |
A.length > 0 | |
) | |
{ | |
//set A[0] to the first letter uppercased, followed by the rest of | |
// the letters, lowercased | |
A[ 0 ] = | |
A[ 0 ][ 0 ].toUpperCase() | |
+ | |
A[ 0 ].slice( 1 ).toLowerCase(); | |
} | |
//end if | |
//TODO: consider localization ramifications of amputation by a nation's | |
// cancellation with violation of the right of pagination all for | |
// liberation of vegetation accomodation | |
return A.join( " " ); | |
}, | |
/** | |
@author Scruffy (The candle that burns twice as bright turns half as long) | |
@description A produceCallback solution to your SentenceFactory.prototype.produceCallback needs! | |
@date 16.8.2012 | |
@return mommy? | |
*/ | |
produceCallback : function | |
( | |
//an expr | |
expr | |
) | |
{ | |
//return the produce result of expr | |
return expr.produce(); | |
}, | |
/** | |
@author Scruffy (It's a mirror into Scruffy's soul) | |
@description The enterprise solution to all your turnIntoAMoose needs! | |
@date 16.8.2012 | |
@return void | |
*/ | |
turnIntoAMoose : function | |
( | |
) | |
{ | |
//throw a new Error | |
throw new Error( 'You are not ready for the moose' ); | |
}, | |
constructor : SentenceFactory | |
}; | |
/** | |
@author Scruffy (Don't thank me. Thank the ladder.) | |
@description The enterprise solution to all your WordFactory needs! | |
@date 16.8.2012 | |
@arg dawg word | |
@return WordFactory | |
*/ | |
function WordFactory | |
( | |
//a dawg | |
dawg | |
) | |
{ | |
//set this.value = dawg | |
this.value = dawg; | |
} | |
WordFactory.prototype = | |
{ | |
/** | |
@author Scruffy (Scruffy's work here is done.) | |
@description The enterprise solution to all your set needs! | |
@date 16.8.2012 | |
@arg dawg word | |
@return WordFactory | |
*/ | |
set : function | |
( | |
//a dawg | |
dawg | |
) | |
{ | |
//set this.value = dawg | |
this.value = dawg; | |
}, | |
/** | |
@author Scruffy (I took a regular board, and made it into a divin' board. | |
Mhrm. | |
@description The enterprise solution to all your produce needs! | |
@date 16.8.2012 | |
@return value value | |
*/ | |
produce : function | |
( | |
) | |
{ | |
//if there is no value | |
if | |
( | |
!this.value | |
) | |
{ | |
//throw a new TypeError | |
throw new TypeError( 'PPPEEEENNNNIIIIISSSS' ); | |
} | |
//end if | |
//return this.value | |
return this.value; | |
}, | |
constructor : WordFactory | |
}; | |
/** | |
@author Scruffy (I'm on break *eats potato chip*) | |
@description The enterprise solution to all your HelloFactory needs! | |
@date 16.8.2012 | |
@arg locale locale | |
@return HelloFactory | |
*/ | |
function HelloFactory | |
( | |
//a locale | |
locale | |
) | |
{ | |
//if a locale isn't passed, | |
if | |
( | |
!locale | |
) | |
{ | |
//set the locale to 'en' | |
locale = 'en'; | |
} | |
//end if | |
//call this.set, passing in the result of getting the `locale` property on | |
// this.locales | |
this.set | |
( | |
//because javascript is stupid, we can't use a variable to get a | |
// property on an object, so we have to use eval | |
//I saw this once in a NetTuts+ tutorial. | |
eval( 'this.locales.' + locale ) | |
); | |
} | |
//set the HelloFactory prototype to a new WordFactory | |
HelloFactory.prototype = new WordFactory(); | |
//set HelloFactory.prototype.locales to an object | |
HelloFactory.prototype.locales = new Object(); | |
HelloFactory.prototype.locales.en = "hello"; | |
HelloFactory.prototype.locales.de = "hallo"; | |
HelloFactory.prototype.locales.es = "hola"; | |
/*QA called and told us to be prepared for these kinds of customers*/ | |
HelloFactory.prototype.locales.za = "̸̶̧̩̼̫̭͖̒̽̌ͦ̚Z͈͉̼͔͚̮͖͛ͪ͛ͩ̆ͤͅA̸̩̜̬͚ͤ̉́͞L̯̙̭͈̃͟G̷̤̟̙̹̗͆̍͛͒͂ͥ͠O̳̞̜͑ͣͤͦ͜"; | |
/* p.s. YOU'RE A GIANT DOUCHEBAG */ | |
//set HelloFactory.prototype.constructor to HelloFactory | |
HelloFactory.prototype.constructor = HelloFactory; | |
/** | |
@author Scruffy (Life and death are a seamless continuum) | |
@description The enterprise solution to your WorldFactory needs! | |
@date 16.8.2012 | |
@ | |
*/ | |
function WorldFactory | |
( | |
//a locale | |
locale | |
) | |
{ | |
//management called and said DRY is for pussies | |
//if locale wasn't passed in, | |
if | |
( | |
!locale | |
) | |
{ | |
//set locale to 'en' | |
locale = 'en'; | |
} | |
//end if | |
//call this.set, passing in the result of getting the `locale` property on | |
// this.locales | |
this.set | |
( | |
//because javascript is stupid, we can't use a variable to get a | |
// property on an object, so we have to use eval | |
//I saw this once in a NetTuts+ tutorial. | |
eval( 'this.locales.' + locale ) | |
); | |
} | |
//set the WorldFactory prototype to a new WordFactory | |
WorldFactory.prototype = new WordFactory(); | |
//set WorldFactory.prototype.locales to a new Object | |
WorldFactory.prototype.locales = new Object(); | |
WorldFactory.prototype.locales.en = "world"; | |
WorldFactory.prototype.locales.de = "welt"; | |
WorldFactory.prototype.locales.es = "mundo"; | |
WorldFactory.prototype.locales.za = "͉̰̖͕̬̜͎̮̗͛̇̎ͥ̆Z̴̵̙̖̹̭̭͖̯ͫ̓ͦ̑̀̚ͅA̸̲̜̮ͧ͒̌ͯ̀̊̂̅͞ͅL͙̰͔̝̮̬̹̅̓̉̊͛͛͒͜͠G̨̲̀ͦ͊͐͐ͫ̒ͨO̷͔̜̹͇̩̫͓ͬͫͣ̂͗̆͟͡!̨̯̼̹̮͉͔̿ͬ̓ͫͫ͛̌̃"; | |
//set WorldFactory prototype constructor to WorldFactory | |
WorldFactory.prototype.constructor = WorldFactory; | |
/** | |
@author Scruffy (What fevered dream is this that bids to tear this company | |
in twain!? | |
@description The enterprise solution to all your HelloWorldFactory needs! | |
@date 16.8.2012 | |
@args locale locale | |
@return HelloWorldFactory | |
*/ | |
function HelloWorldFactory | |
( | |
//a locale | |
locale | |
) | |
{ | |
//set hello to making a new HelloFactory, passing in locale | |
var hello = new HelloFactory | |
( | |
locale | |
); | |
//set world to making a new WorldFactory, passing in locale | |
var world = new WorldFactory | |
( | |
locale | |
); | |
//set a to a new array | |
var a = new Array(); | |
//set the first item to hello | |
a[ 0 ] = hello; | |
//and the second item to world | |
a[ 1 ] = world; | |
//call this.set, passing in a | |
this.set | |
( | |
a | |
); | |
} | |
//set HelloWorldFactory prototype to a new SentenceFactory | |
HelloWorldFactory.prototype = new SentenceFactory(); | |
//set HelloWorldFactory prototype constructor to HelloWorldFactory | |
HelloWorldFactory.prototype.constructor = HelloWorldFactory; | |
/** | |
@author Scruffy (My job. Toilets 'n boilers, boilers 'n toilets. Plus that | |
one boilin' toilet. Fire me if'n you dare.) | |
@description The enterprise solution to all your static_void_main needs! | |
@date 16.8.2012 | |
@return void void | |
*/ | |
function static_void_main | |
() | |
{ | |
//set helloWorld to a new HelloWorldFactory | |
var helloWorld = new HelloWorldFactory() | |
//set result to the result of calling produce on helloWorld | |
, result = helloWorld.produce(); | |
//call the console.log function, passing in result | |
console.log | |
( | |
result | |
); | |
} | |
//call static_void_main | |
static_void_main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment