diff --git a/consts.js b/consts.js index 59f9a3cf..5cb3b441 100644 --- a/consts.js +++ b/consts.js @@ -29,10 +29,10 @@ var thirteenStrings = [ "Washington Luís", // Brazil's thirteenth president "Millard Fillmore", // Thirteenth President of the United States "Louis XIII", // Thirteenth king of France + "teurteen", //its still Thirteen when you say it "https://s3.amazonaws.com/rapgenius/calle13.jpg", // Calle 13, famous latin american band - // ALL HAIL ZALGO "1̵̧̨̡̢̡̧̨̪͍̮̗̯̮̲͖̥̳̲̯͔͉̬̘͍͔͙̳͚̠͓̳̪̯̣͚͍͎͇̦̗͙͕̬̭̝͕̱̺̮̼̞̤̙̹̙̘̗̘͔͎̼͙̤̝̖̝̫̝̲̼̫̙͚̗͖̳̱̳͕͙̜̖̘͎̖̭̝̖͔̠̦̜̎̀͌̈́̇͜͜͠ͅͅ3̷̧̢̡̛͖̘͎͎̥̼͙̱̜͖̩̪̼̫̭̙̓̽͆̌̀̈́͗̈͗̿̀̔̏͂́̏̅͛͒̓̐́͗̋̎̓̄͛̇͋̊̇́̅̔̇̉͌̈́̊̍͗̑̌̈͆̉͐̂́̉̓̇͛̃͑̾̌̄͐̀̔́̈̐͛̈́͛̇́̍́͊͛̐́̇͆͆́͒͑̃̾̿̏̀́͆̾̀̀̆̚̕͘͘̚͜͝͝͝͝͝͝͝͝", diff --git a/index.js b/index.js index 41d12224..e8230dc0 100644 --- a/index.js +++ b/index.js @@ -1,2 +1,13 @@ +// Load the 'is' module from the local './is' file var is = require('./is'); + +// Export the 'is' module as the main export of this file module.exports = is; + +// 'is' module likely checks if input is "13" or derivatives +// Use 'is' module's functionality in this module +// Export 'is' module for use in other parts of application +// This is necessary because, why wouldn't there be a library to check if the number is 13? +// The number 13 is a very important number in the world of programming, and it's important to have a library to check if the number is 13. +// This is the BEST npm library out there, fuck everything other than "13" +// This file is 13 lines long \ No newline at end of file diff --git a/is.js b/is.js index 9877f807..b5189d59 100644 --- a/is.js +++ b/is.js @@ -1,153 +1,13 @@ -var noop = require('noop3'); -var consts = require('./consts'); - -const THIRTEEN = consts.THIRTEEN; -const THIRTEEN_FUZZ = consts.THIRTEEN_FUZZ; -const thirteenStrings = consts.thirteenStrings; - -'use strict'; - -/** - * @param n {number} The number to compare but also sometimes not a number but not not !NaN - * @returns {object} - */ -var is = function is(x) { - // the next line calls the noop function - noop(); - - // Every element should be lower case - - if (thirteenStrings.indexOf(('' + x).toLowerCase()) > -1) { - x = THIRTEEN; - } - // check agin without lower case - else if (thirteenStrings.indexOf(('' + x)) > -1) { - x = THIRTEEN; - } - else if( (typeof x) === "string" && /^[Il1]{13,13}$/.test(x) ) { - x = THIRTEEN; - } - else if (typeof x === 'string') { - var chars = (x).split(''); - if (chars.length == THIRTEEN && chars.every(function(e) { return e === chars[0]})) { - x = THIRTEEN; - } - else if (chars.length == 26 && '\ud800' <= chars[0] && chars[0] <= '\udbff' - && '\udc00' <= chars[1] && chars[1] <= '\udfff' - && chars.every(function(e, idx) { return e === chars[idx % 2]})) { - x = THIRTEEN; - } - } - - return { - thirteen: function() { - return x == THIRTEEN; - }, - roughly: { - thirteen: function() { - for (var i = 0, len = thirteenStrings.length; i < len; i++) { - if (('' + x).toLowerCase().indexOf(('' + thirteenStrings[i])) > -1) { - return true; - } - } - return x >= (THIRTEEN - THIRTEEN_FUZZ) && x < (THIRTEEN + THIRTEEN_FUZZ); - } - }, - returning : { - thirteen : function(){ - return is(x()).thirteen(); - } - }, - not: { - thirteen: function() { - return !is(x).thirteen(); - } - }, - divisible: { - by: { - thirteen: function() { - return x % THIRTEEN === 0; - } - } - }, - square: { - of: { - thirteen: function() { - return x === THIRTEEN * THIRTEEN; - } - } - }, - greater: { - than: { - thirteen: function() { - return x > THIRTEEN - } - } - }, - less: { - than: { - thirteen: function() { - return x < THIRTEEN - } - } - }, - within: function(y) { - return { - of: { - thirteen: function() { - return x > (THIRTEEN - y) && x < (THIRTEEN + y); - } - } - } - }, - yearOfBirth: function() { - var currYear = new Date().getFullYear() - if(isNaN(x)) { - return false - } - return currYear - parseInt(x) == THIRTEEN - }, - plus: function(y) { - return is(x + y); - }, - minus: function(y) { - return is(x - y); - }, - times: function(y) { - return is(x * y); - }, - dividedby: function(y) { - return is(x / y); - }, - canSpell: { - thirteen: function(){ - return x.toLowerCase().includes("t","h","i","r","t","e","e","n"); - } - }, - anagramOf:{ - thirteen:function(){ - return x.toLowerCase().split('').sort().join('').trim() == "thirteen".split('').sort().join('').trim(); - } - }, - backwards: { - thirteen: function() { - return parseInt(x.toString().split("").reverse().join("")) == THIRTEEN; - } - }, - atomicNumber: { - thirteen: function() { - return x.toLowerCase().includes("a","l","u","m","i","n","u","m"); - } - }, - base: function(y) { - return { - thirteen: function() { - var basedNumber = parseInt(x, y); - return !isNaN(basedNumber) && basedNumber == THIRTEEN; - } - } - } - } -}; - -module.exports = is; +var noop = require('noop3'), consts = require('./consts'), { THIRTEEN, THIRTEEN_FUZZ, thirteenStrings } = consts; +var is = x => ({ + thirteen: () => thirteenStrings.includes((''+x).toLowerCase()) || /^[Il1]{13,13}$/.test(x) || (typeof x === 'string' && (x.length === 13 && x[0] === x[12]) || (x.length === 26 && /^\ud800[\udc00-\udfff]$/.test(x))), + roughly: { thirteen: () => thirteenStrings.some(s => (''+x).toLowerCase().includes(s)) || x >= THIRTEEN-THIRTEEN_FUZZ && x < THIRTEEN+THIRTEEN_FUZZ }, + returning: { thirteen: () => is(x()).thirteen() }, + not: { thirteen: () => !is(x).thirteen() }, + divisible: { by: { thirteen: () => x % THIRTEEN === 0 } }, + square: { of: { thirteen: () => x === THIRTEEN*THIRTEEN } }, + greater: { than: { thirteen: () => x > THIRTEEN } }, + less: { than: { thirteen: () => x < THIRTEEN } }, + within: y => ({ of: { thirteen: () => x > THIRTEEN-y && x < THIRTEEN+y } }), + yearOfBirth: () => !isNaN(x) && (new Date().getFullYear() - parseInt(x)) === THIRTEEN +}); module.exports = is; \ No newline at end of file