2.0.18 • Published 3 months ago

string-truncator v2.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Install

This package is pure ESM.

npm i string-truncator

Quick Take

import { strict as assert } from "assert";

import { truncate } from "string-truncator";

// maxLen setting means limit length to equivalent of 10
// longest letter lengths (font "Outfit" letter lengths are used)
// and you can override those references with your font-specific lengths
assert.deepEqual(truncate("Supermotodelicious", { maxLen: 10 }), {
  result: "Supermotodelic",
  addEllipsis: true,
});

assert.deepEqual(
  truncate(
    "the quick brown fox jumps over the lazy dog and then bites him in the tail and runs away",
    {
      maxLen: 10,
      maxLines: 2,
    },
  ),
  {
    result: "the quick brown fox jumps over",
    addEllipsis: true,
  },
);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2024 Roy Revelt and other contributors.

2.0.18

3 months ago

2.0.17

4 months ago

2.0.16

4 months ago

2.0.15

8 months ago

2.0.13

12 months ago

2.0.14

10 months ago

2.0.11

1 year ago

2.0.7

1 year ago

2.0.12

12 months ago

2.0.9

1 year ago

2.0.10

1 year ago

2.0.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.6

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago