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

numerator

v0.2.0

Published

Auto incrementing serial numbers, containing non-digit symbols.

Downloads

7

Readme

numerator

A simple script, that increments serial numbers, containing non-digit symbols

Useful for numbering documents, catalogs, users and etc.

Quickstart

npm install numerator

Then make reference inside yor module...

const numerator = require('numerator');

// ... start numeration from begining with given template
numerator.next('IN/2019/000'); // ⇨ 'IN/2019/001'

// ... or to get next of the given number
numerator.next('IN/2019/056'); // ⇨ 'IN/2019/057'

// ... to get first number with only given prefix
numerator.next('USER-', true); // ⇨ 'USER-1'

// ... or to get next number with expanding template
numerator.next('USER-99', true); // ⇨ 'USER-100'

API

next(num, [expand])

Generates and returns next number based on given number

Arguments

  • num - (string | number) A number, that must be icremented
  • expand - (boolen) optional; true, if we want to expand number template (to increase its lenght) in case, when quantity of digits of the number must be increased; by default it is false

Note: if you pass "USER-99" as num and expand is false, it will throw Error (not returns "USER-100"), so if you need "USER-100", expand mast be true

Returns

string - result of inrementing

getPrefix(num)

Returns the prefix of given number

Arguments

  • num - (string | number) A number, we want to get prefix of

Returns

string - prefix of the number, if the number has it

Note: prefix will be returned without leading zeros, if the number has them

Testing

npm test

License

MIT