Skip to content

ozgurg/akronim

Repository files navigation

Downloads Version

akronim

An acronym generator with useful options.

Install

npm install akronim

This package is a pure ESM package.

Usage

import akronim from "akronim";

akronim("Mustafa Kemal Atatürk");
// "MKA"

akronim("God of War");
// "GOW"

akronim("GitHub");
// "GH"

akronim("Game of Thrones", { ignoreLowercaseWords: true });
// "GT"

akronim("Grand Theft Auto", { separateWith: "." });
// "G.T.A."

akronim("Grand Theft Auto", { separateWith: ".", trimLastSeparator: true });
// "G.T.A"

akronim("To be announced", { capitalize: false });
// "Tba"

API

akronim(text, options) : string

text

Text to generate the acronym.

Note: It will be trimmed with .trim().

Type: string | number
Required: Yes

options

Default: {}
Type: object
Required: No

options.ignoreLowercaseWords

Ignores lowercase words in the input.

Default: false
Type: boolean
Required: No

akronim("Game of Thrones", { ignoreLowercaseWords: true });
// "GT"

options.separateWith

Separates the output with the given value.

Note: It will be trimmed with .trim().

Default: ""
Type: string | number
Required: No

akronim("Grand Theft Auto", { separateWith: "." });
// "G.T.A."

options.trimLastSeparator

Trims the last separator in the output when using with options.separateWith.

Default: false
Type: boolean
Required: No

akronim("Grand Theft Auto", { separateWith: ".", trimLastSeparator: true });
// "G.T.A"

options.capitalize

Capitalizes all letters in the output.

Default: true
Type: boolean
Required: No

akronim("To be announced");
akronim("To be announced", { capitalize: true });
// "TBA"

akronim("To be announced", { capitalize: false });
// "Tba"

License

License