├── .jshintrc ├── index.js ├── .gitignore ├── package.json ├── test └── index.js ├── Gruntfile.js ├── LICENSE ├── README.md └── CONTRIBUTING.md /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "laxcomma": true 3 | } 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = function thirteen(number) { 2 | if (number !== undefined && typeof number !== "number") { 3 | // Can number be cast to a number? 4 | if (!isNaN(+number.toString())) { 5 | return +number.toString() * 13; 6 | } else if (!isNaN(+number.valueOf())) { 7 | return +number.valueOf() * 13; 8 | } else { 9 | return new Error("I can only deal with numbers"); 10 | } 11 | } else { 12 | // Respond with great energy 13 | return number * 13 + "!!!"; 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### node etc ### 2 | 3 | # Logs 4 | logs 5 | *.log 6 | 7 | # Runtime data 8 | pids 9 | *.pid 10 | *.seed 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 19 | .grunt 20 | 21 | # Compiled Dirs (http://nodejs.org/api/addons.html) 22 | build/ 23 | dist/ 24 | 25 | # Dependency directories 26 | # Deployed apps should consider commenting these lines out: 27 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 28 | node_modules/ 29 | bower_components/ 30 | 31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "thirteen", 3 | "version": "1.0.3", 4 | "description": "Take any number and...", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node_modules/.bin/grunt ci" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/phillipalexander/thirteen" 12 | }, 13 | "keywords": [ 14 | "thirteen", 15 | "numbers", 16 | "math" 17 | ], 18 | "author": "Phillip Alexander ", 19 | "license": "BSD-3-Clause", 20 | "bugs": { 21 | "url": "https://github.com/phillipalexander/thirteen/issues" 22 | }, 23 | "dependencies": {}, 24 | "devDependencies": { 25 | "chai": "~3.5.0", 26 | "grunt-contrib-jshint": "~1.0.0", 27 | "grunt-contrib-watch": "~1.0.0", 28 | "grunt": "~1.0.1", 29 | "grunt-mocha-cli": "~2.1.0", 30 | "grunt-complexity": "~0.3.0", 31 | "grunt-cli": "~1.2.0" 32 | } 33 | } -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | var expect = require('chai').expect; 2 | var thirteen = require('../index.js'); 3 | 4 | describe('thirteen', function () { 5 | it('should be a function', function () { 6 | expect(thirteen).to.be.a("function"); 7 | }); 8 | 9 | it('should return its argument multiplied by thirteen', function () { 10 | // Cast to number from string for test comparison. Test will pass even if value is returned with more force (i.e. "130!!!!!!!!"). 11 | var returnedAsNumber = parseFloat(thirteen(10).replace(/\!/g, "")); 12 | expect(returnedAsNumber).to.eql(130); 13 | }); 14 | 15 | it('should NOT return its argument multiplied by twelve', function () { 16 | var returnedAsNumber = parseFloat(thirteen(10).replace(/\!/g, "")); 17 | expect(returnedAsNumber).to.not.eql(120); 18 | }); 19 | 20 | it('should return its arguments number-like value multiplied by thirteen', function () { 21 | var wannabeString = {}; 22 | var wannabeValue = {}; 23 | 24 | wannabeString.toString = function () { return '13'; }; 25 | wannabeValue.valueOf = function () { return '13'; }; 26 | 27 | expect(thirteen(wannabeString)).to.eql(169); 28 | expect(thirteen(wannabeValue)).to.eql(169); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | // Generated on 2014-07-07 using generator-nodejs 2.0.1 2 | module.exports = function (grunt) { 3 | grunt.initConfig({ 4 | pkg: grunt.file.readJSON('package.json'), 5 | complexity: { 6 | generic: { 7 | src: ['app/**/*.js'], 8 | options: { 9 | errorsOnly: false, 10 | cyclometric: 6, // default is 3 11 | halstead: 16, // default is 8 12 | maintainability: 100 // default is 100 13 | } 14 | } 15 | }, 16 | jshint: { 17 | all: [ 18 | 'Gruntfile.js', 19 | 'app/**/*.js', 20 | 'test/**/*.js' 21 | ], 22 | options: { 23 | jshintrc: '.jshintrc' 24 | } 25 | }, 26 | mochacli: { 27 | all: ['test/**/*.js'], 28 | options: { 29 | reporter: 'spec', 30 | ui: 'tdd' 31 | } 32 | }, 33 | watch: { 34 | js: { 35 | files: ['**/*.js', '!node_modules/**/*.js'], 36 | tasks: ['default'], 37 | options: { 38 | nospawn: true 39 | } 40 | } 41 | } 42 | }); 43 | 44 | grunt.loadNpmTasks('grunt-complexity'); 45 | grunt.loadNpmTasks('grunt-contrib-jshint'); 46 | grunt.loadNpmTasks('grunt-contrib-watch'); 47 | grunt.loadNpmTasks('grunt-mocha-cli'); 48 | grunt.registerTask('test', ['complexity', 'jshint', 'mochacli', 'watch']); 49 | grunt.registerTask('ci', ['complexity', 'jshint', 'mochacli']); 50 | grunt.registerTask('default', ['test']); 51 | }; 52 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Phillip Alexander 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 3. Neither the name of Phillip Alexander nor the names of its contributors 13 | may be used to endorse or promote products derived from this software 14 | without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY PHILLIP ALEXANDER ''AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL PHILLIP ALEXANDER BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/da2b37c35b73434a957a31fa23c60692)](https://www.codacy.com/app/git_12/thirteen) 2 | [![GitHub issues](https://img.shields.io/github/issues/phillipalexander/thirteen.svg)](https://github.com/phillipalexander/thirteen/issues) 3 | [![npm version](https://badge.fury.io/js/thirteen.svg)](http://badge.fury.io/js/thirteen) 4 | 5 | # thirteen 6 | #### (13, XIII, 十三, trece, tredici, 열세, तेरह, ثلاثة عشر, тринадцать, treze, dreizehn, baker's dozen, 1101, שלוש עשרה, Hamahiru, tredici, mười ba) 7 | 8 | Take any number (or anything that _thinks_ it's a number) 9 | and multiply by [thirteen][13]. 10 | 11 | From [Wikipedia][13]: 12 | > 13 (thirteen /θɜrˈtiːn/) is the natural number following 12 and preceding 14. 13 | 14 | > In spoken English, the numbers 13 and 30 are often confused. When carefully enunciated, they differ in which syllable is stressed: 13 [![Listen](https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Speakerlink-new.svg/22px-Speakerlink-new.svg.png)](https://upload.wikimedia.org/wikipedia/commons/0/06/En-us-thirteen.ogg) [/θərˈtiːn/][not13] vs. 30 [/ˈθɜrti/][not13]. However, in dates such as 1300 ("thirteen hundred") or when contrasting numbers in the teens, such as 13, 14, 15, the stress shifts to the first syllable: 13 [/ˈθɜrtiːn/][not13]. 15 | 16 | Thirteen is represented in numerous ways, depending on the desired counting system. Outside of the common base-10 system, here are a few examples of other ways to understand the number 13: 17 | 18 | ``` 19 | Ndom (Base-6): 13 = (6 x 2) + 1 20 | (Base-12): 13 = 10 + 1 where 10 in Base-12 is equal to 12 in Base-10 21 | Oksapmin (Base-27) : 13 = right ear + right thumb 22 | Alamblak (Built from 1,2,5, and 20) : 13 = (5 x 2) + 2 + 1 = tir hosfi hosfirpat 23 | ``` 24 | 25 | _Sources:_ 26 | * http://www.sf.airnet.ne.jp/ts/language/number/ndom.html 27 | * http://mentalfloss.com/article/31879/12-mind-blowing-number-systems-other-languages 28 | * http://io9.com/5977095/why-we-should-switch-to-a-base-12-counting-system 29 | * http://www.sf.airnet.ne.jp/ts/language/number/alamblak.html 30 | 31 | ## Counting To Thirteen 32 | > Epistemic certainty courtesy of @CountVonCount: 33 | 34 | [![Counting to Thirteen](http://img.youtube.com/vi/XDQU0CcVKFI/0.jpg)](https://www.youtube.com/watch?v=XDQU0CcVKFI) 35 | 36 | ## Installation 37 | 38 | This module is installed via npm: 39 | 40 | ``` bash 41 | $ npm install thirteen 42 | ``` 43 | 44 | ## Example Usage 45 | 46 | ``` js 47 | var thirteen = require('thirteen'); 48 | 49 | var thirteenTwice = thirteen(2); 50 | console.log(thirteenTwice) // logs 26, which is thirteen, twice 51 | ``` 52 | 53 | ## Tests 54 | 55 | ``` bash 56 | grunt test 57 | ``` 58 | 59 | ## Contributing 60 | 61 | See [CONTRIBUTING.MD](CONTRIBUTING.md) 62 | 63 | [13]:http://en.wikipedia.org/wiki/13_(number) 64 | [not13]:https://en.wikipedia.org/wiki/Help:IPA_for_English 65 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## General Workflow 4 | 5 | 1. Fork the repo 6 | 1. Cut a namespaced feature branch from master 7 | - bug/... 8 | - feat/... 9 | - test/... 10 | - doc/... 11 | - refactor/... 12 | 1. Make commits to your feature branch. Prefix each commit like so: 13 | - (feat) Added a new feature 14 | - (fix) Fixed inconsistent tests [Fixes #0] 15 | - (refactor) ... 16 | - (cleanup) ... 17 | - (test) ... 18 | - (doc) ... 19 | 1. When you've finished with your fix or feature, Rebase upstream changes into your branch. submit a [pull request][] 20 | directly to master. Include a description of your changes. 21 | 1. Your pull request will be reviewed by another maintainer. The point of code 22 | reviews is to help keep the codebase clean and of high quality and, equally 23 | as important, to help you grow as a programmer. If your code reviewer 24 | requests you make a change you don't understand, ask them why. 25 | 1. Fix any issues raised by your code reviwer, and push your fixes as a single 26 | new commit. 27 | 1. Once the pull request has been reviewed, it will be merged by another member of the team. Do not merge your own commits. 28 | 29 | ## Detailed Workflow 30 | 31 | ### Fork the repo 32 | 33 | Use github’s interface to make a fork of the repo, then add that repo as an upstream remote: 34 | 35 | ``` 36 | git remote add upstream https://github.com/hackreactor-labs/.git 37 | ``` 38 | 39 | ### Cut a namespaced feature branch from master 40 | 41 | Your branch should follow this naming convention: 42 | - bug/... 43 | - feat/... 44 | - test/... 45 | - doc/... 46 | - refactor/... 47 | 48 | These commands will help you do this: 49 | 50 | ``` bash 51 | 52 | # Creates your branch and brings you there 53 | git checkout -b `your-branch-name` 54 | ``` 55 | 56 | ### Make commits to your feature branch. 57 | 58 | Prefix each commit like so 59 | - (feat) Added a new feature 60 | - (fix) Fixed inconsistent tests [Fixes #0] 61 | - (refactor) ... 62 | - (cleanup) ... 63 | - (test) ... 64 | - (doc) ... 65 | 66 | Make changes and commits on your branch, and make sure that you 67 | only make changes that are relevant to this branch. If you find 68 | yourself making unrelated changes, make a new branch for those 69 | changes. 70 | 71 | #### Commit Message Guidelines 72 | 73 | - Commit messages should be written in the present tense; e.g. "Fix continuous 74 | integration script". 75 | - The first line of your commit message should be a brief summary of what the 76 | commit changes. Aim for about 70 characters max. Remember: This is a summary, 77 | not a detailed description of everything that changed. 78 | - If you want to explain the commit in more depth, following the first line should 79 | be a blank line and then a more detailed description of the commit. This can be 80 | as detailed as you want, so dig into details here and keep the first line short. 81 | 82 | ### Rebase upstream changes into your branch 83 | 84 | Once you are done making changes, you can begin the process of getting 85 | your code merged into the main repo. Step 1 is to rebase upstream 86 | changes to the master branch into yours by running this command 87 | from your branch: 88 | 89 | ``` 90 | git pull --rebase upstream master 91 | ``` 92 | 93 | This will start the rebase process. You must commit all of your changes 94 | before doing this. If there are no conflicts, this should just roll all 95 | of your changes back on top of the changes from upstream, leading to a 96 | nice, clean, linear commit history. 97 | 98 | If there are conflicting changes, git will start yelling at you part way 99 | through the rebasing process. Git will pause rebasing to allow you to sort 100 | out the conflicts. You do this the same way you solve merge conflicts, 101 | by checking all of the files git says have been changed in both histories 102 | and picking the versions you want. Be aware that these changes will show 103 | up in your pull request, so try and incorporate upstream changes as much 104 | as possible. 105 | 106 | Once you are done fixing conflicts for a specific commit, run: 107 | 108 | ``` 109 | git rebase --continue 110 | ``` 111 | 112 | This will continue the rebasing process. Once you are done fixing all 113 | conflicts you should run the existing tests to make sure you didn’t break 114 | anything, then run your new tests (there are new tests, right?) and 115 | make sure they work also. 116 | 117 | If rebasing broke anything, fix it, then repeat the above process until 118 | you get here again and nothing is broken and all the tests pass. 119 | 120 | ### Make a pull request 121 | 122 | Make a clear pull request from your fork and branch to the upstream master 123 | branch, detailing exactly what changes you made and what feature this 124 | should add. The clearer your pull request is the faster you can get 125 | your changes incorporated into this repo. 126 | 127 | At least one other person MUST give your changes a code review, and once 128 | they are satisfied they will merge your changes into upstream. Alternatively, 129 | they may have some requested changes. You should make more commits to your 130 | branch to fix these, then follow this process again from rebasing onwards. 131 | 132 | Once you get back here, make a comment requesting further review and 133 | someone will look at your code again. If they like it, it will get merged, 134 | else, just repeat again. 135 | 136 | Thanks for contributing! 137 | 138 | ### Guidelines 139 | 140 | 1. Uphold the current code standard: 141 | - Keep your code [DRY][]. 142 | - Apply the [boy scout rule][]. 143 | - Follow [STYLE-GUIDE.md](STYLE-GUIDE.md) 144 | 1. Run the [tests][] before submitting a pull request. 145 | 1. Tests are very, very important. Submit tests if your pull request contains 146 | new, testable behavior. 147 | 1. Your pull request is comprised of a single ([squashed][]) commit. 148 | 149 | ## Checklist: 150 | 151 | This is just to help you organize your process 152 | 153 | - [ ] Did I cut my work branch off of master (don't cut new branches from existing feature brances)? 154 | - [ ] Did I follow the correct naming convention for my branch? 155 | - [ ] Is my branch focused on a single main change? 156 | - [ ] Do all of my changes directly relate to this change? 157 | - [ ] Did I rebase the upstream master branch after I finished all my 158 | work? 159 | - [ ] Did I write a clear pull request message detailing what changes I made? 160 | - [ ] Did I get a code review? 161 | - [ ] Did I make any requested changes from that code review? 162 | 163 | If you follow all of these guidelines and make good changes, you should have 164 | no problem getting your changes merged in. 165 | 166 | 167 | 168 | [style guide]: https://github.com/hackreactor-labs/style-guide 169 | [n-queens]: https://github.com/hackreactor-labs/n-queens 170 | [Underbar]: https://github.com/hackreactor-labs/underbar 171 | [curriculum workflow diagram]: http://i.imgur.com/p0e4tQK.png 172 | [cons of merge]: https://f.cloud.github.com/assets/1577682/1458274/1391ac28-435e-11e3-88b6-69c85029c978.png 173 | [Bookstrap]: https://github.com/hackreactor/bookstrap 174 | [Taser]: https://github.com/hackreactor/bookstrap 175 | [tools workflow diagram]: http://i.imgur.com/kzlrDj7.png 176 | [Git Flow]: http://nvie.com/posts/a-successful-git-branching-model/ 177 | [GitHub Flow]: http://scottchacon.com/2011/08/31/github-flow.html 178 | [Squash]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html 179 | --------------------------------------------------------------------------------