forked from airbnb/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
npm-debug.log
97 lines (97 loc) · 46.8 KB
/
npm-debug.log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'publish' ]
2 info using npm@3.3.6
3 info using node@v5.0.0
4 verbose publish [ '.' ]
5 silly cache add args [ '.', null ]
6 verbose cache add spec .
7 silly cache add parsed spec Result {
7 silly cache add raw: '.',
7 silly cache add scope: null,
7 silly cache add name: null,
7 silly cache add rawSpec: '.',
7 silly cache add spec: '/Users/nigel/about.me/javascript',
7 silly cache add type: 'directory' }
8 verbose addLocalDirectory /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package.tgz not in flight; packing
9 info lifecycle @aboutdotme/javascript@1.0.4~prepublish: @aboutdotme/javascript@1.0.4
10 silly lifecycle @aboutdotme/javascript@1.0.4~prepublish: no script for prepublish, continuing
11 verbose tar pack [ '/Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package.tgz',
11 verbose tar pack '/Users/nigel/about.me/javascript' ]
12 verbose tarball /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package.tgz
13 verbose folder /Users/nigel/about.me/javascript
14 verbose addLocalTarball adding from inside cache /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package.tgz
15 silly cache afterAdd @aboutdotme/javascript@1.0.4
16 verbose afterAdd /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package/package.json not in flight; writing
17 verbose afterAdd /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package/package.json written
18 silly publish { name: '@aboutdotme/javascript',
18 silly publish version: '1.0.4',
18 silly publish description: 'installs .jshintrc file for the parent module. this should only be used as a dev dependency.',
18 silly publish main: 'index.js',
18 silly publish scripts:
18 silly publish { test: 'echo "Error: no test specified" && exit 1',
18 silly publish postinstall: 'node linters/jshintrc_install.js' },
18 silly publish repository:
18 silly publish { type: 'git',
18 silly publish url: 'git+https://github.com/aboutdotme/javascript.git' },
18 silly publish author: { name: 'Nigel Kibodeaux' },
18 silly publish license: 'ISC',
18 silly publish bugs: { url: 'https://github.com/aboutdotme/javascript/issues' },
18 silly publish homepage: 'https://github.com/aboutdotme/javascript',
18 silly publish readme: '# NPM package\n`npm install --save-dev me-javascript` to install the .jshintrc file in the parent module\'s root directory\n\n# About.me JavaScript Style Guide() {\n\n*A mostly reasonable approach to JavaScript*\n\n*Forked from [Airbnb\'s Javascript Style\nGuide](https://github.com/airbnb/javascript). Modified with about.me\nconventions*\n\n\n## Table of Contents\n\n1. [Types](#types)\n1. [Objects](#objects)\n1. [Arrays](#arrays)\n1. [Strings](#strings)\n1. [Functions](#functions)\n1. [Properties](#properties)\n1. [Variables](#variables)\n1. [Hoisting](#hoisting)\n1. [Conditional Expressions & Equality](#conditional-expressions--equality)\n1. [Blocks](#blocks)\n1. [Comments](#comments)\n1. [Whitespace](#whitespace)\n1. [Commas](#commas)\n1. [Semicolons](#semicolons)\n1. [Type Casting & Coercion](#type-casting--coercion)\n1. [Naming Conventions](#naming-conventions)\n1. [Accessors](#accessors)\n1. [Constructors](#constructors)\n1. [Events](#events)\n1. [Modules](#modules)\n1. [jQuery](#jquery)\n1. [ECMAScript 5 Compatibility](#ecmascript-5-compatibility)\n1. [Testing](#testing)\n1. [Performance](#performance)\n1. [Resources](#resources)\n1. [In the Wild](#in-the-wild)\n1. [Translation](#translation)\n1. [The JavaScript Style Guide Guide](#the-javascript-style-guide-guide)\n1. [Contributors](#contributors)\n1. [License](#license)\n\n## Types\n\n - **Primitives**: When you access a primitive type you work directly on its value\n\n + `string`\n + `number`\n + `boolean`\n + `null`\n + `undefined`\n\n ```javascript\n var foo = 1,\n bar = foo;\n\n bar = 9;\n\n console.log(foo, bar); // => 1, 9\n ```\n - **Complex**: When you access a complex type you work on a reference to its value\n\n + `object`\n + `array`\n + `function`\n\n ```javascript\n var foo = [1, 2],\n bar = foo;\n\n bar[0] = 9;\n\n console.log(foo[0], bar[0]); // => 9, 9\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Objects\n\n - Use the literal syntax for object creation.\n\n ```javascript\n // bad\n var item = new Object();\n\n // good\n var item = {};\n ```\n\n - Don\'t use [reserved words](http://es5.github.io/#x7.6.1) as keys. It won\'t work in IE8. [More info](https://github.com/airbnb/javascript/issues/61)\n\n ```javascript\n // bad\n var superman = {\n default: { clark: \'kent\' },\n private: true\n };\n\n // good\n var superman = {\n defaults: { clark: \'kent\' },\n hidden: true\n };\n ```\n\n - Use readable synonyms in place of reserved words.\n\n ```javascript\n // bad\n var superman = {\n class: \'alien\'\n };\n\n // bad\n var superman = {\n klass: \'alien\'\n };\n\n // good\n var superman = {\n type: \'alien\'\n };\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Arrays\n\n - Use the literal syntax for array creation\n\n ```javascript\n // bad\n var items = new Array();\n\n // good\n var items = [];\n ```\n\n - If you don\'t know array length use Array#push.\n\n ```javascript\n var someStack = [];\n\n\n // bad\n someStack[someStack.length] = \'abracadabra\';\n\n // good\n someStack.push(\'abracadabra\');\n ```\n\n - When you need to copy an array use Array#slice. [jsPerf](http://jsperf.com/converting-arguments-to-an-array/7)\n\n ```javascript\n var len = items.length,\n itemsCopy = [],\n i;\n\n // bad\n for (i = 0; i < len; i++) {\n itemsCopy[i] = items[i];\n }\n\n // good\n itemsCopy = items.slice();\n ```\n\n - To convert an array-like object to an array, use Array#slice.\n\n ```javascript\n function trigger() {\n var args = Array.prototype.slice.call(arguments);\n ...\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Strings\n\n - Use single quotes `\'\'` for strings\n\n ```javascript\n // bad\n var name = "Bob Parr";\n\n // good\n var name = \'Bob Parr\';\n\n // bad\n var fullName = "Bob " + this.lastName;\n\n // good\n var fullName = \'Bob \' + this.lastName;\n ```\n\n - Strings longer than 80 characters should be written across multiple lines using string concatenation.\n - Note: If overused, long strings with concatenation could impact performance. [jsPerf](http://jsperf.com/ya-string-concat) & [Discussion](https://github.com/airbnb/javascript/issues/40)\n\n ```javascript\n // bad\n var errorMessage = \'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.\';\n\n // bad\n var errorMessage = \'This is a super long error that was thrown because \\\n of Batman. When you stop to think about how Batman had anything to do \\\n with this, you would get nowhere \\\n fast.\';\n\n // good\n var errorMessage = \'This is a super long error that was thrown because \' +\n \'of Batman. When you stop to think about how Batman had anything to do \' +\n \'with this, you would get nowhere fast.\';\n ```\n\n - When programmatically building up a string, use Array#join instead of string concatenation. Mostly for IE: [jsPerf](http://jsperf.com/string-vs-array-concat/2).\n\n ```javascript\n var items,\n messages,\n length,\n i;\n\n messages = [{\n state: \'success\',\n message: \'This one worked.\'\n }, {\n state: \'success\',\n message: \'This one worked as well.\'\n }, {\n state: \'error\',\n message: \'This one did not work.\'\n }];\n\n length = messages.length;\n\n // bad\n function inbox(messages) {\n items = \'<ul>\';\n\n for (i = 0; i < length; i++) {\n items += \'<li>\' + messages[i].message + \'</li>\';\n }\n\n return items + \'</ul>\';\n }\n\n // good\n function inbox(messages) {\n items = [];\n\n for (i = 0; i < length; i++) {\n items[i] = messages[i].message;\n }\n\n return \'<ul><li>\' + items.join(\'</li><li>\') + \'</li></ul>\';\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Functions\n\n - Function expressions:\n\n ```javascript\n // anonymous function expression\n var anonymous = function() {\n return true;\n };\n\n // named function expression\n var named = function named() {\n return true;\n };\n\n // immediately-invoked function expression (IIFE)\n (function() {\n console.log(\'Welcome to the Internet. Please follow me.\');\n })();\n ```\n\n - Never declare a function in a non-function block (if, while, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently, which is bad news bears.\n - **Note:** ECMA-262 defines a `block` as a list of statements. A function declaration is not a statement. [Read ECMA-262\'s note on this issue](http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf#page=97).\n\n ```javascript\n // bad\n if (currentUser) {\n function test() {\n console.log(\'Nope.\');\n }\n }\n\n // good\n var test;\n if (currentUser) {\n test = function test() {\n console.log(\'Yup.\');\n };\n }\n ```\n\n - Never name a parameter `arguments`, this will take precedence over the `arguments` object that is given to every function scope.\n\n ```javascript\n // bad\n function nope(name, options, arguments) {\n // ...stuff...\n }\n\n // good\n function yup(name, options, args) {\n // ...stuff...\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n\n## Properties\n\n - Use dot notation when accessing properties.\n\n ```javascript\n var luke = {\n jedi: true,\n age: 28\n };\n\n // bad\n var isJedi = luke[\'jedi\'];\n\n // good\n var isJedi = luke.jedi;\n ```\n\n - Use subscript notation `[]` when accessing properties with a variable.\n\n ```javascript\n var luke = {\n jedi: true,\n age: 28\n };\n\n function getProp(prop) {\n return luke[prop];\n }\n\n var isJedi = getProp(\'jedi\');\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Variables\n\n - Always use `var` to declare variables. Not doing so will result in global variables. We want to avoid polluting the global namespace. Captain Planet warned us of that.\n\n ```javascript\n // bad\n superPower = new SuperPower();\n\n // good\n var superPower = new SuperPower();\n ```\n\n - Use one `var` declaration for multiple variables and declare each variable on a newline.\n\n ```javascript\n // bad\n var items = getItems();\n var goSportsTeam = true;\n var dragonball = \'z\';\n\n // good\n var items = getItems(),\n goSportsTeam = true,\n dragonball = \'z\';\n ```\n\n - Declare unassigned variables last. This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.\n\n ```javascript\n // bad\n var i, len, dragonball,\n items = getItems(),\n goSportsTeam = true;\n\n // bad\n var i, items = getItems(),\n dragonball,\n goSportsTeam = true,\n len;\n\n // good\n var items = getItems(),\n goSportsTeam = true,\n dragonball,\n length,\n i;\n ```\n\n - Assign variables at the top of their scope. This helps avoid issues with variable declaration and assignment hoisting related issues.\n\n ```javascript\n // bad\n function() {\n test();\n console.log(\'doing stuff..\');\n\n //..other stuff..\n\n var name = getName();\n\n if (name === \'test\') {\n return false;\n }\n\n return name;\n }\n\n // good\n function() {\n var name = getName();\n\n test();\n console.log(\'doing stuff..\');\n\n //..other stuff..\n\n if (name === \'test\') {\n return false;\n }\n\n return name;\n }\n\n // bad\n function() {\n var name = getName();\n\n if (!arguments.length) {\n return false;\n }\n\n return true;\n }\n\n // good\n function() {\n if (!arguments.length) {\n return false;\n }\n\n var name = getName();\n\n return true;\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Hoisting\n\n - Variable declarations get hoisted to the top of their scope, their assignment does not.\n\n ```javascript\n // we know this wouldn\'t work (assuming there\n // is no notDefined global variable)\n function example() {\n console.log(notDefined); // => throws a ReferenceError\n }\n\n // creating a variable declaration after you\n // reference the variable will work due to\n // variable hoisting. Note: the assignment\n // value of `true` is not hoisted.\n function example() {\n console.log(declaredButNotAssigned); // => undefined\n var declaredButNotAssigned = true;\n }\n\n // The interpreter is hoisting the variable\n // declaration to the top of the scope.\n // Which means our example could be rewritten as:\n function example() {\n var declaredButNotAssigned;\n console.log(declaredButNotAssigned); // => undefined\n declaredButNotAssigned = true;\n }\n ```\n\n - Anonymous function expressions hoist their variable name, but not the function assignment.\n\n ```javascript\n function example() {\n console.log(anonymous); // => undefined\n\n anonymous(); // => TypeError anonymous is not a function\n\n var anonymous = function() {\n console.log(\'anonymous function expression\');\n };\n }\n ```\n\n - Named function expressions hoist the variable name, not the function name or the function body.\n\n ```javascript\n function example() {\n console.log(named); // => undefined\n\n named(); // => TypeError named is not a function\n\n superPower(); // => ReferenceError superPower is not defined\n\n var named = function superPower() {\n console.log(\'Flying\');\n };\n }\n\n // the same is true when the function name\n // is the same as the variable name.\n function example() {\n console.log(named); // => undefined\n\n named(); // => TypeError named is not a function\n\n var named = function named() {\n console.log(\'named\');\n }\n }\n ```\n\n - Function declarations hoist their name and the function body.\n\n ```javascript\n function example() {\n superPower(); // => Flying\n\n function superPower() {\n console.log(\'Flying\');\n }\n }\n ```\n\n - For more information refer to [JavaScript Scoping & Hoisting](http://www.adequatelygood.com/2010/2/JavaScript-Scoping-and-Hoisting) by [Ben Cherry](http://www.adequatelygood.com/)\n\n**[⬆ back to top](#table-of-contents)**\n\n\n\n## Conditional Expressions & Equality\n\n - Use `===` and `!==` over `==` and `!=`.\n - Conditional expressions are evaluated using coercion with the `ToBoolean` method and always follow these simple rules:\n\n + **Objects** evaluate to **true**\n + **Undefined** evaluates to **false**\n + **Null** evaluates to **false**\n + **Booleans** evaluate to **the value of the boolean**\n + **Numbers** evaluate to **false** if **+0, -0, or NaN**, otherwise **true**\n + **Strings** evaluate to **false** if an empty string `\'\'`, otherwise **true**\n\n ```javascript\n if ([0]) {\n // true\n // An array is an object, objects evaluate to true\n }\n ```\n\n - Use shortcuts.\n\n ```javascript\n // bad\n if (name !== \'\') {\n // ...stuff...\n }\n\n // good\n if (name) {\n // ...stuff...\n }\n\n // bad\n if (collection.length > 0) {\n // ...stuff...\n }\n\n // good\n if (collection.length) {\n // ...stuff...\n }\n ```\n\n - For more information see [Truth Equality and JavaScript](http://javascriptweblog.wordpress.com/2011/02/07/truth-equality-and-javascript/#more-2108) by Angus Croll\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Blocks\n\n - Use braces with all multi-line blocks.\n\n ```javascript\n // bad\n if (test)\n return false;\n\n // good\n if (test) return false;\n\n // good\n if (test) {\n return false;\n }\n\n // bad\n function() { return false; }\n\n // good\n function() {\n return false;\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Comments\n\n - Use `/** ... */` for multiline comments. Include a description, specify types and values for all parameters and return values.\n\n ```javascript\n // bad\n // make() returns a new element\n // based on the passed in tag name\n //\n // @param <String> tag\n // @return <Element> element\n function make(tag) {\n\n // ...stuff...\n\n return element;\n }\n\n // good\n /**\n * make() returns a new element\n * based on the passed in tag name\n *\n * @param <String> tag\n * @return <Element> element\n */\n function make(tag) {\n\n // ...stuff...\n\n return element;\n }\n ```\n\n - Use `//` for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment.\n\n ```javascript\n // bad\n var active = true; // is current tab\n\n // good\n // is current tab\n var active = true;\n\n // bad\n function getType() {\n console.log(\'fetching type...\');\n // set the default type to \'no type\'\n var type = this._type || \'no type\';\n\n return type;\n }\n\n // good\n function getType() {\n console.log(\'fetching type...\');\n\n // set the default type to \'no type\'\n var type = this._type || \'no type\';\n\n return type;\n }\n ```\n\n - Prefixing your comments with `DNR`, `FIXME`, or `TODO` helps other developers quickly understand if you\'re pointing out a problem that needs to be revisited, or if you\'re suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable. The actions are `FIXME -- need to figure this out` or `TODO -- need to implement`.\n\n - Use `// DNR` to mark code which should not be released under any circumstances\n\n ```javascript\n function Calculator() {\n\n window.total = this.total; // DNR\n\n return this;\n }\n ```\n\n - Use `// FIXME:` to annotate problems\n\n ```javascript\n function Calculator() {\n\n // FIXME: shouldn\'t use a global here\n total = 0;\n\n return this;\n }\n ```\n\n - Use `// TODO:` to annotate solutions to problems\n\n ```javascript\n function Calculator() {\n\n // TODO: total should be configurable by an options param\n this.total = 0;\n\n return this;\n }\n```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Whitespace\n\n - Use soft tabs set to 4 spaces.\n\n ```javascript\n // good\n function() {\n ∙∙∙∙var name;\n }\n\n // bad\n function() {\n ∙∙var name;\n }\n\n // good\n function() {\n var name;\n }\n ```\n\n - The above guideline is up for debate. See the note at the top of this document.\n \n - Place 1 space before the leading brace.\n\n ```javascript\n // bad\n function test(){\n console.log(\'test\');\n }\n\n // good\n function test() {\n console.log(\'test\');\n }\n\n // bad\n dog.set(\'attr\',{\n age: \'1 year\',\n breed: \'Bernese Mountain Dog\'\n });\n\n // good\n dog.set(\'attr\', {\n age: \'1 year\',\n breed: \'Bernese Mountain Dog\'\n });\n ```\n\n - Set off operators with spaces.\n\n ```javascript\n // bad\n var x=y+5;\n\n // good\n var x = y + 5;\n ```\n\n - Place an empty newline at the end of the file.\n\n ```javascript\n // bad\n (function(global) {\n // ...stuff...\n })(this);\n ```\n\n ```javascript\n // good\n (function(global) {\n // ...stuff...\n })(this);\n\n ```\n\n - Use indentation when making long method chains.\n\n ```javascript\n // bad\n $(\'#items\').find(\'.selected\').highlight().end().find(\'.open\').updateCount();\n\n // good\n $(\'#items\')\n .find(\'.selected\')\n .highlight()\n .end()\n .find(\'.open\')\n .updateCount();\n\n // bad\n var leds = stage.selectAll(\'.led\').data(data).enter().append(\'svg:svg\').class(\'led\', true)\n .attr(\'width\', (radius + margin) * 2).append(\'svg:g\')\n .attr(\'transform\', \'translate(\' + (radius + margin) + \',\' + (radius + margin) + \')\')\n .call(tron.led);\n\n // good\n var leds = stage.selectAll(\'.led\')\n .data(data)\n .enter().append(\'svg:svg\')\n .class(\'led\', true)\n .attr(\'width\', (radius + margin) * 2)\n .append(\'svg:g\')\n .attr(\'transform\', \'translate(\' + (radius + margin) + \',\' + (radius + margin) + \')\')\n .call(tron.led);\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n## Commas\n\n - Leading commas: **Nope.**\n\n ```javascript\n // bad\n var once\n , upon\n , aTime;\n\n // good\n var once,\n upon,\n aTime;\n\n // bad\n var hero = {\n firstName: \'Bob\'\n , lastName: \'Parr\'\n , heroName: \'Mr. Incredible\'\n , superPower: \'strength\'\n };\n\n // good\n var hero = {\n firstName: \'Bob\',\n lastName: \'Parr\',\n heroName: \'Mr. Incredible\',\n superPower: \'strength\'\n };\n ```\n\n - Additional trailing comma: **Nope.** This can cause problems with IE6/7 and IE9 if it\'s in quirksmode. Also, in some implementations of ES3 would add length to an array if it had an additional trailing comma. This was clarified in ES5 ([source](http://es5.github.io/#D)):\n\n> Edition 5 clarifies the fact that a trailing comma at the end of an ArrayInitialiser does not add to the length of the array. This is not a semantic change from Edition 3 but some implementations may have previously misinterpreted this.\n\n ```javascript\n // bad\n var hero = {\n firstName: \'Kevin\',\n lastName: \'Flynn\',\n };\n\n var heroes = [\n \'Batman\',\n \'Superman\',\n ];\n\n // good\n var hero = {\n firstName: \'Kevin\',\n lastName: \'Flynn\'\n };\n\n var heroes = [\n \'Batman\',\n \'Superman\'\n ];\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Semicolons\n\n - **Yup.**\n\n ```javascript\n // bad\n (function() {\n var name = \'Skywalker\'\n return name\n })()\n\n // good\n (function() {\n var name = \'Skywalker\';\n return name;\n })();\n\n // good\n ;(function() {\n var name = \'Skywalker\';\n return name;\n })();\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Type Casting & Coercion\n\n - Perform type coercion at the beginning of the statement.\n - Strings:\n\n ```javascript\n // => this.reviewScore = 9;\n\n // bad\n var totalScore = this.reviewScore + \'\';\n\n // good\n var totalScore = \'\' + this.reviewScore;\n\n // bad\n var totalScore = \'\' + this.reviewScore + \' total score\';\n\n // good\n var totalScore = this.reviewScore + \' total score\';\n ```\n\n - Use `parseInt` for Numbers and always with a radix for type casting.\n\n ```javascript\n var inputValue = \'4\';\n\n // bad\n var val = new Number(inputValue);\n\n // bad\n var val = +inputValue;\n\n // bad\n var val = inputValue >> 0;\n\n // bad\n var val = parseInt(inputValue);\n\n // good\n var val = Number(inputValue);\n\n // good\n var val = parseInt(inputValue, 10);\n ```\n\n - If for whatever reason you are doing something wild and `parseInt` is your bottleneck and need to use Bitshift for [performance reasons](http://jsperf.com/coercion-vs-casting/3), leave a comment explaining why and what you\'re doing.\n - **Note:** Be careful when using bitshift operations. Numbers are represented as [64-bit values](http://es5.github.io/#x4.3.19), but Bitshift operations always return a 32-bit integer ([source](http://es5.github.io/#x11.7)). Bitshift can lead to unexpected behavior for integer values larger than 32 bits. [Discussion](https://github.com/airbnb/javascript/issues/109)\n\n ```javascript\n // good\n /**\n * parseInt was the reason my code was slow.\n * Bitshifting the String to coerce it to a\n * Number made it a lot faster.\n */\n var val = inputValue >> 0;\n ```\n\n - Booleans:\n\n ```javascript\n var age = 0;\n\n // bad\n var hasAge = new Boolean(age);\n\n // good\n var hasAge = Boolean(age);\n\n // good\n var hasAge = !!age;\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Naming Conventions\n\n - Avoid single letter names. Be descriptive with your naming. Use verbs when naming functions, nouns for objects.\n\n ```javascript\n // bad\n function q() {\n // ...stuff...\n }\n\n // good\n function findPerson() {\n // ..stuff..\n }\n ```\n\n - Use PascalCase when naming constructors or classes\n\n ```javascript\n // bad\n function user(options) {\n this.name = options.name;\n }\n\n var bad = new user({\n name: \'nope\'\n });\n\n // good\n function User(options) {\n this.name = options.name;\n }\n\n var good = new User({\n name: \'yup\'\n });\n ```\n\n - Use camelCase when naming functions or object methods. Use descriptive names, preferably starting with a verb.\n\n ```javascript\n // bad\n function MethodName() {};\n function method_name() {};\n var MyObject = {\n MethodName: function() {},\n method_name: function() {}\n };\n\n // good\n function doSomething() {};\n var MyObject = {\n doSomething: function() {}\n };\n ```\n\n - Use lowercase_with_underscores when naming instances, variables, or object properties.\n\n ```javascript\n // bad\n var myObject = new MyObject();\n var myVar = \'bad\';\n myObject.myProperty = \'bad\';\n\n // good\n var my_object = new MyObject();\n var my_var = \'good\';\n my_object.my_property = \'good\';\n ```\n\n - Use ALL_CAPS_WITH_UNDERSCORES when naming constants.\n\n ```javascript\n // bad\n var some_constant = \'immutable value\';\n\n // good\n var SOME_CONSTANT = \'immutable value\';\n ```\n\n - Use a leading underscore `_` when naming private properties. Or, avoid exposing private properties to other modules entirely.\n\n ```javascript\n // bad\n this.__firstName__ = \'Panda\';\n this.firstName_ = \'Panda\';\n\n // good\n this._firstName = \'Panda\';\n ```\n\n - When saving a reference to `this` use `_this`.\n\n ```javascript\n // bad\n function() {\n var self = this;\n return function() {\n console.log(self);\n };\n }\n\n // bad\n function() {\n var that = this;\n return function() {\n console.log(that);\n };\n }\n\n // good\n function() {\n var _this = this;\n return function() {\n console.log(_this);\n };\n }\n ```\n\n - Name your functions. This is helpful for stack traces.\n\n ```javascript\n // bad\n var log = function(msg) {\n console.log(msg);\n };\n\n // good\n var log = function log(msg) {\n console.log(msg);\n };\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Accessors\n\n - Accessor functions for properties are not required\n - If you do make accessor functions use getVal() and setVal(\'hello\')\n\n ```javascript\n // bad\n dragon.age();\n\n // good\n dragon.getAge();\n\n // bad\n dragon.age(25);\n\n // good\n dragon.setAge(25);\n ```\n\n - If the property is a boolean, use isVal() or hasVal()\n\n ```javascript\n // bad\n if (!dragon.age()) {\n return false;\n }\n\n // good\n if (!dragon.hasAge()) {\n return false;\n }\n ```\n\n - It\'s okay to create get() and set() functions, but be consistent.\n\n ```javascript\n function Jedi(options) {\n options || (options = {});\n var lightsaber = options.lightsaber || \'blue\';\n this.set(\'lightsaber\', lightsaber);\n }\n\n Jedi.prototype.set = function(key, val) {\n this[key] = val;\n };\n\n Jedi.prototype.get = function(key) {\n return this[key];\n };\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Constructors\n\n - Assign methods to the prototype object, instead of overwriting the prototype with a new object. Overwriting the prototype makes inheritance impossible: by resetting the prototype you\'ll overwrite the base!\n\n ```javascript\n function Jedi() {\n console.log(\'new jedi\');\n }\n\n // bad\n Jedi.prototype = {\n fight: function fight() {\n console.log(\'fighting\');\n },\n\n block: function block() {\n console.log(\'blocking\');\n }\n };\n\n // good\n Jedi.prototype.fight = function fight() {\n console.log(\'fighting\');\n };\n\n Jedi.prototype.block = function block() {\n console.log(\'blocking\');\n };\n ```\n\n - Methods can return `this` to help with method chaining.\n\n ```javascript\n // bad\n Jedi.prototype.jump = function() {\n this.jumping = true;\n return true;\n };\n\n Jedi.prototype.setHeight = function(height) {\n this.height = height;\n };\n\n var luke = new Jedi();\n luke.jump(); // => true\n luke.setHeight(20) // => undefined\n\n // good\n Jedi.prototype.jump = function() {\n this.jumping = true;\n return this;\n };\n\n Jedi.prototype.setHeight = function(height) {\n this.height = height;\n return this;\n };\n\n var luke = new Jedi();\n\n luke.jump()\n .setHeight(20);\n ```\n\n\n - It\'s okay to write a custom toString() method, just make sure it works successfully and causes no side effects.\n\n ```javascript\n function Jedi(options) {\n options || (options = {});\n this.name = options.name || \'no name\';\n }\n\n Jedi.prototype.getName = function getName() {\n return this.name;\n };\n\n Jedi.prototype.toString = function toString() {\n return \'Jedi - \' + this.getName();\n };\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Events\n\n - When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event. For example, instead of:\n\n ```js\n // bad\n $(this).trigger(\'listingUpdated\', listing.id);\n\n ...\n\n $(this).on(\'listingUpdated\', function(e, listingId) {\n // do something with listingId\n });\n ```\n\n prefer:\n\n ```js\n // good\n $(this).trigger(\'listingUpdated\', { listingId : listing.id });\n\n ...\n\n $(this).on(\'listingUpdated\', function(e, data) {\n // do something with data.listingId\n });\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Modules\n\n - The module should start with a `!`. This ensures that if a malformed module forgets to include a final semicolon there aren\'t errors in production when the scripts get concatenated. [Explanation](https://github.com/airbnb/javascript/issues/44#issuecomment-13063933)\n - The file should be named with camelCase, live in a folder with the same name, and match the name of the single export.\n - Add a method called noConflict() that sets the exported module to the previous version and returns this one.\n - Always declare `\'use strict\';` at the top of the module.\n\n ```javascript\n // fancyInput/fancyInput.js\n\n !function(global) {\n \'use strict\';\n\n var previousFancyInput = global.FancyInput;\n\n function FancyInput(options) {\n this.options = options || {};\n }\n\n FancyInput.noConflict = function noConflict() {\n global.FancyInput = previousFancyInput;\n return FancyInput;\n };\n\n global.FancyInput = FancyInput;\n }(this);\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## jQuery\n\n - Prefix jQuery object variables with a `$`.\n\n ```javascript\n // bad\n var sidebar = $(\'.sidebar\');\n\n // good\n var $sidebar = $(\'.sidebar\');\n ```\n\n - Cache jQuery lookups.\n\n ```javascript\n // bad\n function setSidebar() {\n $(\'.sidebar\').hide();\n\n // ...stuff...\n\n $(\'.sidebar\').css({\n \'background-color\': \'pink\'\n });\n }\n\n // good\n function setSidebar() {\n var $sidebar = $(\'.sidebar\');\n $sidebar.hide();\n\n // ...stuff...\n\n $sidebar.css({\n \'background-color\': \'pink\'\n });\n }\n ```\n\n - For DOM queries use Cascading `$(\'.sidebar ul\')` or parent > child `$(\'.sidebar > ul\')`. [jsPerf](http://jsperf.com/jquery-find-vs-context-sel/16)\n - Use `find` with scoped jQuery object queries.\n\n ```javascript\n // bad\n $(\'ul\', \'.sidebar\').hide();\n\n // bad\n $(\'.sidebar\').find(\'ul\').hide();\n\n // good\n $(\'.sidebar ul\').hide();\n\n // good\n $(\'.sidebar > ul\').hide();\n\n // good\n $sidebar.find(\'ul\').hide();\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## ECMAScript 5 Compatibility\n\n - Refer to [Kangax](https://twitter.com/kangax/)\'s ES5 [compatibility table](http://kangax.github.com/es5-compat-table/)\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Testing\n\n - **Yup.**\n\n ```javascript\n function() {\n return true;\n }\n ```\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Performance\n\n - [On Layout & Web Performance](http://kellegous.com/j/2013/01/26/layout-performance/)\n - [String vs Array Concat](http://jsperf.com/string-vs-array-concat/2)\n - [Try/Catch Cost In a Loop](http://jsperf.com/try-catch-in-loop-cost)\n - [Bang Function](http://jsperf.com/bang-function)\n - [jQuery Find vs Context, Selector](http://jsperf.com/jquery-find-vs-context-sel/13)\n - [innerHTML vs textContent for script text](http://jsperf.com/innerhtml-vs-textcontent-for-script-text)\n - [Long String Concatenation](http://jsperf.com/ya-string-concat)\n - Loading...\n\n**[⬆ back to top](#table-of-contents)**\n\n\n## Resources\n\n\n**Read This**\n\n - [Annotated ECMAScript 5.1](http://es5.github.com/)\n\n**Other Styleguides**\n\n - [Google JavaScript Style Guide](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml)\n - [jQuery Core Style Guidelines](http://docs.jquery.com/JQuery_Core_Style_Guidelines)\n - [Principles of Writing Consistent, Idiomatic JavaScript](https://github.com/rwldrn/idiomatic.js/)\n\n**Other Styles**\n\n - [Naming this in nested functions](https://gist.github.com/4135065) - Christian Johansen\n - [Conditional Callbacks](https://github.com/airbnb/javascript/issues/52)\n - [Popular JavaScript Coding Conventions on Github](http://sideeffect.kr/popularconvention/#javascript)\n\n**Further Reading**\n\n - [Understanding JavaScript Closures](http://javascriptweblog.wordpress.com/2010/10/25/understanding-javascript-closures/) - Angus Croll\n - [Basic JavaScript for the impatient programmer](http://www.2ality.com/2013/06/basic-javascript.html) - Dr. Axel Rauschmayer\n - [You Might Not Need jQuery](http://youmightnotneedjquery.com/) - Zack Bloom & Adam Schwartz\n - [ES6 Features](https://github.com/lukehoban/es6features) - Luke Hoban\n\n**Books**\n\n - [JavaScript: The Good Parts](http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742) - Douglas Crockford\n - [JavaScript Patterns](http://www.amazon.com/JavaScript-Patterns-Stoyan-Stefanov/dp/0596806752) - Stoyan Stefanov\n - [Pro JavaScript Design Patterns](http://www.amazon.com/JavaScript-Design-Patterns-Recipes-Problem-Solution/dp/159059908X) - Ross Harmes and Dustin Diaz\n - [High Performance Web Sites: Essential Knowledge for Front-End Engineers](http://www.amazon.com/High-Performance-Web-Sites-Essential/dp/0596529309) - Steve Souders\n - [Maintainable JavaScript](http://www.amazon.com/Maintainable-JavaScript-Nicholas-C-Zakas/dp/1449327680) - Nicholas C. Zakas\n - [JavaScript Web Applications](http://www.amazon.com/JavaScript-Web-Applications-Alex-MacCaw/dp/144930351X) - Alex MacCaw\n - [Pro JavaScript Techniques](http://www.amazon.com/Pro-JavaScript-Techniques-John-Resig/dp/1590597273) - John Resig\n - [Smashing Node.js: JavaScript Everywhere](http://www.amazon.com/Smashing-Node-js-JavaScript-Everywhere-Magazine/dp/1119962595) - Guillermo Rauch\n - [Secrets of the JavaScript Ninja](http://www.amazon.com/Secrets-JavaScript-Ninja-John-Resig/dp/193398869X) - John Resig and Bear Bibeault\n - [Human JavaScript](http://humanjavascript.com/) - Henrik Joreteg\n - [Superhero.js](http://superherojs.com/) - Kim Joar Bekkelund, Mads Mobæk, & Olav Bjorkoy\n - [JSBooks](http://jsbooks.revolunet.com/)\n - [Third Party JavaScript](http://manning.com/vinegar/) - Ben Vinegar and Anton Kovalyov\n\n**Blogs**\n\n - [DailyJS](http://dailyjs.com/)\n - [JavaScript Weekly](http://javascriptweekly.com/)\n - [JavaScript, JavaScript...](http://javascriptweblog.wordpress.com/)\n - [Bocoup Weblog](http://weblog.bocoup.com/)\n - [Adequately Good](http://www.adequatelygood.com/)\n - [NCZOnline](http://www.nczonline.net/)\n - [Perfection Kills](http://perfectionkills.com/)\n - [Ben Alman](http://benalman.com/)\n - [Dmitry Baranovskiy](http://dmitry.baranovskiy.com/)\n - [Dustin Diaz](http://dustindiaz.com/)\n - [nettuts](http://net.tutsplus.com/?s=javascript)\n\n**[⬆ back to top](#table-of-contents)**\n\n## In the Wild\n\nThis is a list of organizations that are using this style guide. Send us a pull request or open an issue and we\'ll add you to the list.\n\n - **Aan Zee**: [AanZee/javascript](https://github.com/AanZee/javascript)\n - **Airbnb**: [airbnb/javascript](https://github.com/airbnb/javascript)\n - **American Insitutes for Research**: [AIRAST/javascript](https://github.com/AIRAST/javascript)\n - **Compass Learning**: [compasslearning/javascript-style-guide](https://github.com/compasslearning/javascript-style-guide)\n - **Digitpaint** [digitpaint/javascript](https://github.com/digitpaint/javascript)\n - **ExactTarget**: [ExactTarget/javascript](https://github.com/ExactTarget/javascript)\n - **Gawker Media**: [gawkermedia/javascript](https://github.com/gawkermedia/javascript)\n - **GeneralElectric**: [GeneralElectric/javascript](https://github.com/GeneralElectric/javascript)\n - **GoodData**: [gooddata/gdc-js-style](https://github.com/gooddata/gdc-js-style)\n - **Grooveshark**: [grooveshark/javascript](https://github.com/grooveshark/javascript)\n - **How About We**: [howaboutwe/javascript](https://github.com/howaboutwe/javascript)\n - **Mighty Spring**: [mightyspring/javascript](https://github.com/mightyspring/javascript)\n - **MinnPost**: [MinnPost/javascript](https://github.com/MinnPost/javascript)\n - **ModCloth**: [modcloth/javascript](https://github.com/modcloth/javascript)\n - **Money Advice Service**: [moneyadviceservice/javascript](https://github.com/moneyadviceservice/javascript)\n - **National Geographic**: [natgeo/javascript](https://github.com/natgeo/javascript)\n - **National Park Service**: [nationalparkservice/javascript](https://github.com/nationalparkservice/javascript)\n - **Orion Health**: [orionhealth/javascript](https://github.com/orionhealth/javascript)\n - **Peerby**: [Peerby/javascript](https://github.com/Peerby/javascript)\n - **Razorfish**: [razorfish/javascript-style-guide](https://github.com/razorfish/javascript-style-guide)\n - **SeekingAlpha**: [seekingalpha/javascript-style-guide](https://github.com/seekingalpha/javascript-style-guide)\n - **reddit**: [reddit/styleguide/javascript](https://github.com/reddit/styleguide/tree/master/javascript)\n - **REI**: [reidev/js-style-guide](https://github.com/reidev/js-style-guide)\n - **Ripple**: [ripple/javascript-style-guide](https://github.com/ripple/javascript-style-guide)\n - **Shutterfly**: [shutterfly/javascript](https://github.com/shutterfly/javascript)\n - **Userify**: [userify/javascript](https://github.com/userify/javascript)\n - **Zillow**: [zillow/javascript](https://github.com/zillow/javascript)\n - **ZocDoc**: [ZocDoc/javascript](https://github.com/ZocDoc/javascript)\n\n## Translation\n\nThis style guide is also available in other languages:\n\n - :de: **German**: [timofurrer/javascript-style-guide](https://github.com/timofurrer/javascript-style-guide)\n - :jp: **Japanese**: [mitsuruog/javacript-style-guide](https://github.com/mitsuruog/javacript-style-guide)\n - :br: **Portuguese**: [armoucar/javascript-style-guide](https://github.com/armoucar/javascript-style-guide)\n - :cn: **Chinese**: [adamlu/javascript-style-guide](https://github.com/adamlu/javascript-style-guide)\n - :es: **Spanish**: [paolocarrasco/javascript-style-guide](https://github.com/paolocarrasco/javascript-style-guide)\n - :kr: **Korean**: [tipjs/javascript-style-guide](https://github.com/tipjs/javascript-style-guide)\n - :fr: **French**: [nmussy/javascript-style-guide](https://github.com/nmussy/javascript-style-guide)\n - :ru: **Russian**: [uprock/javascript](https://github.com/uprock/javascript)\n - :bg: **Bulgarian**: [borislavvv/javascript](https://github.com/borislavvv/javascript)\n\n## The JavaScript Style Guide Guide\n\n - [Reference](https://github.com/airbnb/javascript/wiki/The-JavaScript-Style-Guide-Guide)\n\n## Contributors\n\n - [View Contributors](https://github.com/airbnb/javascript/graphs/contributors)\n\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2014 Airbnb\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\'Software\'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \'AS IS\', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n**[⬆ back to top](#table-of-contents)**\n\n# };\n',
18 silly publish readmeFilename: 'README.md',
18 silly publish gitHead: 'b0b0ef1fc8bce1a6f90ca9e5a56b9371484aa182',
18 silly publish _id: '@aboutdotme/javascript@1.0.4',
18 silly publish _shasum: '9ec08f146589c88d19946f3871eb43b09c484964',
18 silly publish _from: '.' }
19 verbose getPublishConfig undefined
20 silly mapToRegistry name @aboutdotme/javascript
21 silly mapToRegistry scope (from package name) @aboutdotme
22 verbose mapToRegistry no registry URL found in name for scope @aboutdotme
23 silly mapToRegistry using default registry
24 silly mapToRegistry registry https://registry.npmjs.org/
25 silly mapToRegistry uri https://registry.npmjs.org/@aboutdotme%2fjavascript
26 verbose publish registryBase https://registry.npmjs.org/
27 silly publish uploading /Users/nigel/.npm/@aboutdotme/javascript/1.0.4/package.tgz
28 verbose request uri https://registry.npmjs.org/@aboutdotme%2fjavascript
29 verbose request sending authorization for write operation
30 info attempt registry request try #1 at 2:18:27 PM
31 verbose request using bearer token for auth
32 verbose request id e133a85704cf2463
33 http request PUT https://registry.npmjs.org/@aboutdotme%2fjavascript
34 http 403 https://registry.npmjs.org/@aboutdotme%2fjavascript
35 verbose headers { 'content-type': 'application/json',
35 verbose headers 'cache-control': 'max-age=0',
35 verbose headers 'content-length': '95',
35 verbose headers 'accept-ranges': 'bytes',
35 verbose headers date: 'Wed, 18 Nov 2015 23:18:28 GMT',
35 verbose headers via: '1.1 varnish',
35 verbose headers connection: 'keep-alive',
35 verbose headers 'x-served-by': 'cache-lax1421-LAX',
35 verbose headers 'x-cache': 'MISS',
35 verbose headers 'x-cache-hits': '0',
35 verbose headers 'x-timer': 'S1447888708.464412,VS0,VE439' }
36 verbose request invalidating /Users/nigel/.npm/registry.npmjs.org/_40aboutdotme_252fjavascript on PUT
37 error publish Failed PUT 403
38 verbose stack Error: "You cannot publish over the previously published version 1.0.4." : @aboutdotme/javascript
38 verbose stack at makeError (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:264:12)
38 verbose stack at CachingRegistryClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:252:14)
38 verbose stack at Request._callback (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:172:14)
38 verbose stack at Request.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/request.js:198:22)
38 verbose stack at emitTwo (events.js:87:13)
38 verbose stack at Request.emit (events.js:172:7)
38 verbose stack at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1063:14)
38 verbose stack at emitOne (events.js:82:20)
38 verbose stack at Request.emit (events.js:169:7)
38 verbose stack at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1009:12)
39 verbose statusCode 403
40 verbose pkgid @aboutdotme/javascript
41 verbose cwd /Users/nigel/about.me/javascript
42 error Darwin 15.0.0
43 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "publish"
44 error node v5.0.0
45 error npm v3.3.6
46 error code E403
47 error "You cannot publish over the previously published version 1.0.4." : @aboutdotme/javascript
48 error If you need help, you may report this error at:
48 error <https://github.com/npm/npm/issues>
49 verbose exit [ 1, true ]