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

ersatz-ellip

v1.0.3

Published

An ellipsis function that's usually good enough. Works with strings, arrays and similar.

Downloads

41

Readme

ersatz-ellip

An ellipsis function that's usually good enough. Works with strings, arrays and similar.

API

This module exports one function with one method:

ersatzEllip(seq[, max[, end[, gap]]])

Return a possibly shortened version of input seq that is at most max long, either as a number of elements, or as a fraction, in which case it means that fraction of the original length. Note that the fraction has to be strictly smaller than 1, because otherwise there's no need to use this function.

Works with any input that has suitable .length, .slice and .concat, e.g. strings or arrays.

end allows to modify how much of the preview length shall be used for elements from the back, thereby reducing how many elements are copied from the front. Like with max, can be a fraction.

If seq needs to be shortened, the copied part(s) are glued together with gap, which defaults to . Make sure your gap has a length greater than or equal to 0. (Versions before 1.0.3 had required a positive length.)

ersatzEllip.split(seq, max, end, gap)

Just the splitting part. Returns an Array with one or two subsequences. Usecases include encoding the subsequences individually and then joining them with a gap that shall not be encoded.

If there is a second part, the array will also carry a property gap that holds the effective gap value that was used to calculate part lengths.

For your destructuring convenience, the result array will also carry its parts as additional properties head and (if applicable) tail.

Usage

see test.usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC