npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trimcate

v1.0.2

Published

convert long text into a previewable short text with with a start length and an end length

Downloads

6

Readme

trimcate

take a long text, and return a truncated previewable version:

Input: (https://tools.ietf.org/html/rfc1866)

  "The Hypertext Markup Language (HTML) is a simple markup language used to create hypertext documents that are platform independent. HTML documents are SGML documents with generic semantics that are appropriate for representing information from a wide range of domains. HTML markup can represent hypertext news, mail, documentation, and hypermedia; menus of options; database query results; simple structured documents with in-lined graphics; and hypertext views of existing bodies of information."

Output:

  "The Hypertext Markup Language (HTML) … of information."

trimcate

  trimcate(text, options)

options object

you can run trimcate without any options, or put one or all into your call:

  prelude: 20, // {Number} how long the beginning text should be, default `20`
  postlude: 10, // {Number} how long the end text should be, default `10`
  separator: '…', // {String} to glue start and end together, default `…`
  wholeWorlds: false, // {Boolean} telling trimcate preserve words and don't cut hard into the text, default `false`

you can set all or single or some of the options:

trimcate("Hello World…", { wholeWords: true });

trimcate("Hello World…", { prelude: 36, postlude: 8 });

trimcate("Hello World…", { prelude: 24, separator: '🤍' });

usage

  import trimcate from 'trimcate';
  …
  return trimcate(text);

Have a look at index.html to see a working example