Skip to content

Commit 308d3fa

Browse files
committed
Add jshint
1 parent e23dfd3 commit 308d3fa

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

Gruntfile.coffee

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ module.exports = (grunt) ->
140140
# Run concat, autoprefixer, cssmin and uglify
141141
tasks: ['build']
142142

143+
jshint:
144+
options:
145+
curly: true,
146+
eqeqeq: true,
147+
immed: true,
148+
latedef: true,
149+
newcap: true,
150+
noarg: true,
151+
sub: true,
152+
undef: true,
153+
boss: true,
154+
eqnull: true,
155+
node: true,
156+
strict: false,
157+
mocha: true
158+
all:
159+
src: ['src/*.js']
160+
143161
# Jasmine test
144162

145163
jasmine:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"grunt-contrib-cssmin": "~0.10.0",
2525
"grunt-contrib-uglify": "~0.6.0",
2626
"grunt-contrib-coffee": "~0.12.0",
27+
"grunt-contrib-jshint": "~0.10.0",
2728
"grunt-contrib-jasmine": "~0.8.0",
2829
"grunt-template-jasmine-istanbul": "~0.3.0",
2930
"load-grunt-tasks": "~0.6.0"

src/Array.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
var BinArray = (function(){
77
var BinArray = {};
88
BinArray.bsearch = function(arr, what, how){
9-
if(arr.length == 0) return 0;
10-
if(how(what,arr[0]) < 0) return 0;
11-
if(how(what,arr[arr.length - 1]) >=0) return arr.length;
9+
if(arr.length === 0) {
10+
return 0;
11+
}
12+
if(how(what,arr[0]) < 0) {
13+
return 0;
14+
}
15+
if(how(what,arr[arr.length - 1]) >=0) {
16+
return arr.length;
17+
}
1218
var low =0;
1319
var i = 0;
1420
var count = 0;
@@ -18,15 +24,17 @@ var BinArray = (function(){
1824
count++;
1925
if(how(what,arr[i-1])>=0 && how(what,arr[i])<0){
2026
return i;
21-
}else if(how(what,arr[i-1])<0){
27+
}
28+
if(how(what,arr[i-1])<0){
2229
high = i-1;
2330
}else if(how(what,arr[i])>=0){
2431
low = i;
25-
}else
32+
}else {
2633
console.error('Program Error');
27-
if(count > 1500) console.error('Too many run cycles.');
34+
}
35+
if(count > 1500) { console.error('Too many run cycles.'); }
2836
}
29-
return -1;
37+
return -1; //this line can never been run
3038
};
3139
BinArray.binsert = function(arr, what, how){
3240
var index = BinArray.bsearch(arr,what,how);

0 commit comments

Comments
 (0)