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

@zenith-to/lumen-js

v1.0.0

Published

A JavaScript text processing library

Downloads

5

Readme

Lumen | Zenith

A JavaScript utility that provides text processing routines for post content.

I'm creating Lumen to lay the foundations of a social networking platform that I have in mind. And, as you can easily guess, users in a social network interact mainly through a component that allows them to publish text, links, images, emoji and much more. The library provides autolinking and extraction for URLs, usernames, lists, and hashtags.

Based on twitter-text.

NPM Users

Install it with: npm install @zenith-to/lumen-js

The lumen namespace is exported, making it available as such:

var lumen = require('@zenith-to/lumen-js')
lumen.autoLink(lumen.htmlEscape('#hello < @world >'))

Extraction Examples

// basic extraction
var usernames = lumen.extractMentions("Mentioning @vincent and @james")
// usernames == ["vincent", "james"]

Auto-linking Examples

lumen.autoLink("link @user, please #request");

lumen.autoLink("link @user, and expand url... http://z.to/0JG5Mcq", {
    urlEntities: [
        {
          "url": "http://z.to/0JG5Mcq",
          "display_url": "blog.zenith.to/2025/05/zenith…",
          "expanded_url": "http://blog.zenith.to/2025/05/zenith-is-online",
          "indices": [
            30,
            48
          ]
        }
    ]});

Content Parsing

lumen exposes a "parseText" method that will return the following fields:

  • weightedLength: Integer that indicates the weighted length calculated by the algorithm above.
  • permillage: Integer value corresponding to the ratio of consumed weighted length to the maximum weighted length.
  • valid: Boolean indicating whether it is a valid content (for posts).
  • dispayRangeStart: Integer with start index on the text string
  • displayRangeEnd: Integer with end index on the text string (inclusive)
  • validDisplayRangeStart: Integer indicating the valid start index on the text string
  • validDisplayRangeEnd: Integer indicating the valid end index on the text string. This can be lesser than displayRangeEnd (inclusive).
var content = "This is a test post";
lumen.parseText(content);
/* Returns:
  {
    weightedLength: 20,
    permillage: 71,
    valid: true,
    displayRangeEnd: 19,
    displayRangeStart: 0,
    validRangeEnd: 19,
    validRangeStart: 0
  }
*/