Although this isn't a problem in other languages, because of semicolon insertion, there could be problems if you don't place the bracket on the opening line:
// no:
function()
{
/* | |
Copyright 2011 Martin Hawksey | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
/** | |
* Add attributes to each object of an array. | |
* | |
* @param {array} foo - Array of objects where we will add the attibutes | |
* @param {function} iterator | |
*/ | |
_.each(foo, function(element, index) { | |
_.extend(element, {field1: index}, {field2: 'bar', field3: 'baz'}); | |
}); |
'use strict'; | |
define(['phaser'], function(Phaser) { | |
function Gesture(game) { | |
this.game = game; | |
this.swipeDispatched = false; | |
this.holdDispatched = false; | |
this.isTouching = false; |
/** | |
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded | |
* templates and such with AngularJS. Use this simple directive to | |
* tame this beast once and for all. | |
* | |
* Usage: | |
* <input type="text" autofocus> | |
* | |
* License: MIT | |
*/ |
console.log("Usage Syntax: scanScope(objectToScan, 'scanFor', ['whatToIgnore']); %c(whatToIgnore is optional and can be a string, or an array of strings) (scanScope can be shortened to ss)", 'color: red'); | |
var abortAtLevel = 20, | |
callStack = 0, | |
errArray = [], | |
funArray = [], | |
scanLoop = function (whatToScan, scanValue, whatToIgnore, parentTree) { | |
scanValue = scanValue.toLowerCase(); | |
if (Array.isArray(whatToIgnore)) { | |
whatToIgnore.forEach(function (ignoreVal) { | |
ignoreVal = lowerCase(ignoreVal); |
// from https://github.com/thinkphp/String.levenshtein/blob/master/Source/String.levenshtein.js but no depencencies | |
function levenshtein(str1, str2) { | |
var cost = new Array(), | |
n = str1.length, | |
m = str2.length, | |
i, j; | |
var minimum = function(a, b, c) { | |
var min = a; | |
if (b < min) { |