# initials

> initials for names

Latest version **3.1.2** (published 2021-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install initials
pnpm add initials
yarn add initials
bun add initials
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.2 |
| Published | 2021-12-17 |
| First published | 2014-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 31 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gregor Martynus |
| Maintainers | gr2m, boennemann, zoepage |

## Links

- npm: https://www.npmjs.com/package/initials
- Repository: https://github.com/gr2m/initials
- Homepage: http://gr2m.github.io/initials
- Issues: https://github.com/gr2m/initials/issues
- npm.io page: https://npm.io/package/initials

## Recent versions

- 3.1.2 (latest) — 2021-12-17
- 3.1.1 — 2020-06-09
- 3.1.0 — 2020-05-26
- 3.0.1 — 2019-03-11
- 3.0.0 — 2018-05-21
- 2.1.5 — 2015-10-31
- 2.1.4 — 2015-10-12
- 2.1.3 — 2015-10-12
- 2.1.2 — 2015-10-12
- 2.1.1 — 2015-10-12
- 2.1.0 — 2015-10-12
- 2.0.0 — 2015-09-09
- 1.0.4 — 2015-09-05
- 1.0.3 — 2015-02-23
- 1.0.2 — 2015-02-09
- … 8 more at https://npm.io/package/initials/versions

## README

Initials. Because JD is shorter than John Doe
=============================================

> extracts initials from and adds initials to names

[![Build Status](https://travis-ci.org/gr2m/initials.svg?branch=main)](https://travis-ci.org/gr2m/initials)
[![Coverage Status](https://coveralls.io/repos/gr2m/initials/badge.svg?branch=main)](https://coveralls.io/r/gr2m/initials?branch=main)
[![Greenkeeper badge](https://badges.greenkeeper.io/gr2m/initials.svg)](https://greenkeeper.io/)

## Installation

Install using [npm](https://npmjs.org/) for node.js:

```
npm install --save initials
```


## Usage

```js
initials('John Doe')
// 'JD'

initials(['John Doe', 'Robert Roe'])
// ['JD', 'RR']

// alias for initials('John Doe')
initials.find('John Doe')

// parse name(s)
initials.parse('John Doe')
// {name: 'John Doe', initials: 'JD'}

// add initials to name(s)
initials.addTo('John Doe')
// 'John Doe (JD)'

// pass existing initials for names
initials(['John Doe', 'Jane Dane'], {
  existing: { 'John Doe': 'JD' }
})
// ['JD', 'JDa']
```

## Notes

Preffered initials can be passed in `(JD)`, e.g.

```js
console.log( initials('John Doe (JoDo)') );
// 'JoDo'
```

If a name contains an email, it gets ignored when calculating initials

```js
console.log( initials('John Doe joe@example.com') );
// 'JD'
```

If a name _is_ an email, the domain part gets ignored

```js
console.log( initials('joe@example.com') );
// 'jo'
```

When passing an Array of names, duplicates of initials are avoided

```js
console.log( initials(['John Doe', 'Jane Dane']) );
// ['JDo', 'JDa']
```

## Test

```
npm test
```


## LICENSE

[MIT](LICENSE)

---
_Source: https://npm.io/package/initials · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
