From ec36a2244296ffdab3c7034d2076665e9a3f861e Mon Sep 17 00:00:00 2001 From: Ali Sajid Imami Date: Wed, 10 Nov 2021 11:22:05 -0500 Subject: [PATCH 1/3] Added urdu and rupee support --- README.md | 4 ++++ five.js | 9 +++++++++ test.js | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index addc66f6..d722db96 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ five.telugu() // ఐదు five.thai() // ห้า five.turkish() // beş five.ukrainian() // п’ять +five.urdu() // پانچ five.welsh() // pump ``` @@ -197,6 +198,9 @@ five.guys(); // '🍔' ```javascript five.euro(); // '5€' five.dollar(); // '$5' +five.rupee('pakistani'); // '5 Rs.' +five.rupee('indian'); // '₹ 5' +five.rupee(); // '5 Rs.' for the default case ``` diff --git a/five.js b/five.js index 90507e66..d59f600e 100755 --- a/five.js +++ b/five.js @@ -91,6 +91,7 @@ five.turkish = function() { return 'beş'; }; five.thai = function() { return 'ห้า'; }; five.ukrainian = function() { return 'п’ять'; }; + five.urdu = function() {return 'پانچ';}; five.welsh = function() { return 'pump'; }; five.morseCode = function() { return '.....'; }; @@ -196,6 +197,14 @@ five.dollar = function() { return '$5' }; + five.rupee = function(type) { + switch (type) { + case 'pakistani': return '5 Rs.'; + case 'indian': return '₹ 5'; + default: return '5 Rs.'; + } + }; + five.rot = function(word) { if(typeof(word) != 'string') { return word; diff --git a/test.js b/test.js index 63ee6cc8..6e837901 100755 --- a/test.js +++ b/test.js @@ -77,6 +77,7 @@ assert.equal('ఐదు', five.telugu(), 'A telugu five should be ఐదు'); assert.equal('ห้า', five.thai(), 'A thai five should be ห้า'); assert.equal('beş', five.turkish(), 'A turkish five should be beş'); assert.equal('п’ять', five.ukrainian(), 'A ukrainian five should be п’ять'); +assert.equal('پانچ', five.urdu(), 'An urdu five should be پانچ'); assert.equal('.....', five.morseCode(), 'A five in morse code should be .....'); assert.equal('10', five.base(5), 'A quinary five should be 10'); @@ -142,6 +143,10 @@ assert.equal('5€', five.euro()); assert.equal('$5', five.dollar()); +assert.equal('5 Rs.', five.rupee('pakistani')); +assert.equal('₹ 5', five.rupee('indian')); +assert.equal('5 Rs.', five.rupee()); + assert.equal('5678901234', five.rot('0123456789'), 'Numbers should be rotated'); assert.equal('fghijklmnopqrstuvwxyzabcde', five.rot('abcdefghijklmnopqrstuvwxyz'), 'Small letters should be rotated'); assert.equal('FGHIJKLMNOPQRSTUVWXYZABCDE', five.rot('ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'Capital letters too'); From f9c8ae7682d04b9d9d18dafe095770a410f240cf Mon Sep 17 00:00:00 2001 From: Ali Sajid Imami Date: Wed, 10 Nov 2021 11:25:10 -0500 Subject: [PATCH 2/3] reformatted with prettier --- five.js | 515 ++++++++++++++++++++++++++++++++++++++----------------- index.js | 2 +- test.js | 420 +++++++++++++++++++++++++++++---------------- 3 files changed, 634 insertions(+), 303 deletions(-) diff --git a/five.js b/five.js index d59f600e..ca7395cb 100755 --- a/five.js +++ b/five.js @@ -1,241 +1,446 @@ (function () { - - var five = function() { return 5; }; + var five = function () { + return 5; + }; // Quote: Malaclypse the Younger, Principia Discordia, Page 00016 - five.law = function() { return 'The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.'; }; + five.law = function () { + return "The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong."; + }; - five.upHigh = function() { return '⁵'; }; - five.downLow = function() { return '₅'; }; - five.roman = function() { return 'V'; }; + five.upHigh = function () { + return "⁵"; + }; + five.downLow = function () { + return "₅"; + }; + five.roman = function () { + return "V"; + }; - five.convertTo = function(anotherNumber) { + five.convertTo = function (anotherNumber) { // If you need other numbers I'd strongly suggest you call // this function when your app starts up and cache the result. var oneFifthOfFive = five() / five(); - while(anotherNumber < oneFifthOfFive) { + while (anotherNumber < oneFifthOfFive) { anotherNumber += oneFifthOfFive; } return anotherNumber; }; - five.arabic = function() { return 'خمسة'; }; - five.azerbaijani = function() { return 'beş'; }; - five.basque = function() { return 'bost'; }; - five.belarusian = function() { return 'пяць'; }; - five.bosnian = function() { return 'pet'; }; - five.bulgarian = function() { return 'пет'; }; - five.catalan = function() { return 'cinc'; }; - five.chinese = function(type) { - switch(type) { - case 'pinyin': return 'wǔ'; - case 'financial': return '伍'; - default: return '五'; + five.arabic = function () { + return "خمسة"; + }; + five.azerbaijani = function () { + return "beş"; + }; + five.basque = function () { + return "bost"; + }; + five.belarusian = function () { + return "пяць"; + }; + five.bosnian = function () { + return "pet"; + }; + five.bulgarian = function () { + return "пет"; + }; + five.catalan = function () { + return "cinc"; + }; + five.chinese = function (type) { + switch (type) { + case "pinyin": + return "wǔ"; + case "financial": + return "伍"; + default: + return "五"; } }; - five.choctaw = function() { return 'tahlapi'; }; - five.croatian = function() { return 'pet'; }; - five.czech = function() { return 'pět'; }; - five.dothraki = function() { return 'mek'; }; - five.dovah = function() { return 'hen'; }; - five.dutch = function() { return 'vijf'; }; - five.elvish = function(type) { - switch(type) { - case 'quenya': return 'lempë'; - case 'sindarin': return 'leben'; - default: return 'lempë'; + five.choctaw = function () { + return "tahlapi"; + }; + five.croatian = function () { + return "pet"; + }; + five.czech = function () { + return "pět"; + }; + five.dothraki = function () { + return "mek"; + }; + five.dovah = function () { + return "hen"; + }; + five.dutch = function () { + return "vijf"; + }; + five.elvish = function (type) { + switch (type) { + case "quenya": + return "lempë"; + case "sindarin": + return "leben"; + default: + return "lempë"; } }; - five.english = function() { return 'five'; }; - five.esperanto = function() { return 'kvin'; }; - five.estonian = function() { return 'viis'; }; - five.finnish = function() { return 'viisi'; }; - five.french = function() { return 'cinq'; }; - five.german = function() { return 'fünf'; }; - five.greek = function() { return 'πέντε'; }; - five.hebrew = function() { return 'חמש'; }; - five.hindi = function() { return 'पांच'; }; - five.hungarian = function() { return 'öt'; }; - five.icelandic = function() { return 'fimm'; }; - five.indonesian = function() { return 'lima'; }; - five.irish = function() { return 'cúig'; }; - five.italian = function() { return 'cinque'; }; - five.japanese = function() { return '五'; }; - five.kannada = function() { return 'ಐದು'; }; - five.klingon = function() { return 'vagh'; }; - five.korean = function() { return '오'; }; - five.latin = function() { return 'quinque'; }; - five.latvian = function() { return 'pieci'; }; - five.lithuanian = function() { return 'penki'; }; - five.maltese = function() { return 'ħamsa'; }; - five.mongolian = function() { return 'таван'; }; - five.nepali = function() { return 'पाँच'; }; - five.norwegian = function() { return 'fem'; }; - five.persian = function() { return 'پنج'; }; - five.piglatin = function() { return 'ivefay'; }; - five.polish = function() { return 'pięć'; }; - five.portuguese = function () { return 'cinco'; }; - five.punjabi = function () { return 'ਪੰਜ'; }; - five.romanian = function() { return 'cinci'; }; - five.russian = function() { return 'пять'; }; - five.serbian = function() { return 'pet'; }; - five.sinhala = function() { return 'පහ'; }; - five.slovakian = function() { return 'päť'; }; - five.slovenian = function() { return 'pet'; }; - five.spanish = function() { return 'cinco'; }; - five.swedish = function() { return 'fem'; }; - five.tamil = function() { return 'ஐந்து'; }; - five.telugu = function() { return 'ఐదు'; }; - five.turkish = function() { return 'beş'; }; - five.thai = function() { return 'ห้า'; }; - five.ukrainian = function() { return 'п’ять'; }; - five.urdu = function() {return 'پانچ';}; - five.welsh = function() { return 'pump'; }; - - five.morseCode = function() { return '.....'; }; - five.base = function(i) { return five().toString(i); } - five.binary = function() { return five.base(2); }; - five.octal = function() { return five.base(8); }; - five.hex = function() { return five.base(16); }; - - five.mdFive = function() { return '30056e1cab7a61d256fc8edd970d14f5'; }; - five.golden = function() { + five.english = function () { + return "five"; + }; + five.esperanto = function () { + return "kvin"; + }; + five.estonian = function () { + return "viis"; + }; + five.finnish = function () { + return "viisi"; + }; + five.french = function () { + return "cinq"; + }; + five.german = function () { + return "fünf"; + }; + five.greek = function () { + return "πέντε"; + }; + five.hebrew = function () { + return "חמש"; + }; + five.hindi = function () { + return "पांच"; + }; + five.hungarian = function () { + return "öt"; + }; + five.icelandic = function () { + return "fimm"; + }; + five.indonesian = function () { + return "lima"; + }; + five.irish = function () { + return "cúig"; + }; + five.italian = function () { + return "cinque"; + }; + five.japanese = function () { + return "五"; + }; + five.kannada = function () { + return "ಐದು"; + }; + five.klingon = function () { + return "vagh"; + }; + five.korean = function () { + return "오"; + }; + five.latin = function () { + return "quinque"; + }; + five.latvian = function () { + return "pieci"; + }; + five.lithuanian = function () { + return "penki"; + }; + five.maltese = function () { + return "ħamsa"; + }; + five.mongolian = function () { + return "таван"; + }; + five.nepali = function () { + return "पाँच"; + }; + five.norwegian = function () { + return "fem"; + }; + five.persian = function () { + return "پنج"; + }; + five.piglatin = function () { + return "ivefay"; + }; + five.polish = function () { + return "pięć"; + }; + five.portuguese = function () { + return "cinco"; + }; + five.punjabi = function () { + return "ਪੰਜ"; + }; + five.romanian = function () { + return "cinci"; + }; + five.russian = function () { + return "пять"; + }; + five.serbian = function () { + return "pet"; + }; + five.sinhala = function () { + return "පහ"; + }; + five.slovakian = function () { + return "päť"; + }; + five.slovenian = function () { + return "pet"; + }; + five.spanish = function () { + return "cinco"; + }; + five.swedish = function () { + return "fem"; + }; + five.tamil = function () { + return "ஐந்து"; + }; + five.telugu = function () { + return "ఐదు"; + }; + five.turkish = function () { + return "beş"; + }; + five.thai = function () { + return "ห้า"; + }; + five.ukrainian = function () { + return "п’ять"; + }; + five.urdu = function () { + return "پانچ"; + }; + five.welsh = function () { + return "pump"; + }; + + five.morseCode = function () { + return "....."; + }; + five.base = function (i) { + return five().toString(i); + }; + five.binary = function () { + return five.base(2); + }; + five.octal = function () { + return five.base(8); + }; + five.hex = function () { + return five.base(16); + }; + + five.mdFive = function () { + return "30056e1cab7a61d256fc8edd970d14f5"; + }; + five.golden = function () { // Φ or 'Phive' = 5 ^ .5 * .5 + .5 - var pointFive = five() / (five() + five()) + var pointFive = five() / (five() + five()); return Math.pow(five(), pointFive) * pointFive + pointFive; }; - five.factorial = function() { + five.factorial = function () { // returns 5*4*3*2*1 optimized at 500% normal factorial runtime; return 120; - } + }; - five.negative = function() { return -five(); }; - five.loud = function (lang) { return (lang && typeof five[lang] === 'function') ? five[lang]().toUpperCase() : five.english().toUpperCase();}; - five.smooth = function() { return 'S'; }; + five.negative = function () { + return -five(); + }; + five.loud = function (lang) { + return lang && typeof five[lang] === "function" + ? five[lang]().toUpperCase() + : five.english().toUpperCase(); + }; + five.smooth = function () { + return "S"; + }; - five.tooSlow = function() { + five.tooSlow = function () { var returnIn = new Date(new Date().valueOf() + 555); - do {} while(new Date() < returnIn); + do {} while (new Date() < returnIn); return five(); }; - five.emitter = function() { - var ee = new (require('events').EventEmitter); + five.emitter = function () { + var ee = new (require("events").EventEmitter)(); - setInterval(function() { - ee.emit('five', 5); + setInterval(function () { + ee.emit("five", 5); }, 5); return ee; }; - five.high = function() { return "o/"; }; + five.high = function () { + return "o/"; + }; + + five.isFive = function (a) { + return a === five(); + }; - five.isFive = function(a) { return a === five(); }; + five.map = function (array) { + return array.map(five); + }; + five.filter = function (array) { + return array.filter(five.isFive); + }; + five.reduce = function (array) { + return array.reduce(five); + }; - five.map = function(array) { return array.map(five); }; - five.filter = function(array) { return array.filter(five.isFive); }; - five.reduce = function(array) { return array.reduce(five); }; + five.fab = function () { + return [ + "Juwan Howard", + "Ray Jackson", + "Jimmy King", + "Jalen Rose", + "Chris Webber", + ]; + }; - five.fab = function() { - return ['Juwan Howard','Ray Jackson','Jimmy King','Jalen Rose','Chris Webber']; + five.jackson = function () { + return ["Jackie", "Tito", "Jermaine", "Marlon", "Michael"]; }; - five.jackson = function() { - return ['Jackie','Tito','Jermaine','Marlon','Michael']; + five.members = function () { + return [ + "Sean Conlon", + "Ritchie Neville", + "Scott Robinson", + "Jason 'J' Brown", + "Abz Love", + ]; }; - - five.members = function() { - return ['Sean Conlon', 'Ritchie Neville', 'Scott Robinson', 'Jason \'J\' Brown', 'Abz Love']; + + five.discography = function () { + return ["5ive", "Invincible", "Kingsize"]; }; - five.discography = function() { - return ['5ive', 'Invincible', 'Kingsize']; + five.singles = function () { + return [ + "Slam Dunk (Da Funk)", + "When the Lights Go Out", + "Got the Feelin'", + "Everybody Get Up", + "It's the Things You Do", + "Until the Time Is Through", + "If Ya Gettin' Down", + "Keep On Movin'", + "Don't Wanna Let You Go", + "We Will Rock You", + "Let's Dance", + "Closer to Me", + "Rock the Party", + "I Wish It Could Be Christmas Everyday", + ]; }; - five.singles = function() { - return ['Slam Dunk (Da Funk)', 'When the Lights Go Out', 'Got the Feelin\'', 'Everybody Get Up', 'It\'s the Things You Do', 'Until the Time Is Through', 'If Ya Gettin\' Down', 'Keep On Movin\'', 'Don\'t Wanna Let You Go', 'We Will Rock You', 'Let\'s Dance', 'Closer to Me', 'Rock the Party', 'I Wish It Could Be Christmas Everyday']; - } - - five.fiveFiveFive = function() { - return 'Interstella 5555: The 5tory of the 5ecret 5tar 5ystem'; - } + five.fiveFiveFive = function () { + return "Interstella 5555: The 5tory of the 5ecret 5tar 5ystem"; + }; - five.furious = function() { - return ['Tigress','Viper','Crane','Monkey','Mantis']; + five.furious = function () { + return ["Tigress", "Viper", "Crane", "Monkey", "Mantis"]; }; - five.famous = function() { - return ['Julian', 'Dick', 'George', 'Anne', 'Timmy']; + five.famous = function () { + return ["Julian", "Dick", "George", "Anne", "Timmy"]; }; /** * References "I got 5 on it" by Luniz. * http://en.wikipedia.org/wiki/I_Got_5_on_It */ - five.luniz = function() { + five.luniz = function () { return "I Got " + five() + " on It"; - } + }; - five.funk = function(){ - return five() + " bad boys with the power to rock you" - } + five.funk = function () { + return five() + " bad boys with the power to rock you"; + }; - five.async = function(callback) { - process.nextTick(function() { + five.async = function (callback) { + process.nextTick(function () { callback(null, five()); }); }; - five.r = function () { return '£5'; }; - - five.euro = function() { return '5€' }; - - five.dollar = function() { return '$5' }; + five.r = function () { + return "£5"; + }; - five.rupee = function(type) { - switch (type) { - case 'pakistani': return '5 Rs.'; - case 'indian': return '₹ 5'; - default: return '5 Rs.'; - } + five.euro = function () { + return "5€"; + }; + + five.dollar = function () { + return "$5"; + }; + + five.rupee = function (type) { + switch (type) { + case "pakistani": + return "5 Rs."; + case "indian": + return "₹ 5"; + default: + return "5 Rs."; + } }; - five.rot = function(word) { - if(typeof(word) != 'string') { + five.rot = function (word) { + if (typeof word != "string") { return word; } function replaceLetter(z) { - if('0' <= z && z <= '9') { - return ((parseInt(z)+5)%10).toString(); + if ("0" <= z && z <= "9") { + return ((parseInt(z) + 5) % 10).toString(); } - var aLetter = (z <= 'Z' ? 'A': 'a').charCodeAt(0); + var aLetter = (z <= "Z" ? "A" : "a").charCodeAt(0); var x = 5 + z.charCodeAt(0) - aLetter; x %= 26; - return String.fromCharCode(x+aLetter); + return String.fromCharCode(x + aLetter); } return word.replace(/[a-zA-Z0-9]/g, replaceLetter); }; - five.oclock = function() { return '🕔'; }; - - five.oclockSomewhere = function() { return '🍺'; }; + five.oclock = function () { + return "🕔"; + }; + + five.oclockSomewhere = function () { + return "🍺"; + }; - five.guys = function() { return '🍔'; }; - - five.bucks = function() { return '$' + five() + '.00'; }; + five.guys = function () { + return "🍔"; + }; + + five.bucks = function () { + return "$" + five() + ".00"; + }; five.valueOf = five; - if(typeof module !== 'undefined' && module.exports) { + if (typeof module !== "undefined" && module.exports) { module.exports = five; - } else if (typeof define === 'function' && define.amd){ + } else if (typeof define === "function" && define.amd) { define(five); } else if (window) { window.five = five; } -}()); +})(); diff --git a/index.js b/index.js index 977ca7b3..e301e7cb 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require('./five.js'); \ No newline at end of file +module.exports = require("./five.js"); diff --git a/test.js b/test.js index 6e837901..3dddc969 100755 --- a/test.js +++ b/test.js @@ -1,134 +1,246 @@ -var assert = require('assert'); -var five = require('./'); +var assert = require("assert"); +var five = require("./"); -assert.equal(5, five(), 'Five should give you five'); -assert.notEqual(6, five(), 'Five should not give you not five'); +assert.equal(5, five(), "Five should give you five"); +assert.notEqual(6, five(), "Five should not give you not five"); -assert.equal('The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.', five.law(), 'The Law of Fives should never be wrong'); +assert.equal( + "The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.", + five.law(), + "The Law of Fives should never be wrong" +); assert.equal(five.convertTo(5), 5); assert.equal(five.convertTo(3), 3); assert.equal(five.convertTo(665456), 665456); -assert.equal('⁵', five.upHigh(), 'An up high five should be a superscripted 5'); -assert.equal('₅', five.downLow(), 'A down low five should be a subscripted 5'); -assert.equal('V', five.roman(), 'A roman five should be a V'); - - -assert.equal('خمسة', five.arabic(), 'A arabic five should be خمسة'); -assert.equal('beş', five.azerbaijani(), 'A azerbaijani five should be beş'); -assert.equal('bost', five.basque(), 'A basque five should be bost'); -assert.equal('пяць', five.belarusian(), 'A belarusian five should be пяць'); -assert.equal('pet', five.bosnian(), 'A bosnian five should be pet'); -assert.equal('пет', five.bulgarian(), 'A bulgarian five should be пет'); -assert.equal('cinc', five.catalan(), 'A catalan five should be cinc'); -assert.equal('五', five.chinese(), 'A chinese five should be 五'); -assert.equal('wǔ', five.chinese('pinyin'), 'A chinese five in Pīnyīn should be wǔ'); -assert.equal('伍', five.chinese('financial'), 'A chinese five in financial contexts should be 伍'); -assert.equal('tahlapi', five.choctaw(), 'A choctaw five should be tahlapi'); -assert.equal('pet', five.croatian(), 'A croatian five should be pet'); -assert.equal('pět', five.czech(), 'A czech five should be pět'); -assert.equal('mek', five.dothraki(), 'A dothraki five should be mek'); -assert.equal('hen', five.dovah(), 'A dovah five should be hen'); -assert.equal('vijf', five.dutch(), 'A dutch five should be vijf'); -assert.equal('lempë', five.elvish(), 'An elvish five should be lempë'); -assert.equal('lempë', five.elvish('quenya'), 'An elvish five in Quenya should be lempë'); -assert.equal('leben', five.elvish('sindarin'), 'An elvish five in Sindarin should be leben'); -assert.equal('five', five.english(), 'A english five should be five'); -assert.equal('kvin', five.esperanto(), 'An esperanto five should be kvin'); -assert.equal('viis', five.estonian(), 'An estonian five should be viis'); -assert.equal('viisi', five.finnish(), 'A finnish five should be viisi'); -assert.equal('cinq', five.french(), 'A french five should be cinq'); -assert.equal('fünf', five.german(), 'A german five should be fünf'); -assert.equal('πέντε', five.greek(), 'A greek five should be πέντε'); -assert.equal('חמש', five.hebrew(), 'A hebrew five should be חמש'); -assert.equal('पांच', five.hindi(), 'A hindi five should be पांच'); -assert.equal('öt', five.hungarian(), 'A hungarian five should be öt'); -assert.equal('fimm', five.icelandic(), 'An icelandic five should be fimm'); -assert.equal('lima', five.indonesian(), 'A indonesian five should be lima'); -assert.equal('cúig', five.irish(), 'A irish five should be cúig'); -assert.equal('cinque', five.italian(), 'A italian five should be cinque'); -assert.equal('五', five.japanese(), 'A japanese five should be 五'); -assert.equal('ಐದು', five.kannada(), 'A kannada five should be ಐದು'); -assert.equal('vagh', five.klingon(), 'A klingon five should be vagh'); -assert.equal('오', five.korean(), 'A korean five should be 오'); -assert.equal('quinque', five.latin(), 'A latin five should be quinque'); -assert.equal('pieci', five.latvian(), 'A latvian five should be pieci'); -assert.equal('penki', five.lithuanian(), 'A lithuanian five should be penki'); -assert.equal('ħamsa', five.maltese(), ' A maltese five should be ħamsa'); -assert.equal('таван', five.mongolian(), 'A mongolian five should be таван'); -assert.equal('पाँच', five.nepali(), 'A nepali five should be पाँच'); -assert.equal('fem', five.norwegian(), 'A norwegian five should be fem'); -assert.equal('پنج', five.persian(), 'A persian five should be پنج'); -assert.equal('ivefay', five.piglatin(), 'A piglatin five should be ivefay'); -assert.equal('pięć', five.polish(), 'A polish five should be pięć'); -assert.equal('cinco', five.portuguese(), 'A portuguese five should be cinco'); -assert.equal('ਪੰਜ', five.punjabi(), 'A punjabi five should be ਪੰਜ'); -assert.equal('cinci', five.romanian(), 'A romanian five should be cinci'); -assert.equal('пять', five.russian(), 'A russian five should be пять'); -assert.equal('pet', five.serbian(), 'A serbian five should be pet'); -assert.equal('පහ', five.sinhala(), 'A sinhala five should be පහ'); -assert.equal('päť', five.slovakian(), 'A slovakian five should be päť'); -assert.equal('pet', five.slovenian(), 'A slovenian five should be pet'); -assert.equal('cinco', five.spanish(), 'A spanish five should be cinco'); -assert.equal('fem', five.swedish(), 'A swedish five should be fem'); -assert.equal('ஐந்து', five.tamil(), 'A tamil five should be ஐந்து'); -assert.equal('ఐదు', five.telugu(), 'A telugu five should be ఐదు'); -assert.equal('ห้า', five.thai(), 'A thai five should be ห้า'); -assert.equal('beş', five.turkish(), 'A turkish five should be beş'); -assert.equal('п’ять', five.ukrainian(), 'A ukrainian five should be п’ять'); -assert.equal('پانچ', five.urdu(), 'An urdu five should be پانچ'); - -assert.equal('.....', five.morseCode(), 'A five in morse code should be .....'); -assert.equal('10', five.base(5), 'A quinary five should be 10'); -assert.equal('11', five.base(4), 'An quaternary five should be 11') -assert.equal('101', five.binary(), 'A binary five should be 101'); -assert.equal('5', five.octal(), 'An octal five should be 5'); -assert.equal('5', five.hex(), 'An hexadecimal five should be 5'); - -assert.equal('30056e1cab7a61d256fc8edd970d14f5', five.mdFive(), 'md5 checksum of "five" should be 30056e1cab7a61d256fc8edd970d14f5'); -assert.equal('1.618033988749895', five.golden(), 'A golden five is Phive'); - -assert.equal('-5', five.negative(), 'A negative five should be -5'); -assert.equal('FIVE', five.loud(), 'A loud five should be FIVE'); -assert.equal('IVEFAY', five.loud('piglatin'), 'A loud five in Pig Latin should be IVEFAY'); -assert.equal('ПЯТЬ', five.loud('russian'), 'A loud five in Russian should be ПЯТЬ'); -assert.equal('S', five.smooth(), 'A smooth five should be S'); - -assert.equal('🕔', five.oclock(), 'A unicode symbol for five o\'clock should be U+1F554'); -assert.equal('🍺', five.oclockSomewhere(), 'A unicode symbol for \'It\'s five o\'clock somewhere\' should be U+1F37A'); -assert.equal('🍔', five.guys(), 'A unicode symbol for Five Guys should be U+1F354'); -assert.equal('$5.00', five.bucks(), 'Five bucks in USD should be $5.00'); - -assert.equal('o/', five.high(), 'A High five should be o/'); +assert.equal("⁵", five.upHigh(), "An up high five should be a superscripted 5"); +assert.equal("₅", five.downLow(), "A down low five should be a subscripted 5"); +assert.equal("V", five.roman(), "A roman five should be a V"); + +assert.equal("خمسة", five.arabic(), "A arabic five should be خمسة"); +assert.equal("beş", five.azerbaijani(), "A azerbaijani five should be beş"); +assert.equal("bost", five.basque(), "A basque five should be bost"); +assert.equal("пяць", five.belarusian(), "A belarusian five should be пяць"); +assert.equal("pet", five.bosnian(), "A bosnian five should be pet"); +assert.equal("пет", five.bulgarian(), "A bulgarian five should be пет"); +assert.equal("cinc", five.catalan(), "A catalan five should be cinc"); +assert.equal("五", five.chinese(), "A chinese five should be 五"); +assert.equal( + "wǔ", + five.chinese("pinyin"), + "A chinese five in Pīnyīn should be wǔ" +); +assert.equal( + "伍", + five.chinese("financial"), + "A chinese five in financial contexts should be 伍" +); +assert.equal("tahlapi", five.choctaw(), "A choctaw five should be tahlapi"); +assert.equal("pet", five.croatian(), "A croatian five should be pet"); +assert.equal("pět", five.czech(), "A czech five should be pět"); +assert.equal("mek", five.dothraki(), "A dothraki five should be mek"); +assert.equal("hen", five.dovah(), "A dovah five should be hen"); +assert.equal("vijf", five.dutch(), "A dutch five should be vijf"); +assert.equal("lempë", five.elvish(), "An elvish five should be lempë"); +assert.equal( + "lempë", + five.elvish("quenya"), + "An elvish five in Quenya should be lempë" +); +assert.equal( + "leben", + five.elvish("sindarin"), + "An elvish five in Sindarin should be leben" +); +assert.equal("five", five.english(), "A english five should be five"); +assert.equal("kvin", five.esperanto(), "An esperanto five should be kvin"); +assert.equal("viis", five.estonian(), "An estonian five should be viis"); +assert.equal("viisi", five.finnish(), "A finnish five should be viisi"); +assert.equal("cinq", five.french(), "A french five should be cinq"); +assert.equal("fünf", five.german(), "A german five should be fünf"); +assert.equal("πέντε", five.greek(), "A greek five should be πέντε"); +assert.equal("חמש", five.hebrew(), "A hebrew five should be חמש"); +assert.equal("पांच", five.hindi(), "A hindi five should be पांच"); +assert.equal("öt", five.hungarian(), "A hungarian five should be öt"); +assert.equal("fimm", five.icelandic(), "An icelandic five should be fimm"); +assert.equal("lima", five.indonesian(), "A indonesian five should be lima"); +assert.equal("cúig", five.irish(), "A irish five should be cúig"); +assert.equal("cinque", five.italian(), "A italian five should be cinque"); +assert.equal("五", five.japanese(), "A japanese five should be 五"); +assert.equal("ಐದು", five.kannada(), "A kannada five should be ಐದು"); +assert.equal("vagh", five.klingon(), "A klingon five should be vagh"); +assert.equal("오", five.korean(), "A korean five should be 오"); +assert.equal("quinque", five.latin(), "A latin five should be quinque"); +assert.equal("pieci", five.latvian(), "A latvian five should be pieci"); +assert.equal("penki", five.lithuanian(), "A lithuanian five should be penki"); +assert.equal("ħamsa", five.maltese(), " A maltese five should be ħamsa"); +assert.equal("таван", five.mongolian(), "A mongolian five should be таван"); +assert.equal("पाँच", five.nepali(), "A nepali five should be पाँच"); +assert.equal("fem", five.norwegian(), "A norwegian five should be fem"); +assert.equal("پنج", five.persian(), "A persian five should be پنج"); +assert.equal("ivefay", five.piglatin(), "A piglatin five should be ivefay"); +assert.equal("pięć", five.polish(), "A polish five should be pięć"); +assert.equal("cinco", five.portuguese(), "A portuguese five should be cinco"); +assert.equal("ਪੰਜ", five.punjabi(), "A punjabi five should be ਪੰਜ"); +assert.equal("cinci", five.romanian(), "A romanian five should be cinci"); +assert.equal("пять", five.russian(), "A russian five should be пять"); +assert.equal("pet", five.serbian(), "A serbian five should be pet"); +assert.equal("පහ", five.sinhala(), "A sinhala five should be පහ"); +assert.equal("päť", five.slovakian(), "A slovakian five should be päť"); +assert.equal("pet", five.slovenian(), "A slovenian five should be pet"); +assert.equal("cinco", five.spanish(), "A spanish five should be cinco"); +assert.equal("fem", five.swedish(), "A swedish five should be fem"); +assert.equal("ஐந்து", five.tamil(), "A tamil five should be ஐந்து"); +assert.equal("ఐదు", five.telugu(), "A telugu five should be ఐదు"); +assert.equal("ห้า", five.thai(), "A thai five should be ห้า"); +assert.equal("beş", five.turkish(), "A turkish five should be beş"); +assert.equal("п’ять", five.ukrainian(), "A ukrainian five should be п’ять"); +assert.equal("پانچ", five.urdu(), "An urdu five should be پانچ"); + +assert.equal(".....", five.morseCode(), "A five in morse code should be ....."); +assert.equal("10", five.base(5), "A quinary five should be 10"); +assert.equal("11", five.base(4), "An quaternary five should be 11"); +assert.equal("101", five.binary(), "A binary five should be 101"); +assert.equal("5", five.octal(), "An octal five should be 5"); +assert.equal("5", five.hex(), "An hexadecimal five should be 5"); + +assert.equal( + "30056e1cab7a61d256fc8edd970d14f5", + five.mdFive(), + 'md5 checksum of "five" should be 30056e1cab7a61d256fc8edd970d14f5' +); +assert.equal("1.618033988749895", five.golden(), "A golden five is Phive"); + +assert.equal("-5", five.negative(), "A negative five should be -5"); +assert.equal("FIVE", five.loud(), "A loud five should be FIVE"); +assert.equal( + "IVEFAY", + five.loud("piglatin"), + "A loud five in Pig Latin should be IVEFAY" +); +assert.equal( + "ПЯТЬ", + five.loud("russian"), + "A loud five in Russian should be ПЯТЬ" +); +assert.equal("S", five.smooth(), "A smooth five should be S"); + +assert.equal( + "🕔", + five.oclock(), + "A unicode symbol for five o'clock should be U+1F554" +); +assert.equal( + "🍺", + five.oclockSomewhere(), + "A unicode symbol for 'It's five o'clock somewhere' should be U+1F37A" +); +assert.equal( + "🍔", + five.guys(), + "A unicode symbol for Five Guys should be U+1F354" +); +assert.equal("$5.00", five.bucks(), "Five bucks in USD should be $5.00"); + +assert.equal("o/", five.high(), "A High five should be o/"); var now = new Date().valueOf(); var slowFive = five.tooSlow(); var finishes = new Date().valueOf(); -assert.equal(5, slowFive, 'A too slow five should still be five'); -assert.ok((finishes - now) > 500, 'A too slow five should take longer than 500 milliseconds to be returned, blocking execution and generally being a bad idea'); - - -assert.equal(JSON.stringify(['Jackie','Tito','Jermaine','Marlon','Michael']), JSON.stringify(five.jackson()), 'A Jackson five should be the five members of the 70\'s pop family group the Jackson 5'); - -assert.equal(JSON.stringify(['Juwan Howard','Ray Jackson','Jimmy King','Jalen Rose','Chris Webber']), JSON.stringify(five.fab()), 'A fab five should be the 1991-1993 Michigan Mens Basketball Team'); - -assert.equal(JSON.stringify(['Sean Conlon', 'Ritchie Neville', 'Scott Robinson', 'Jason \'J\' Brown', 'Abz Love']), JSON.stringify(five.members()), 'A five five should be the 90\'s boy band 5ive'); - -assert.equal(JSON.stringify(['5ive', 'Invincible', 'Kingsize']), JSON.stringify(five.discography()), 'A five discography should be the studio albums released by the 90\'s boy band 5ive'); - -assert.equal(JSON.stringify(['Slam Dunk (Da Funk)', 'When the Lights Go Out', 'Got the Feelin\'', 'Everybody Get Up', 'It\'s the Things You Do', 'Until the Time Is Through', 'If Ya Gettin\' Down', 'Keep On Movin\'', 'Don\'t Wanna Let You Go', 'We Will Rock You', 'Let\'s Dance', 'Closer to Me', 'Rock the Party', 'I Wish It Could Be Christmas Everyday']), JSON.stringify(five.singles()), 'A five singles should be the singles released by the 90\'s boy band 5ive'); - -assert.equal(JSON.stringify(['Tigress','Viper','Crane','Monkey','Mantis']), JSON.stringify(five.furious()), 'A Furious five should be the five fictional members of the ninja group Furious Five from the movie Kung-Fu Panda'); - -assert.equal(JSON.stringify(['Julian', 'Dick', 'George', 'Anne', 'Timmy']), JSON.stringify(five.famous()), 'A Famous five should be the five central characters of the series of Enid Blighton novels'); - -assert.equal('Interstella 5555: The 5tory of the 5ecret 5tar 5ystem', five.fiveFiveFive(), 'FiveFiveFiveFive should be Interstella 5555: The 5tory of the 5ecret 5tar 5ystem'); - -assert.equal(five.luniz(), 'I Got 5 on It', 'A Luniz five should be the song title of their most famous hit'); - -assert.equal(five.funk(), '5 bad boys with the power to rock you', 'A funked five should be a group of bad boys with the power to rock you'); +assert.equal(5, slowFive, "A too slow five should still be five"); +assert.ok( + finishes - now > 500, + "A too slow five should take longer than 500 milliseconds to be returned, blocking execution and generally being a bad idea" +); + +assert.equal( + JSON.stringify(["Jackie", "Tito", "Jermaine", "Marlon", "Michael"]), + JSON.stringify(five.jackson()), + "A Jackson five should be the five members of the 70's pop family group the Jackson 5" +); + +assert.equal( + JSON.stringify([ + "Juwan Howard", + "Ray Jackson", + "Jimmy King", + "Jalen Rose", + "Chris Webber", + ]), + JSON.stringify(five.fab()), + "A fab five should be the 1991-1993 Michigan Mens Basketball Team" +); + +assert.equal( + JSON.stringify([ + "Sean Conlon", + "Ritchie Neville", + "Scott Robinson", + "Jason 'J' Brown", + "Abz Love", + ]), + JSON.stringify(five.members()), + "A five five should be the 90's boy band 5ive" +); + +assert.equal( + JSON.stringify(["5ive", "Invincible", "Kingsize"]), + JSON.stringify(five.discography()), + "A five discography should be the studio albums released by the 90's boy band 5ive" +); + +assert.equal( + JSON.stringify([ + "Slam Dunk (Da Funk)", + "When the Lights Go Out", + "Got the Feelin'", + "Everybody Get Up", + "It's the Things You Do", + "Until the Time Is Through", + "If Ya Gettin' Down", + "Keep On Movin'", + "Don't Wanna Let You Go", + "We Will Rock You", + "Let's Dance", + "Closer to Me", + "Rock the Party", + "I Wish It Could Be Christmas Everyday", + ]), + JSON.stringify(five.singles()), + "A five singles should be the singles released by the 90's boy band 5ive" +); + +assert.equal( + JSON.stringify(["Tigress", "Viper", "Crane", "Monkey", "Mantis"]), + JSON.stringify(five.furious()), + "A Furious five should be the five fictional members of the ninja group Furious Five from the movie Kung-Fu Panda" +); + +assert.equal( + JSON.stringify(["Julian", "Dick", "George", "Anne", "Timmy"]), + JSON.stringify(five.famous()), + "A Famous five should be the five central characters of the series of Enid Blighton novels" +); + +assert.equal( + "Interstella 5555: The 5tory of the 5ecret 5tar 5ystem", + five.fiveFiveFive(), + "FiveFiveFiveFive should be Interstella 5555: The 5tory of the 5ecret 5tar 5ystem" +); + +assert.equal( + five.luniz(), + "I Got 5 on It", + "A Luniz five should be the song title of their most famous hit" +); + +assert.equal( + five.funk(), + "5 bad boys with the power to rock you", + "A funked five should be a group of bad boys with the power to rock you" +); assert.equal(true, five.isFive(five())); assert.equal(false, five.isFive(10)); @@ -137,53 +249,67 @@ assert.equal(JSON.stringify([5, 5]), JSON.stringify(five.filter([5, true, 5]))); assert.equal(JSON.stringify([5, 5, 5]), JSON.stringify(five.map([1, 2, 3]))); assert.equal(5, five.reduce([1, 2, 3])); -assert.equal('£5', five.r(), 'A fiver should be 5 GBP'); - -assert.equal('5€', five.euro()); - -assert.equal('$5', five.dollar()); - -assert.equal('5 Rs.', five.rupee('pakistani')); -assert.equal('₹ 5', five.rupee('indian')); -assert.equal('5 Rs.', five.rupee()); - -assert.equal('5678901234', five.rot('0123456789'), 'Numbers should be rotated'); -assert.equal('fghijklmnopqrstuvwxyzabcde', five.rot('abcdefghijklmnopqrstuvwxyz'), 'Small letters should be rotated'); -assert.equal('FGHIJKLMNOPQRSTUVWXYZABCDE', five.rot('ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'Capital letters too'); -assert.equal('$_$ -,- @.@?', five.rot('$_$ -,- @.@?'), 'Emoticons should not be rotated'); +assert.equal("£5", five.r(), "A fiver should be 5 GBP"); + +assert.equal("5€", five.euro()); + +assert.equal("$5", five.dollar()); + +assert.equal("5 Rs.", five.rupee("pakistani")); +assert.equal("₹ 5", five.rupee("indian")); +assert.equal("5 Rs.", five.rupee()); + +assert.equal("5678901234", five.rot("0123456789"), "Numbers should be rotated"); +assert.equal( + "fghijklmnopqrstuvwxyzabcde", + five.rot("abcdefghijklmnopqrstuvwxyz"), + "Small letters should be rotated" +); +assert.equal( + "FGHIJKLMNOPQRSTUVWXYZABCDE", + five.rot("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), + "Capital letters too" +); +assert.equal( + "$_$ -,- @.@?", + five.rot("$_$ -,- @.@?"), + "Emoticons should not be rotated" +); assert.equal(five * five, 25); assert.equal(five + five, 10); assert.equal(five / five, 1); assert.equal(five - five, 0); -assert.equal((five / five) * (five), five); +assert.equal((five / five) * five, five); assert.equal(120, five.factorial()); var fiveEmitter = five.emitter(); var emitterTested = false; -fiveEmitter.on('five', function(e) { - assert.equal(5, e, 'Five event emitter should only emit 5'); +fiveEmitter.on("five", function (e) { + assert.equal(5, e, "Five event emitter should only emit 5"); emitterTested = true; }); -setTimeout(function() { - if(!emitterTested) { - console.error('The five event emitter did something unexpected! I hope you\'re not using this feature in production'); +setTimeout(function () { + if (!emitterTested) { + console.error( + "The five event emitter did something unexpected! I hope you're not using this feature in production" + ); process.exit(1); } process.exit(0); }, 100); var asyncTests = 1; -five.async(function(err, five) { - assert.equal(err, null, 'Async should not result in an error.'); - assert.equal(five, 5, 'Async should pass 5 to callback.'); - asyncTests--; +five.async(function (err, five) { + assert.equal(err, null, "Async should not result in an error."); + assert.equal(five, 5, "Async should pass 5 to callback."); + asyncTests--; }); -setInterval(function() { - if (!asyncTests) { - process.exit(0); - } +setInterval(function () { + if (!asyncTests) { + process.exit(0); + } }, 100); From 960415e1bf930dca4b4833436bcf5f72e31d4731 Mon Sep 17 00:00:00 2001 From: Ali Sajid Imami <395482+AliSajid@users.noreply.github.com> Date: Sat, 5 Nov 2022 19:40:35 +0000 Subject: [PATCH 3/3] Revert "reformatted with prettier" This reverts commit f9c8ae7682d04b9d9d18dafe095770a410f240cf. --- five.js | 515 +++++++++++++++++-------------------------------------- index.js | 2 +- test.js | 420 ++++++++++++++++----------------------------- 3 files changed, 303 insertions(+), 634 deletions(-) diff --git a/five.js b/five.js index ca7395cb..d59f600e 100755 --- a/five.js +++ b/five.js @@ -1,446 +1,241 @@ (function () { - var five = function () { - return 5; - }; + + var five = function() { return 5; }; // Quote: Malaclypse the Younger, Principia Discordia, Page 00016 - five.law = function () { - return "The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong."; - }; + five.law = function() { return 'The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.'; }; - five.upHigh = function () { - return "⁵"; - }; - five.downLow = function () { - return "₅"; - }; - five.roman = function () { - return "V"; - }; + five.upHigh = function() { return '⁵'; }; + five.downLow = function() { return '₅'; }; + five.roman = function() { return 'V'; }; - five.convertTo = function (anotherNumber) { + five.convertTo = function(anotherNumber) { // If you need other numbers I'd strongly suggest you call // this function when your app starts up and cache the result. var oneFifthOfFive = five() / five(); - while (anotherNumber < oneFifthOfFive) { + while(anotherNumber < oneFifthOfFive) { anotherNumber += oneFifthOfFive; } return anotherNumber; }; - five.arabic = function () { - return "خمسة"; - }; - five.azerbaijani = function () { - return "beş"; - }; - five.basque = function () { - return "bost"; - }; - five.belarusian = function () { - return "пяць"; - }; - five.bosnian = function () { - return "pet"; - }; - five.bulgarian = function () { - return "пет"; - }; - five.catalan = function () { - return "cinc"; - }; - five.chinese = function (type) { - switch (type) { - case "pinyin": - return "wǔ"; - case "financial": - return "伍"; - default: - return "五"; + five.arabic = function() { return 'خمسة'; }; + five.azerbaijani = function() { return 'beş'; }; + five.basque = function() { return 'bost'; }; + five.belarusian = function() { return 'пяць'; }; + five.bosnian = function() { return 'pet'; }; + five.bulgarian = function() { return 'пет'; }; + five.catalan = function() { return 'cinc'; }; + five.chinese = function(type) { + switch(type) { + case 'pinyin': return 'wǔ'; + case 'financial': return '伍'; + default: return '五'; } }; - five.choctaw = function () { - return "tahlapi"; - }; - five.croatian = function () { - return "pet"; - }; - five.czech = function () { - return "pět"; - }; - five.dothraki = function () { - return "mek"; - }; - five.dovah = function () { - return "hen"; - }; - five.dutch = function () { - return "vijf"; - }; - five.elvish = function (type) { - switch (type) { - case "quenya": - return "lempë"; - case "sindarin": - return "leben"; - default: - return "lempë"; + five.choctaw = function() { return 'tahlapi'; }; + five.croatian = function() { return 'pet'; }; + five.czech = function() { return 'pět'; }; + five.dothraki = function() { return 'mek'; }; + five.dovah = function() { return 'hen'; }; + five.dutch = function() { return 'vijf'; }; + five.elvish = function(type) { + switch(type) { + case 'quenya': return 'lempë'; + case 'sindarin': return 'leben'; + default: return 'lempë'; } }; - five.english = function () { - return "five"; - }; - five.esperanto = function () { - return "kvin"; - }; - five.estonian = function () { - return "viis"; - }; - five.finnish = function () { - return "viisi"; - }; - five.french = function () { - return "cinq"; - }; - five.german = function () { - return "fünf"; - }; - five.greek = function () { - return "πέντε"; - }; - five.hebrew = function () { - return "חמש"; - }; - five.hindi = function () { - return "पांच"; - }; - five.hungarian = function () { - return "öt"; - }; - five.icelandic = function () { - return "fimm"; - }; - five.indonesian = function () { - return "lima"; - }; - five.irish = function () { - return "cúig"; - }; - five.italian = function () { - return "cinque"; - }; - five.japanese = function () { - return "五"; - }; - five.kannada = function () { - return "ಐದು"; - }; - five.klingon = function () { - return "vagh"; - }; - five.korean = function () { - return "오"; - }; - five.latin = function () { - return "quinque"; - }; - five.latvian = function () { - return "pieci"; - }; - five.lithuanian = function () { - return "penki"; - }; - five.maltese = function () { - return "ħamsa"; - }; - five.mongolian = function () { - return "таван"; - }; - five.nepali = function () { - return "पाँच"; - }; - five.norwegian = function () { - return "fem"; - }; - five.persian = function () { - return "پنج"; - }; - five.piglatin = function () { - return "ivefay"; - }; - five.polish = function () { - return "pięć"; - }; - five.portuguese = function () { - return "cinco"; - }; - five.punjabi = function () { - return "ਪੰਜ"; - }; - five.romanian = function () { - return "cinci"; - }; - five.russian = function () { - return "пять"; - }; - five.serbian = function () { - return "pet"; - }; - five.sinhala = function () { - return "පහ"; - }; - five.slovakian = function () { - return "päť"; - }; - five.slovenian = function () { - return "pet"; - }; - five.spanish = function () { - return "cinco"; - }; - five.swedish = function () { - return "fem"; - }; - five.tamil = function () { - return "ஐந்து"; - }; - five.telugu = function () { - return "ఐదు"; - }; - five.turkish = function () { - return "beş"; - }; - five.thai = function () { - return "ห้า"; - }; - five.ukrainian = function () { - return "п’ять"; - }; - five.urdu = function () { - return "پانچ"; - }; - five.welsh = function () { - return "pump"; - }; - - five.morseCode = function () { - return "....."; - }; - five.base = function (i) { - return five().toString(i); - }; - five.binary = function () { - return five.base(2); - }; - five.octal = function () { - return five.base(8); - }; - five.hex = function () { - return five.base(16); - }; - - five.mdFive = function () { - return "30056e1cab7a61d256fc8edd970d14f5"; - }; - five.golden = function () { + five.english = function() { return 'five'; }; + five.esperanto = function() { return 'kvin'; }; + five.estonian = function() { return 'viis'; }; + five.finnish = function() { return 'viisi'; }; + five.french = function() { return 'cinq'; }; + five.german = function() { return 'fünf'; }; + five.greek = function() { return 'πέντε'; }; + five.hebrew = function() { return 'חמש'; }; + five.hindi = function() { return 'पांच'; }; + five.hungarian = function() { return 'öt'; }; + five.icelandic = function() { return 'fimm'; }; + five.indonesian = function() { return 'lima'; }; + five.irish = function() { return 'cúig'; }; + five.italian = function() { return 'cinque'; }; + five.japanese = function() { return '五'; }; + five.kannada = function() { return 'ಐದು'; }; + five.klingon = function() { return 'vagh'; }; + five.korean = function() { return '오'; }; + five.latin = function() { return 'quinque'; }; + five.latvian = function() { return 'pieci'; }; + five.lithuanian = function() { return 'penki'; }; + five.maltese = function() { return 'ħamsa'; }; + five.mongolian = function() { return 'таван'; }; + five.nepali = function() { return 'पाँच'; }; + five.norwegian = function() { return 'fem'; }; + five.persian = function() { return 'پنج'; }; + five.piglatin = function() { return 'ivefay'; }; + five.polish = function() { return 'pięć'; }; + five.portuguese = function () { return 'cinco'; }; + five.punjabi = function () { return 'ਪੰਜ'; }; + five.romanian = function() { return 'cinci'; }; + five.russian = function() { return 'пять'; }; + five.serbian = function() { return 'pet'; }; + five.sinhala = function() { return 'පහ'; }; + five.slovakian = function() { return 'päť'; }; + five.slovenian = function() { return 'pet'; }; + five.spanish = function() { return 'cinco'; }; + five.swedish = function() { return 'fem'; }; + five.tamil = function() { return 'ஐந்து'; }; + five.telugu = function() { return 'ఐదు'; }; + five.turkish = function() { return 'beş'; }; + five.thai = function() { return 'ห้า'; }; + five.ukrainian = function() { return 'п’ять'; }; + five.urdu = function() {return 'پانچ';}; + five.welsh = function() { return 'pump'; }; + + five.morseCode = function() { return '.....'; }; + five.base = function(i) { return five().toString(i); } + five.binary = function() { return five.base(2); }; + five.octal = function() { return five.base(8); }; + five.hex = function() { return five.base(16); }; + + five.mdFive = function() { return '30056e1cab7a61d256fc8edd970d14f5'; }; + five.golden = function() { // Φ or 'Phive' = 5 ^ .5 * .5 + .5 - var pointFive = five() / (five() + five()); + var pointFive = five() / (five() + five()) return Math.pow(five(), pointFive) * pointFive + pointFive; }; - five.factorial = function () { + five.factorial = function() { // returns 5*4*3*2*1 optimized at 500% normal factorial runtime; return 120; - }; + } - five.negative = function () { - return -five(); - }; - five.loud = function (lang) { - return lang && typeof five[lang] === "function" - ? five[lang]().toUpperCase() - : five.english().toUpperCase(); - }; - five.smooth = function () { - return "S"; - }; + five.negative = function() { return -five(); }; + five.loud = function (lang) { return (lang && typeof five[lang] === 'function') ? five[lang]().toUpperCase() : five.english().toUpperCase();}; + five.smooth = function() { return 'S'; }; - five.tooSlow = function () { + five.tooSlow = function() { var returnIn = new Date(new Date().valueOf() + 555); - do {} while (new Date() < returnIn); + do {} while(new Date() < returnIn); return five(); }; - five.emitter = function () { - var ee = new (require("events").EventEmitter)(); + five.emitter = function() { + var ee = new (require('events').EventEmitter); - setInterval(function () { - ee.emit("five", 5); + setInterval(function() { + ee.emit('five', 5); }, 5); return ee; }; - five.high = function () { - return "o/"; - }; - - five.isFive = function (a) { - return a === five(); - }; + five.high = function() { return "o/"; }; - five.map = function (array) { - return array.map(five); - }; - five.filter = function (array) { - return array.filter(five.isFive); - }; - five.reduce = function (array) { - return array.reduce(five); - }; + five.isFive = function(a) { return a === five(); }; - five.fab = function () { - return [ - "Juwan Howard", - "Ray Jackson", - "Jimmy King", - "Jalen Rose", - "Chris Webber", - ]; - }; + five.map = function(array) { return array.map(five); }; + five.filter = function(array) { return array.filter(five.isFive); }; + five.reduce = function(array) { return array.reduce(five); }; - five.jackson = function () { - return ["Jackie", "Tito", "Jermaine", "Marlon", "Michael"]; + five.fab = function() { + return ['Juwan Howard','Ray Jackson','Jimmy King','Jalen Rose','Chris Webber']; }; - five.members = function () { - return [ - "Sean Conlon", - "Ritchie Neville", - "Scott Robinson", - "Jason 'J' Brown", - "Abz Love", - ]; + five.jackson = function() { + return ['Jackie','Tito','Jermaine','Marlon','Michael']; }; - - five.discography = function () { - return ["5ive", "Invincible", "Kingsize"]; + + five.members = function() { + return ['Sean Conlon', 'Ritchie Neville', 'Scott Robinson', 'Jason \'J\' Brown', 'Abz Love']; }; - five.singles = function () { - return [ - "Slam Dunk (Da Funk)", - "When the Lights Go Out", - "Got the Feelin'", - "Everybody Get Up", - "It's the Things You Do", - "Until the Time Is Through", - "If Ya Gettin' Down", - "Keep On Movin'", - "Don't Wanna Let You Go", - "We Will Rock You", - "Let's Dance", - "Closer to Me", - "Rock the Party", - "I Wish It Could Be Christmas Everyday", - ]; + five.discography = function() { + return ['5ive', 'Invincible', 'Kingsize']; }; - five.fiveFiveFive = function () { - return "Interstella 5555: The 5tory of the 5ecret 5tar 5ystem"; - }; + five.singles = function() { + return ['Slam Dunk (Da Funk)', 'When the Lights Go Out', 'Got the Feelin\'', 'Everybody Get Up', 'It\'s the Things You Do', 'Until the Time Is Through', 'If Ya Gettin\' Down', 'Keep On Movin\'', 'Don\'t Wanna Let You Go', 'We Will Rock You', 'Let\'s Dance', 'Closer to Me', 'Rock the Party', 'I Wish It Could Be Christmas Everyday']; + } + + five.fiveFiveFive = function() { + return 'Interstella 5555: The 5tory of the 5ecret 5tar 5ystem'; + } - five.furious = function () { - return ["Tigress", "Viper", "Crane", "Monkey", "Mantis"]; + five.furious = function() { + return ['Tigress','Viper','Crane','Monkey','Mantis']; }; - five.famous = function () { - return ["Julian", "Dick", "George", "Anne", "Timmy"]; + five.famous = function() { + return ['Julian', 'Dick', 'George', 'Anne', 'Timmy']; }; /** * References "I got 5 on it" by Luniz. * http://en.wikipedia.org/wiki/I_Got_5_on_It */ - five.luniz = function () { + five.luniz = function() { return "I Got " + five() + " on It"; - }; + } - five.funk = function () { - return five() + " bad boys with the power to rock you"; - }; + five.funk = function(){ + return five() + " bad boys with the power to rock you" + } - five.async = function (callback) { - process.nextTick(function () { + five.async = function(callback) { + process.nextTick(function() { callback(null, five()); }); }; - five.r = function () { - return "£5"; - }; - - five.euro = function () { - return "5€"; - }; + five.r = function () { return '£5'; }; + + five.euro = function() { return '5€' }; + + five.dollar = function() { return '$5' }; - five.dollar = function () { - return "$5"; - }; - - five.rupee = function (type) { - switch (type) { - case "pakistani": - return "5 Rs."; - case "indian": - return "₹ 5"; - default: - return "5 Rs."; - } + five.rupee = function(type) { + switch (type) { + case 'pakistani': return '5 Rs.'; + case 'indian': return '₹ 5'; + default: return '5 Rs.'; + } }; - five.rot = function (word) { - if (typeof word != "string") { + five.rot = function(word) { + if(typeof(word) != 'string') { return word; } function replaceLetter(z) { - if ("0" <= z && z <= "9") { - return ((parseInt(z) + 5) % 10).toString(); + if('0' <= z && z <= '9') { + return ((parseInt(z)+5)%10).toString(); } - var aLetter = (z <= "Z" ? "A" : "a").charCodeAt(0); + var aLetter = (z <= 'Z' ? 'A': 'a').charCodeAt(0); var x = 5 + z.charCodeAt(0) - aLetter; x %= 26; - return String.fromCharCode(x + aLetter); + return String.fromCharCode(x+aLetter); } return word.replace(/[a-zA-Z0-9]/g, replaceLetter); }; - five.oclock = function () { - return "🕔"; - }; - - five.oclockSomewhere = function () { - return "🍺"; - }; + five.oclock = function() { return '🕔'; }; + + five.oclockSomewhere = function() { return '🍺'; }; - five.guys = function () { - return "🍔"; - }; - - five.bucks = function () { - return "$" + five() + ".00"; - }; + five.guys = function() { return '🍔'; }; + + five.bucks = function() { return '$' + five() + '.00'; }; five.valueOf = five; - if (typeof module !== "undefined" && module.exports) { + if(typeof module !== 'undefined' && module.exports) { module.exports = five; - } else if (typeof define === "function" && define.amd) { + } else if (typeof define === 'function' && define.amd){ define(five); } else if (window) { window.five = five; } -})(); +}()); diff --git a/index.js b/index.js index e301e7cb..977ca7b3 100644 --- a/index.js +++ b/index.js @@ -1 +1 @@ -module.exports = require("./five.js"); +module.exports = require('./five.js'); \ No newline at end of file diff --git a/test.js b/test.js index 3dddc969..6e837901 100755 --- a/test.js +++ b/test.js @@ -1,246 +1,134 @@ -var assert = require("assert"); -var five = require("./"); +var assert = require('assert'); +var five = require('./'); -assert.equal(5, five(), "Five should give you five"); -assert.notEqual(6, five(), "Five should not give you not five"); +assert.equal(5, five(), 'Five should give you five'); +assert.notEqual(6, five(), 'Five should not give you not five'); -assert.equal( - "The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.", - five.law(), - "The Law of Fives should never be wrong" -); +assert.equal('The Law of Fives states simply that: All things happen in fives, or are divisible by or are multiples of five, or are somehow directly or indirectly appropriate to 5. The Law of Fives is never wrong.', five.law(), 'The Law of Fives should never be wrong'); assert.equal(five.convertTo(5), 5); assert.equal(five.convertTo(3), 3); assert.equal(five.convertTo(665456), 665456); -assert.equal("⁵", five.upHigh(), "An up high five should be a superscripted 5"); -assert.equal("₅", five.downLow(), "A down low five should be a subscripted 5"); -assert.equal("V", five.roman(), "A roman five should be a V"); - -assert.equal("خمسة", five.arabic(), "A arabic five should be خمسة"); -assert.equal("beş", five.azerbaijani(), "A azerbaijani five should be beş"); -assert.equal("bost", five.basque(), "A basque five should be bost"); -assert.equal("пяць", five.belarusian(), "A belarusian five should be пяць"); -assert.equal("pet", five.bosnian(), "A bosnian five should be pet"); -assert.equal("пет", five.bulgarian(), "A bulgarian five should be пет"); -assert.equal("cinc", five.catalan(), "A catalan five should be cinc"); -assert.equal("五", five.chinese(), "A chinese five should be 五"); -assert.equal( - "wǔ", - five.chinese("pinyin"), - "A chinese five in Pīnyīn should be wǔ" -); -assert.equal( - "伍", - five.chinese("financial"), - "A chinese five in financial contexts should be 伍" -); -assert.equal("tahlapi", five.choctaw(), "A choctaw five should be tahlapi"); -assert.equal("pet", five.croatian(), "A croatian five should be pet"); -assert.equal("pět", five.czech(), "A czech five should be pět"); -assert.equal("mek", five.dothraki(), "A dothraki five should be mek"); -assert.equal("hen", five.dovah(), "A dovah five should be hen"); -assert.equal("vijf", five.dutch(), "A dutch five should be vijf"); -assert.equal("lempë", five.elvish(), "An elvish five should be lempë"); -assert.equal( - "lempë", - five.elvish("quenya"), - "An elvish five in Quenya should be lempë" -); -assert.equal( - "leben", - five.elvish("sindarin"), - "An elvish five in Sindarin should be leben" -); -assert.equal("five", five.english(), "A english five should be five"); -assert.equal("kvin", five.esperanto(), "An esperanto five should be kvin"); -assert.equal("viis", five.estonian(), "An estonian five should be viis"); -assert.equal("viisi", five.finnish(), "A finnish five should be viisi"); -assert.equal("cinq", five.french(), "A french five should be cinq"); -assert.equal("fünf", five.german(), "A german five should be fünf"); -assert.equal("πέντε", five.greek(), "A greek five should be πέντε"); -assert.equal("חמש", five.hebrew(), "A hebrew five should be חמש"); -assert.equal("पांच", five.hindi(), "A hindi five should be पांच"); -assert.equal("öt", five.hungarian(), "A hungarian five should be öt"); -assert.equal("fimm", five.icelandic(), "An icelandic five should be fimm"); -assert.equal("lima", five.indonesian(), "A indonesian five should be lima"); -assert.equal("cúig", five.irish(), "A irish five should be cúig"); -assert.equal("cinque", five.italian(), "A italian five should be cinque"); -assert.equal("五", five.japanese(), "A japanese five should be 五"); -assert.equal("ಐದು", five.kannada(), "A kannada five should be ಐದು"); -assert.equal("vagh", five.klingon(), "A klingon five should be vagh"); -assert.equal("오", five.korean(), "A korean five should be 오"); -assert.equal("quinque", five.latin(), "A latin five should be quinque"); -assert.equal("pieci", five.latvian(), "A latvian five should be pieci"); -assert.equal("penki", five.lithuanian(), "A lithuanian five should be penki"); -assert.equal("ħamsa", five.maltese(), " A maltese five should be ħamsa"); -assert.equal("таван", five.mongolian(), "A mongolian five should be таван"); -assert.equal("पाँच", five.nepali(), "A nepali five should be पाँच"); -assert.equal("fem", five.norwegian(), "A norwegian five should be fem"); -assert.equal("پنج", five.persian(), "A persian five should be پنج"); -assert.equal("ivefay", five.piglatin(), "A piglatin five should be ivefay"); -assert.equal("pięć", five.polish(), "A polish five should be pięć"); -assert.equal("cinco", five.portuguese(), "A portuguese five should be cinco"); -assert.equal("ਪੰਜ", five.punjabi(), "A punjabi five should be ਪੰਜ"); -assert.equal("cinci", five.romanian(), "A romanian five should be cinci"); -assert.equal("пять", five.russian(), "A russian five should be пять"); -assert.equal("pet", five.serbian(), "A serbian five should be pet"); -assert.equal("පහ", five.sinhala(), "A sinhala five should be පහ"); -assert.equal("päť", five.slovakian(), "A slovakian five should be päť"); -assert.equal("pet", five.slovenian(), "A slovenian five should be pet"); -assert.equal("cinco", five.spanish(), "A spanish five should be cinco"); -assert.equal("fem", five.swedish(), "A swedish five should be fem"); -assert.equal("ஐந்து", five.tamil(), "A tamil five should be ஐந்து"); -assert.equal("ఐదు", five.telugu(), "A telugu five should be ఐదు"); -assert.equal("ห้า", five.thai(), "A thai five should be ห้า"); -assert.equal("beş", five.turkish(), "A turkish five should be beş"); -assert.equal("п’ять", five.ukrainian(), "A ukrainian five should be п’ять"); -assert.equal("پانچ", five.urdu(), "An urdu five should be پانچ"); - -assert.equal(".....", five.morseCode(), "A five in morse code should be ....."); -assert.equal("10", five.base(5), "A quinary five should be 10"); -assert.equal("11", five.base(4), "An quaternary five should be 11"); -assert.equal("101", five.binary(), "A binary five should be 101"); -assert.equal("5", five.octal(), "An octal five should be 5"); -assert.equal("5", five.hex(), "An hexadecimal five should be 5"); - -assert.equal( - "30056e1cab7a61d256fc8edd970d14f5", - five.mdFive(), - 'md5 checksum of "five" should be 30056e1cab7a61d256fc8edd970d14f5' -); -assert.equal("1.618033988749895", five.golden(), "A golden five is Phive"); - -assert.equal("-5", five.negative(), "A negative five should be -5"); -assert.equal("FIVE", five.loud(), "A loud five should be FIVE"); -assert.equal( - "IVEFAY", - five.loud("piglatin"), - "A loud five in Pig Latin should be IVEFAY" -); -assert.equal( - "ПЯТЬ", - five.loud("russian"), - "A loud five in Russian should be ПЯТЬ" -); -assert.equal("S", five.smooth(), "A smooth five should be S"); - -assert.equal( - "🕔", - five.oclock(), - "A unicode symbol for five o'clock should be U+1F554" -); -assert.equal( - "🍺", - five.oclockSomewhere(), - "A unicode symbol for 'It's five o'clock somewhere' should be U+1F37A" -); -assert.equal( - "🍔", - five.guys(), - "A unicode symbol for Five Guys should be U+1F354" -); -assert.equal("$5.00", five.bucks(), "Five bucks in USD should be $5.00"); - -assert.equal("o/", five.high(), "A High five should be o/"); +assert.equal('⁵', five.upHigh(), 'An up high five should be a superscripted 5'); +assert.equal('₅', five.downLow(), 'A down low five should be a subscripted 5'); +assert.equal('V', five.roman(), 'A roman five should be a V'); + + +assert.equal('خمسة', five.arabic(), 'A arabic five should be خمسة'); +assert.equal('beş', five.azerbaijani(), 'A azerbaijani five should be beş'); +assert.equal('bost', five.basque(), 'A basque five should be bost'); +assert.equal('пяць', five.belarusian(), 'A belarusian five should be пяць'); +assert.equal('pet', five.bosnian(), 'A bosnian five should be pet'); +assert.equal('пет', five.bulgarian(), 'A bulgarian five should be пет'); +assert.equal('cinc', five.catalan(), 'A catalan five should be cinc'); +assert.equal('五', five.chinese(), 'A chinese five should be 五'); +assert.equal('wǔ', five.chinese('pinyin'), 'A chinese five in Pīnyīn should be wǔ'); +assert.equal('伍', five.chinese('financial'), 'A chinese five in financial contexts should be 伍'); +assert.equal('tahlapi', five.choctaw(), 'A choctaw five should be tahlapi'); +assert.equal('pet', five.croatian(), 'A croatian five should be pet'); +assert.equal('pět', five.czech(), 'A czech five should be pět'); +assert.equal('mek', five.dothraki(), 'A dothraki five should be mek'); +assert.equal('hen', five.dovah(), 'A dovah five should be hen'); +assert.equal('vijf', five.dutch(), 'A dutch five should be vijf'); +assert.equal('lempë', five.elvish(), 'An elvish five should be lempë'); +assert.equal('lempë', five.elvish('quenya'), 'An elvish five in Quenya should be lempë'); +assert.equal('leben', five.elvish('sindarin'), 'An elvish five in Sindarin should be leben'); +assert.equal('five', five.english(), 'A english five should be five'); +assert.equal('kvin', five.esperanto(), 'An esperanto five should be kvin'); +assert.equal('viis', five.estonian(), 'An estonian five should be viis'); +assert.equal('viisi', five.finnish(), 'A finnish five should be viisi'); +assert.equal('cinq', five.french(), 'A french five should be cinq'); +assert.equal('fünf', five.german(), 'A german five should be fünf'); +assert.equal('πέντε', five.greek(), 'A greek five should be πέντε'); +assert.equal('חמש', five.hebrew(), 'A hebrew five should be חמש'); +assert.equal('पांच', five.hindi(), 'A hindi five should be पांच'); +assert.equal('öt', five.hungarian(), 'A hungarian five should be öt'); +assert.equal('fimm', five.icelandic(), 'An icelandic five should be fimm'); +assert.equal('lima', five.indonesian(), 'A indonesian five should be lima'); +assert.equal('cúig', five.irish(), 'A irish five should be cúig'); +assert.equal('cinque', five.italian(), 'A italian five should be cinque'); +assert.equal('五', five.japanese(), 'A japanese five should be 五'); +assert.equal('ಐದು', five.kannada(), 'A kannada five should be ಐದು'); +assert.equal('vagh', five.klingon(), 'A klingon five should be vagh'); +assert.equal('오', five.korean(), 'A korean five should be 오'); +assert.equal('quinque', five.latin(), 'A latin five should be quinque'); +assert.equal('pieci', five.latvian(), 'A latvian five should be pieci'); +assert.equal('penki', five.lithuanian(), 'A lithuanian five should be penki'); +assert.equal('ħamsa', five.maltese(), ' A maltese five should be ħamsa'); +assert.equal('таван', five.mongolian(), 'A mongolian five should be таван'); +assert.equal('पाँच', five.nepali(), 'A nepali five should be पाँच'); +assert.equal('fem', five.norwegian(), 'A norwegian five should be fem'); +assert.equal('پنج', five.persian(), 'A persian five should be پنج'); +assert.equal('ivefay', five.piglatin(), 'A piglatin five should be ivefay'); +assert.equal('pięć', five.polish(), 'A polish five should be pięć'); +assert.equal('cinco', five.portuguese(), 'A portuguese five should be cinco'); +assert.equal('ਪੰਜ', five.punjabi(), 'A punjabi five should be ਪੰਜ'); +assert.equal('cinci', five.romanian(), 'A romanian five should be cinci'); +assert.equal('пять', five.russian(), 'A russian five should be пять'); +assert.equal('pet', five.serbian(), 'A serbian five should be pet'); +assert.equal('පහ', five.sinhala(), 'A sinhala five should be පහ'); +assert.equal('päť', five.slovakian(), 'A slovakian five should be päť'); +assert.equal('pet', five.slovenian(), 'A slovenian five should be pet'); +assert.equal('cinco', five.spanish(), 'A spanish five should be cinco'); +assert.equal('fem', five.swedish(), 'A swedish five should be fem'); +assert.equal('ஐந்து', five.tamil(), 'A tamil five should be ஐந்து'); +assert.equal('ఐదు', five.telugu(), 'A telugu five should be ఐదు'); +assert.equal('ห้า', five.thai(), 'A thai five should be ห้า'); +assert.equal('beş', five.turkish(), 'A turkish five should be beş'); +assert.equal('п’ять', five.ukrainian(), 'A ukrainian five should be п’ять'); +assert.equal('پانچ', five.urdu(), 'An urdu five should be پانچ'); + +assert.equal('.....', five.morseCode(), 'A five in morse code should be .....'); +assert.equal('10', five.base(5), 'A quinary five should be 10'); +assert.equal('11', five.base(4), 'An quaternary five should be 11') +assert.equal('101', five.binary(), 'A binary five should be 101'); +assert.equal('5', five.octal(), 'An octal five should be 5'); +assert.equal('5', five.hex(), 'An hexadecimal five should be 5'); + +assert.equal('30056e1cab7a61d256fc8edd970d14f5', five.mdFive(), 'md5 checksum of "five" should be 30056e1cab7a61d256fc8edd970d14f5'); +assert.equal('1.618033988749895', five.golden(), 'A golden five is Phive'); + +assert.equal('-5', five.negative(), 'A negative five should be -5'); +assert.equal('FIVE', five.loud(), 'A loud five should be FIVE'); +assert.equal('IVEFAY', five.loud('piglatin'), 'A loud five in Pig Latin should be IVEFAY'); +assert.equal('ПЯТЬ', five.loud('russian'), 'A loud five in Russian should be ПЯТЬ'); +assert.equal('S', five.smooth(), 'A smooth five should be S'); + +assert.equal('🕔', five.oclock(), 'A unicode symbol for five o\'clock should be U+1F554'); +assert.equal('🍺', five.oclockSomewhere(), 'A unicode symbol for \'It\'s five o\'clock somewhere\' should be U+1F37A'); +assert.equal('🍔', five.guys(), 'A unicode symbol for Five Guys should be U+1F354'); +assert.equal('$5.00', five.bucks(), 'Five bucks in USD should be $5.00'); + +assert.equal('o/', five.high(), 'A High five should be o/'); var now = new Date().valueOf(); var slowFive = five.tooSlow(); var finishes = new Date().valueOf(); -assert.equal(5, slowFive, "A too slow five should still be five"); -assert.ok( - finishes - now > 500, - "A too slow five should take longer than 500 milliseconds to be returned, blocking execution and generally being a bad idea" -); - -assert.equal( - JSON.stringify(["Jackie", "Tito", "Jermaine", "Marlon", "Michael"]), - JSON.stringify(five.jackson()), - "A Jackson five should be the five members of the 70's pop family group the Jackson 5" -); - -assert.equal( - JSON.stringify([ - "Juwan Howard", - "Ray Jackson", - "Jimmy King", - "Jalen Rose", - "Chris Webber", - ]), - JSON.stringify(five.fab()), - "A fab five should be the 1991-1993 Michigan Mens Basketball Team" -); - -assert.equal( - JSON.stringify([ - "Sean Conlon", - "Ritchie Neville", - "Scott Robinson", - "Jason 'J' Brown", - "Abz Love", - ]), - JSON.stringify(five.members()), - "A five five should be the 90's boy band 5ive" -); - -assert.equal( - JSON.stringify(["5ive", "Invincible", "Kingsize"]), - JSON.stringify(five.discography()), - "A five discography should be the studio albums released by the 90's boy band 5ive" -); - -assert.equal( - JSON.stringify([ - "Slam Dunk (Da Funk)", - "When the Lights Go Out", - "Got the Feelin'", - "Everybody Get Up", - "It's the Things You Do", - "Until the Time Is Through", - "If Ya Gettin' Down", - "Keep On Movin'", - "Don't Wanna Let You Go", - "We Will Rock You", - "Let's Dance", - "Closer to Me", - "Rock the Party", - "I Wish It Could Be Christmas Everyday", - ]), - JSON.stringify(five.singles()), - "A five singles should be the singles released by the 90's boy band 5ive" -); - -assert.equal( - JSON.stringify(["Tigress", "Viper", "Crane", "Monkey", "Mantis"]), - JSON.stringify(five.furious()), - "A Furious five should be the five fictional members of the ninja group Furious Five from the movie Kung-Fu Panda" -); - -assert.equal( - JSON.stringify(["Julian", "Dick", "George", "Anne", "Timmy"]), - JSON.stringify(five.famous()), - "A Famous five should be the five central characters of the series of Enid Blighton novels" -); - -assert.equal( - "Interstella 5555: The 5tory of the 5ecret 5tar 5ystem", - five.fiveFiveFive(), - "FiveFiveFiveFive should be Interstella 5555: The 5tory of the 5ecret 5tar 5ystem" -); - -assert.equal( - five.luniz(), - "I Got 5 on It", - "A Luniz five should be the song title of their most famous hit" -); - -assert.equal( - five.funk(), - "5 bad boys with the power to rock you", - "A funked five should be a group of bad boys with the power to rock you" -); +assert.equal(5, slowFive, 'A too slow five should still be five'); +assert.ok((finishes - now) > 500, 'A too slow five should take longer than 500 milliseconds to be returned, blocking execution and generally being a bad idea'); + + +assert.equal(JSON.stringify(['Jackie','Tito','Jermaine','Marlon','Michael']), JSON.stringify(five.jackson()), 'A Jackson five should be the five members of the 70\'s pop family group the Jackson 5'); + +assert.equal(JSON.stringify(['Juwan Howard','Ray Jackson','Jimmy King','Jalen Rose','Chris Webber']), JSON.stringify(five.fab()), 'A fab five should be the 1991-1993 Michigan Mens Basketball Team'); + +assert.equal(JSON.stringify(['Sean Conlon', 'Ritchie Neville', 'Scott Robinson', 'Jason \'J\' Brown', 'Abz Love']), JSON.stringify(five.members()), 'A five five should be the 90\'s boy band 5ive'); + +assert.equal(JSON.stringify(['5ive', 'Invincible', 'Kingsize']), JSON.stringify(five.discography()), 'A five discography should be the studio albums released by the 90\'s boy band 5ive'); + +assert.equal(JSON.stringify(['Slam Dunk (Da Funk)', 'When the Lights Go Out', 'Got the Feelin\'', 'Everybody Get Up', 'It\'s the Things You Do', 'Until the Time Is Through', 'If Ya Gettin\' Down', 'Keep On Movin\'', 'Don\'t Wanna Let You Go', 'We Will Rock You', 'Let\'s Dance', 'Closer to Me', 'Rock the Party', 'I Wish It Could Be Christmas Everyday']), JSON.stringify(five.singles()), 'A five singles should be the singles released by the 90\'s boy band 5ive'); + +assert.equal(JSON.stringify(['Tigress','Viper','Crane','Monkey','Mantis']), JSON.stringify(five.furious()), 'A Furious five should be the five fictional members of the ninja group Furious Five from the movie Kung-Fu Panda'); + +assert.equal(JSON.stringify(['Julian', 'Dick', 'George', 'Anne', 'Timmy']), JSON.stringify(five.famous()), 'A Famous five should be the five central characters of the series of Enid Blighton novels'); + +assert.equal('Interstella 5555: The 5tory of the 5ecret 5tar 5ystem', five.fiveFiveFive(), 'FiveFiveFiveFive should be Interstella 5555: The 5tory of the 5ecret 5tar 5ystem'); + +assert.equal(five.luniz(), 'I Got 5 on It', 'A Luniz five should be the song title of their most famous hit'); + +assert.equal(five.funk(), '5 bad boys with the power to rock you', 'A funked five should be a group of bad boys with the power to rock you'); assert.equal(true, five.isFive(five())); assert.equal(false, five.isFive(10)); @@ -249,67 +137,53 @@ assert.equal(JSON.stringify([5, 5]), JSON.stringify(five.filter([5, true, 5]))); assert.equal(JSON.stringify([5, 5, 5]), JSON.stringify(five.map([1, 2, 3]))); assert.equal(5, five.reduce([1, 2, 3])); -assert.equal("£5", five.r(), "A fiver should be 5 GBP"); - -assert.equal("5€", five.euro()); - -assert.equal("$5", five.dollar()); - -assert.equal("5 Rs.", five.rupee("pakistani")); -assert.equal("₹ 5", five.rupee("indian")); -assert.equal("5 Rs.", five.rupee()); - -assert.equal("5678901234", five.rot("0123456789"), "Numbers should be rotated"); -assert.equal( - "fghijklmnopqrstuvwxyzabcde", - five.rot("abcdefghijklmnopqrstuvwxyz"), - "Small letters should be rotated" -); -assert.equal( - "FGHIJKLMNOPQRSTUVWXYZABCDE", - five.rot("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), - "Capital letters too" -); -assert.equal( - "$_$ -,- @.@?", - five.rot("$_$ -,- @.@?"), - "Emoticons should not be rotated" -); +assert.equal('£5', five.r(), 'A fiver should be 5 GBP'); + +assert.equal('5€', five.euro()); + +assert.equal('$5', five.dollar()); + +assert.equal('5 Rs.', five.rupee('pakistani')); +assert.equal('₹ 5', five.rupee('indian')); +assert.equal('5 Rs.', five.rupee()); + +assert.equal('5678901234', five.rot('0123456789'), 'Numbers should be rotated'); +assert.equal('fghijklmnopqrstuvwxyzabcde', five.rot('abcdefghijklmnopqrstuvwxyz'), 'Small letters should be rotated'); +assert.equal('FGHIJKLMNOPQRSTUVWXYZABCDE', five.rot('ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 'Capital letters too'); +assert.equal('$_$ -,- @.@?', five.rot('$_$ -,- @.@?'), 'Emoticons should not be rotated'); assert.equal(five * five, 25); assert.equal(five + five, 10); assert.equal(five / five, 1); assert.equal(five - five, 0); -assert.equal((five / five) * five, five); +assert.equal((five / five) * (five), five); assert.equal(120, five.factorial()); var fiveEmitter = five.emitter(); var emitterTested = false; -fiveEmitter.on("five", function (e) { - assert.equal(5, e, "Five event emitter should only emit 5"); +fiveEmitter.on('five', function(e) { + assert.equal(5, e, 'Five event emitter should only emit 5'); emitterTested = true; }); -setTimeout(function () { - if (!emitterTested) { - console.error( - "The five event emitter did something unexpected! I hope you're not using this feature in production" - ); +setTimeout(function() { + if(!emitterTested) { + console.error('The five event emitter did something unexpected! I hope you\'re not using this feature in production'); process.exit(1); } process.exit(0); }, 100); var asyncTests = 1; -five.async(function (err, five) { - assert.equal(err, null, "Async should not result in an error."); - assert.equal(five, 5, "Async should pass 5 to callback."); - asyncTests--; +five.async(function(err, five) { + assert.equal(err, null, 'Async should not result in an error.'); + assert.equal(five, 5, 'Async should pass 5 to callback.'); + asyncTests--; }); -setInterval(function () { - if (!asyncTests) { - process.exit(0); - } +setInterval(function() { + if (!asyncTests) { + process.exit(0); + } }, 100);