-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
50,864 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
Number.prototype.clamp = function(min, max) { | ||
return Math.min(Math.max(this, min), max); | ||
}; | ||
|
||
/** | ||
* String formatting now supports currying (partial application). | ||
* For a format string with N replacement indices, you can call .format | ||
* with M <= N arguments. The result is going to be a format string | ||
* with N-M replacement indices, properly counting from 0 .. N-M. | ||
* The following Example should explain the usage of partial applied format: | ||
* "{0}:{1}:{2}".format("a","b","c") === "{0}:{1}:{2}".format("a","b").format("c") | ||
* "{0}:{1}:{2}".format("a").format("b").format("c") === "{0}:{1}:{2}".format("a").format("b", "c") | ||
**/ | ||
String.prototype.format = function () { | ||
var args = arguments; | ||
return this.replace(/\{(\d+)\}/g, function (t, i) { | ||
return args[i] !== void 0 ? args[i] : "{"+(i-args.length)+"}"; | ||
}); | ||
}; | ||
|
||
Array.prototype.push8 = function(val) { | ||
this.push(0xFF & val); | ||
return this; | ||
}; | ||
|
||
Array.prototype.push16 = function(val) { | ||
// low byte | ||
this.push(0x00FF & val); | ||
// high byte | ||
this.push(val >> 8); | ||
// chainable | ||
return this; | ||
}; | ||
|
||
Array.prototype.push32 = function(val) { | ||
this.push8(val) | ||
.push8(val >> 8) | ||
.push8(val >> 16) | ||
.push8(val >> 24); | ||
return this; | ||
}; | ||
|
||
DataView.prototype.offset = 0; | ||
DataView.prototype.readU8 = function() { | ||
if (this.byteLength >= this.offset+1) { | ||
return this.getUint8(this.offset++); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
DataView.prototype.readU16 = function() { | ||
if (this.byteLength >= this.offset+2) { | ||
return this.readU8() + this.readU8()*256; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
DataView.prototype.readU32 = function() { | ||
if (this.byteLength >= this.offset+4) { | ||
return this.readU16() + this.readU16()*65536; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
DataView.prototype.read8 = function() { | ||
if (this.byteLength >= this.offset+1) { | ||
return this.getInt8(this.offset++, 1); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
DataView.prototype.read16 = function() { | ||
this.offset += 2; | ||
if (this.byteLength >= this.offset) { | ||
return this.getInt16(this.offset-2, 1); | ||
} else { | ||
return null; | ||
} | ||
}; | ||
|
||
DataView.prototype.read32 = function() { | ||
this.offset += 4; | ||
if (this.byteLength >= this.offset) { | ||
return this.getInt32(this.offset-4, 1); | ||
} else { | ||
return null; | ||
} | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* jQuery throttle / debounce - v1.1 - 3/7/2010 | ||
* http://benalman.com/projects/jquery-throttle-debounce-plugin/ | ||
* | ||
* Copyright (c) 2010 "Cowboy" Ben Alman | ||
* Dual licensed under the MIT and GPL licenses. | ||
* http://benalman.com/about/license/ | ||
*/ | ||
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.