Socket
Book a DemoInstallSign in
Socket

generate-alphabetic-name

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generate-alphabetic-name

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

latest
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

Generate Alphabetic Name

Take an arbitrary string or integer and generate a short alphabetic 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

FAQs

Package last updated on 18 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts