Created
October 22, 2013 08:37
-
-
Save inhji/7097180 to your computer and use it in GitHub Desktop.
Helpers
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
### | |
http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/ | |
### | |
String::hashCode = -> | |
hash = 0 | |
return hash if @length is 0 | |
while i < @length | |
c = @charCodeAt(i) | |
hash = ((hash<<5) - hash) + char | |
hash = hash & hash | |
hash | |
### | |
http://stackoverflow.com | |
### | |
Object::count = -> | |
that = this | |
count = 0 | |
for property of that | |
count++ if that.hasOwnProperty(property) | |
count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment