-
-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor createRequest parsing and hashing (#383)
* Refactor createRequest parsing and hashing Co-authored-by: Jovi De Croock <decroockjovi@gmail.com> * Revert change to request return statement * Remove graphql-tag dependency * Fix consistent hashing between DocumentNodes and strings * Fix copy-paste issue in normalizer
- Loading branch information
Showing
9 changed files
with
100 additions
and
205 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// When we have separate strings it's useful to run a progressive | ||
// version of djb2 where we pretend that we're still looping over | ||
// the same string | ||
export const phash = (h: number, x: string): number => { | ||
h = h | 0; | ||
for (let i = 0, l = x.length | 0; i < l; i++) { | ||
h = (h << 5) + h + x.charCodeAt(i); | ||
} | ||
|
||
return h; | ||
}; | ||
|
||
// This is a djb2 hashing function | ||
export const hash = (x: string): number => phash(5381 | 0, x) >>> 0; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
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