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

@khaosdoctor/codename

v1.0.3

Published

Parsing your semantic version numbers into awesome version names!

Downloads

26

Readme

Codename

JavaScript Style Guide npm version GitHub license Codename Codacy Badge codecov Build Status

Parsing your semantic version numbers into awesome version names!

Summary

What is it?

This is a fun project to transform your boring Semantic Version numbers like 1.2.3 into awesome badass codenames.

This means you can give your project version an alias so you can call it by name, for instance, let's give Pokémon™ names to our versions. So 1.2.3 would be turned into the pokédex number:

  • major is 1, which translates to Bulbasaur
  • minor is 2, which translates to Ivysaur
  • patch is 3, which translates to Venusaur

Your full project codename would be: V1.2.3 - Bulbasaur (or V Bulbasaur.Ivysaur.Venusaur but this is not pretty).

Usage

First, install the package by issuing:

npm i @khaosdoctor/codename --save

Or, if you like yarn:

yarn add @khaosdoctor/codename

Then, in your project require it as const codename = require('@khaosdoctor/codename')

Parsers

Codename uses parsers to parse your version name. A parser is a simple object that follows the structure:

module.exports = {
  major: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ],
  minor: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ],
  patch: [
    'codename0',
    'codename1',
    'codename2',
    'codename3',
    'codename4',
    ...
  ]
}

Or also:

module.exports = {
  major: {
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    'majorNumber': 'name',
    ...
  },
  minor: {
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    'minorNumber': 'name',
    ...
  },
  patch: {
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    'patchNumber': 'name',
    ...
  }
}

Note: If one of the indexes (major, minor or patch) is omitted, the original version number will be used

Another note: Using arrays will start the count on index 0 (as every array), if you wish to specify version numbers for specific names, use objects instead

After that you can simply instantiate with a parser and have fun!

Let's use Pokémon™ again:

const codename = require('khaosdoctor/codename')(yourParser) // This is a Pokémon™ parser
const myVersion = require('./package.json').version // 1.2.3

console.log(codename.parse(myVersion).major) // Would output 'Bulbasaur'

console.log(codename.parse(myVersion).minor) // Would output 'Ivysaur'

console.log(codename.parse(myVersion).patch) // Would output 'Venusaur'

console.log(codename.parse(myVersion).codename) // Would output 'Bulbasaur.Ivysaur.Venusaur'

console.log(codename.parse(myVersion).codenameText) // Would output 'V1.2.3 - Bulbasaur'

That's it.

Some examples and parsers

  • codename-zodiac: Outputs Zodiac Signs for each version number (starting on 1, major only)
  • codename-greek: Outputs greek letters for version numbers
  • codename-greek-gods: Outputs greek god names for major version numbers, demigod names for minor version numbers and hero names for patches (start on 1)
  • codename-titans: Outputs greek titan names for version numbers (start on 1, major only)
  • codename-nordic: Outputs nordic gods names for version numbers (starting on 1, major only)
  • codename-zodiac-warriors: Outputs zodiac warriors names for version numbers (starting on 1, major only)
  • codename-universe: Outputs star names for major version numbers (start on 0), constellation names for minor numbers and moon names for patch numbers

Add yours here by submiting a PR! :smile: