Skip to content

Instantly share code, notes, and snippets.

@evlymn
Last active September 10, 2022 03:39
Show Gist options
  • Save evlymn/183613ef9d7792eedac444341665873c to your computer and use it in GitHub Desktop.
Save evlymn/183613ef9d7792eedac444341665873c to your computer and use it in GitHub Desktop.
Clean String and Hash Code Typescript
cleanString = (str: string) => str.replace(/[^\w ]/g, '').replace(/\s/g, '');
hash = (str: string) => str.split('').reduce((prev, curr) => (((prev << 5) - prev) + curr.charCodeAt(0)) | 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment