Skip to content

Commit

Permalink
[TS migration] Migrate 'hashCode.js' lib to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Aug 28, 2023
1 parent dfb7e23 commit 242c725
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libs/hashCode.js → src/libs/hashCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
/**
* Simple string hashing function obtained from: https://stackoverflow.com/a/8831937/16434681
* Returns a hash code from a string
* @param {String} str The string to hash.
* @return {Number} A 32bit integer (can be negative)
* @param str The string to hash.
* @return A 32bit integer (can be negative)
* @see http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
*/
function hashCode(str) {
function hashCode(str: string): number {
let hash = 0;
for (let i = 0, len = str.length; i < len; i++) {
const chr = str.charCodeAt(i);
Expand Down

0 comments on commit 242c725

Please sign in to comment.