Don't do this. Why am I doing it, then? Because indexOf is so
slooooooooooooooooooooooooooooooooooooooooooooooooooooooooooow
This commit is contained in:
Zixaphir 2013-12-24 15:33:39 -07:00
parent 7b4c794729
commit b060a9c23e
5 changed files with 39 additions and 30 deletions

View File

@ -16,6 +16,7 @@ module.exports = (grunt) ->
)
coffee:
src: [
'src/General/Cheats.coffee'
'src/General/Config.coffee'
'src/General/Globals.coffee'
'src/General/lib/*.coffee'

View File

@ -352,18 +352,6 @@
posts: {}
};
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === val) {
return i;
}
}
return i;
};
$ = function(selector, root) {
if (root == null) {
root = d.body;
@ -833,6 +821,20 @@
return __slice.call(root.querySelectorAll(selector));
};
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === val) {
return i;
}
}
return i;
};
__indexOf = [].indexOf;
Board = (function() {
Board.prototype.toString = function() {
return this.ID;

View File

@ -330,18 +330,6 @@
posts: {}
};
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === val) {
return i;
}
}
return i;
};
$ = function(selector, root) {
if (root == null) {
root = d.body;
@ -840,6 +828,20 @@
return __slice.call(root.querySelectorAll(selector));
};
Array.prototype.indexOf = function(val) {
var i;
i = this.length;
while (i--) {
if (this[i] === val) {
return i;
}
}
return i;
};
__indexOf = [].indexOf;
Board = (function() {
Board.prototype.toString = function() {
return this.ID;

10
src/General/cheats.coffee Normal file
View File

@ -0,0 +1,10 @@
# I am bad at JavaScript and if you reuse this, so are you.
Array::indexOf = (val) ->
i = @length
while i--
return i if @[i] is val
return i
# Update CoffeeScript's reference to [].indexOf
# Reserved keywords are ignored in embedded javascript.
`__indexOf = [].indexOf`

View File

@ -1,9 +1,3 @@
Array::indexOf = (val) ->
i = @length
while i--
return i if @[i] is val
return i
# loosely follows the jquery api:
# http://api.jquery.com/
# not chainable