npm.io
2.2.1 • Published 1 year ago

shortfield

Licence
MIT
Version
2.2.1
Deps
1
Size
6 kB
Vulns
0
Weekly
0
CI / CD Status
NPM npm version
Semaphore CI Build Status
Circle CI CircleCI
Coverall Coverage Status
SonarCloud Quality Gate Status

shortfield returns a string truncated after X characters (default 10), concatenated with "..." (three dots).

Useful in tables with long strings.

E.g. "This is a long string" will return "This is a ..."

Installation

npm install shortfield

Usage

import { Shortener } from "shortfield";

var shorted = Shortener("This is a long string"); // default length is 10
console.log(shorted); // returns This is a ...

var shorted = Shortener("This is a long string", 4);
console.log(shorted); // returns This...

Keywords