Skip to content

Take an arbitrary string or integer and generate a short alphabetic code

Notifications You must be signed in to change notification settings

ForbesLindesay-Bot/generate-alphabetic-name

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Generate Alphabetic Name

Take an arbitrary string or integer and generate a short alphanumeric code. It works in the browser and node.js and is designed to be as small as possible, and extremely fast.

It uses the murmurhash algorithm, and borrows its implementation from the code for generating class names in styled-components

Installation

yarn add generate-alphabetic-name

Usage

import {readFileSync} from 'fs';
import generateAlphabeticName from './generateAlphabeticName';

console.log(generateAlphabeticName(readFileSync(__filename, 'utf8')));
console.log(generateAlphabeticName(42));

You can also just hash a string to a number:

import {readFileSync} from 'fs';
import {hash} from './generateAlphabeticName';

console.log(hash(readFileSync(__filename, 'utf8')));

If you prefer, you can directly reference generateAlphabeticNameFromNumber:

import {readFileSync} from 'fs';
import {hash, generateAlphabeticNameFromNumber} from './generateAlphabeticName';

console.log(generateAlphabeticNameFromNumber(hash(readFileSync(__filename, 'utf8'))));

License

MIT

About

Take an arbitrary string or integer and generate a short alphabetic code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published