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

rocketidenticon

v0.0.1

Published

hash based rocket identicon genrator

Downloads

111

Readme

🚀 Rocketidenticon

rocketidenticon is an npm package that generates unique, deterministic rocket icons (SVG format) based on a hashed input. Each rocket is made up of different components (nose, body, fins, exhaust) that are selected based on the input string. Perfect for creating unique user avatars, placeholders, or fun visual identifiers!

Features

  • Deterministic Generation: The same input always produces the same rocket icon.
  • Customizable Components: Rockets are made up of multiple parts (nose, body, fins, exhaust) combined in unique ways.
  • SVG Output: Scalable and lightweight images.
  • Lightweight Dependency: Uses Node's built-in crypto module for hashing.

Installation

Install the package via npm:

npm install rocketidenticon

Usage

Basic Example

import { getRocketSVG } from "rocketidenticon";

const input = "exampleUser123";
const rocketSVG = getRocketSVG(input);

console.log(rocketSVG);

Saving the SVG to a File

You can save the generated SVG to a file using Node.js:

import { getRocketSVG } from "rocketidenticon";
import fs from "fs";

const input = "exampleUser123";
const rocketSVG = getRocketSVG(input);

fs.writeFileSync("rocket.svg", rocketSVG);
console.log("Rocket SVG saved as rocket.svg");

API

getRocketSVG(input: string): string

Generates a rocket icon as an SVG string based on the input string.

  • Parameters:
    • input (string): A unique string (e.g., username or email) to generate the rocket.
  • Returns:
    • (string): An SVG representation of the rocket.

Example Output

Here’s an example of a generated SVG:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 200" width="100" height="200">
  <path d="M50 0 L90 50 L10 50 Z" fill="#FF5733" />
  <path d="M20 50 L80 50 L80 150 L20 150 Z" fill="#33C3FF" />
  <path d="M20 150 L50 130 L50 150 Z" fill="#FFC300" />
  <path d="M30 150 C40 180, 60 180, 70 150 Z" fill="#C70039" />
</svg>

How It Works

  1. The input string is hashed using SHA-256.
  2. The hash is split into segments and mapped to indices corresponding to predefined SVG paths for rocket components.
  3. These components are combined into a complete rocket SVG.

File Structure

rocketidenticon/
├── src/
│   ├── index.js         # Main entry point
│   ├── hashUtils.js     # Utility functions for hashing and mapping
│   ├── rocketParts.js   # SVG paths for different rocket components
│   ├── generator.js     # Rocket generation logic
├── examples/
│   ├── demo.js          # Example usage
├── package.json         # Package metadata
├── README.md            # Documentation
├── .gitignore           # Git ignore file
└── LICENSE              # License file

Development

Prerequisites

Ensure you have Node.js installed.

Running the Example

Clone the repository and navigate to the project directory:

git clone https://github.com/xooxaa/rocketicon.git
cd rocketicon

Run the example:

node examples/demo.js

Testing

You can add tests using a framework like Jest or Mocha to ensure the rockets are generated correctly.

Contributing

Contributions are welcome! If you have ideas for new rocket components, color schemes, or features, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

Inspired by deterministic avatar generators like Identicons, this project brings a fun twist with rockets!