mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-08-29 09:28:23 +02:00
* chore: upgrade eslint to v9 latest with compatible lint deps Agent-Logs-Url: https://github.com/lucide-icons/lucide/sessions/f7c1f1b5-d213-4afa-91a8-b799a16397ec * Fix eslint config * Fix a lot of eslint errors * Fix eslint * Fix eslint errors * Fix eslint errors * Fix types * Fix eslint warning * Format code * Add eslint 10 * Remove unused vars * Update pnpm * Update deps --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
27 lines
716 B
TypeScript
27 lines
716 B
TypeScript
/**
|
|
* djb2 hashing function
|
|
*
|
|
* @param {string} string
|
|
* @param {number} seed
|
|
* @returns {string} A hashed string of 6 characters
|
|
*/
|
|
export const hash = (string: string, seed = 5381) => {
|
|
let i = string.length;
|
|
|
|
while (i) {
|
|
seed = (seed * 33) ^ string.charCodeAt(--i);
|
|
}
|
|
|
|
return (seed >>> 0).toString(36).substr(0, 6);
|
|
};
|
|
|
|
/**
|
|
* Generate Hashed string based on name and attributes
|
|
*
|
|
* @param {object} seed
|
|
* @param {string} seed.name A name, for example an icon name
|
|
* @param {object} seed.attributes An object of SVGElement Attrbutes
|
|
* @returns {string} A hashed string of 6 characters
|
|
*/
|
|
export const generateHashedKey = ({ name, attributes }) => hash(JSON.stringify([name, attributes]));
|