# name-shorten

> A small npm package to shorten long names

Latest version **1.4.5** (published 2019-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install name-shorten
pnpm add name-shorten
yarn add name-shorten
bun add name-shorten
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.5 |
| Published | 2019-08-30 |
| First published | 2019-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mario Kennedy |
| Maintainers | koiram |
| Keywords | npm, package |

## Links

- npm: https://www.npmjs.com/package/name-shorten
- Repository: https://github.com/mario7746/name-shorten
- Homepage: https://github.com/mario7746/name-shorten#readme
- Issues: https://github.com/mario7746/name-shorten/issues
- npm.io page: https://npm.io/package/name-shorten

## Recent versions

- 1.4.5 (latest) — 2019-08-30
- 1.4.4 — 2019-08-29
- 1.4.3 — 2019-08-29
- 1.4.2 — 2019-08-29
- 1.4.1 — 2019-08-29
- 1.4.0 — 2019-08-29
- 1.2.3 — 2019-08-28
- 1.2.2 — 2019-08-28
- 1.2.1 — 2019-08-28
- 1.2.0 — 2019-08-27
- 1.1.0 — 2019-08-20
- 1.0.0 — 2019-08-20

## README

# Name Shorten

[![npm (scoped)](https://img.shields.io/npm/v/name-shorten.svg)](https://www.npmjs.com/package/name-shorten)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/name-shorten)](https://www.npmjs.com/package/name-shorten)

## Takes long names turns them into a shortened version

To use:

1. ```yarn add name-shorten```


#### Example:

    import React, { Component } from 'react'
    import nameShorten from 'name-shorten'

    class App extends Component {
        state = {
            firstName: '',
            lastName: '',
            shortName: ''
        }

        onInputChange = e => {
            this.setState({
            [e.target.name]: e.target.value,
             shortName: ''
        })

        getShortName = () => {
            const { firstName, lastName } = this.state
            const shortenedName = nameShorten(firstName, lastName)

            this.setState({
                shortName: shortenedName
            })
        }


        render() {
            const { firstName, lastName, shortName } = this.state
            return (
            <div className="App">
                <h1>Name Shortener</h1>
                <p>Shorten long names down to a max of 18 characters</p>
    
                <div className="nameContainer">
                    <input 
                        value={firstName} 
                        type="text" 
                        maxLength={15} 
                        placeholder="First Name" 
                        name="firstName"
                        onChange={this.onInputChange}
                    />
                    <input 
                        value={lastName} 
                        type="text" 
                        maxLength={15} 
                        placeholder="Last Name" 
                        name="lastName"
                        onChange={this.onInputChange}
                    />
                </div>
                <button onClick={this.getShortName}>Submit</button>
                {shortName !== '' &&
                <div className="resultContainer">
                    <p>{shortName}</p>
                </div>
                }
            </div>
            )
        }
    }

    export default App

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