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

next-typro

v1.0.1

Published

A TypeScript library for custom types and validators

Downloads

6

Readme

next-typro

next-typro is a TypeScript library providing custom types and validators for common data formats, such as email addresses, URLs, and more. It helps ensure data conforms to specific formats and enhances code readability and type safety.

Features

  • Custom TypeScript types for email, URL, UUID, and more
  • Validators for runtime format checking
  • Easy to integrate into any TypeScript project

Installation

To install the library, use npm or yarn:

npm install next-typro

or

yarn add next-typro

Usage

Importing Types and Validators

You can import both types and validators from the package:

import { Email, URL, UUID, HexColor } from "next-typro";
import { isEmail, isURL, isUUID, isHexColor } from "next-typro";

Examples

Email

const email: Email = "[email protected]";

if (isEmail(email)) {
  console.log("Valid email:", email);
} else {
  console.log("Invalid email:", email);
}

URL

const url: URL = "https://example.com";

if (isURL(url)) {
  console.log("Valid URL:", url);
} else {
  console.log("Invalid URL:", url);
}

UUID

const uuid: UUID = "123e4567-e89b-12d3-a456-426614174000";

if (isUUID(uuid)) {
  console.log("Valid UUID:", uuid);
} else {
  console.log("Invalid UUID:", uuid);
}

Hex Color

const hexColor: HexColor = "#ff5733";

if (isHexColor(hexColor)) {
  console.log("Valid Hex Color:", hexColor);
} else {
  console.log("Invalid Hex Color:", hexColor);
}

Example Supported Types

  • Email: Validates email addresses.
  • URL: Validates URLs.
  • UUID: Validates UUIDs.
  • HexColor: Validates hexadecimal color codes.
  • CreditCard: Validates credit card numbers.
  • PostalCode: Validates postal codes.
  • Latitude and Longitude: Validates geographical coordinates.
  • Markdown: Basic validation for Markdown content.
  • DateTime and RFC3339DateTime: Validates date-time formats.
  • Base64: Validates Base64 encoded strings.
  • TwitterHandle: Validates Twitter handles.
  • FileExtension: Validates file extensions.
  • ISO8601Duration: Validates ISO 8601 duration format.
  • Slug: Validates URL slugs.
  • HTML: Basic validation for HTML content.
  • GeoJSON: Basic validation for GeoJSON format.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub. Follow the guidelines in CONTRIBUTING.md for more details.

License

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

Acknowledgments

  • Inspired by various TypeScript libraries and custom type validation practices.
  • Thanks to the open-source community for their contributions and support.

Contact

For any questions or feedback, please contact PhumudzoSly.