just-prune

prune a string with whole words and a custom suffix

Usage no npm install needed!

<script type="module">
  import justPrune from 'https://cdn.skypack.dev/just-prune';
</script>

README

just-prune

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-prune
yarn add just-prune

Prune a string with whole words and a custom suffix

  prune('when shall we three meet again', 7); // 'when...'
  prune('when shall we three meet again', 7, ' (more)'; // 'when (more)'
  prune('when shall we', 15,); // 'when shall we'
  prune('when shall we', 15, ' (etc)'); // 'when shall we'
  prune('when shall we', 7, ' (more)'); // ' (more)'