ascii-hash
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ascii-hash

Fast and naive non-cryptographic hash.

Calculates the sum of each character in a string using their character (ASCII) codes. This makes it a computationally cheap way to create relatively unique IDs. Use cases could include React key generation or the creation of a few user IDs.

Installation

npm i ascii-hash
# or
yarn add ascii-hash

Usage

const { asciiHash } = require("ascii-hash");

asciiHash("hello world!") // "1149"

For better performance with consecutive calls (such as in a React render method), consider using the memoized version which caches previous results in memory.

const { asciiHashMem } = require("ascii-hash");

asciiHashMem("hello world!") // "1149"

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    0

Package Sidebar

Install

npm i ascii-hash

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.65 kB

Total Files

4

Last publish

Collaborators

  • lousando