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

is-valid-package-name

v1.0.0

Published

Validation for package name

Downloads

8

Readme

test GitHub release deno land nest badge deno doc deno version node support version npm download

GitHub (Pre-)Release Date dependencies Status codecov Codacy Badge npm type definitions Commitizen friendly Gitmoji semantic-release License: MIT


A validator collection of package names for each package registry

:sparkles: Features

  • :zap: Multi runtime support (Deno, Node.js)
  • :books: Pure TypeScript and provides type definition
  • :package: Optimized, super slim size
  • :page_facing_up: TSDoc-style comments

Currently providing validators for the following package registries: Check each for detailed validation rules.

:zap: Overview

isValid*

The isValid* function returns a boolean if the package name is valid as a package.

isValidNpm('is-valid-package-name') // true
isValidNpm('node_modules') // false

isValidDenoLand('is_valid') // true
isValidDenoLand('is-valid') // false

isValidNestLand('oak') // true
isValidNestLand('o') // false

validate*

The validate* function returns tuple of boolean and error message.

validateNpm('is-valid-package-name') // [ true, "" ]
validateNpm('node_modules') // [ false, "Name is blacklisted" ]

validateDenoLand('is_valid') // [ true, "" ]
validateDenoLand('is-valid') // [ false, "Name contains only the characters a-z, 0-9 and _" ]

validateNestLand('oak') // [ true, "" ]
validateNestLand('o') // [ false, "Name length must be greater than 1" ]

:dizzy: Usage

is-valid-package-name provides multi platform modules.

🦕 Deno

deno.land

import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://deno.land/x/is_valid_package_name/mod.ts";

nest.land

import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://x.nest.land/is_valid_package_name/mod.ts";

:package: Node.js

Install

npm i is-valid-package-name
or
yarn add is-valid-package-name

ES modules

import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "is-valid-package-name";

Commonjs

const { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } = require("is-valid-package-name");

:globe_with_meridians: Browser

The module that bundles the dependencies is obtained from skypack.

<script type="module">
  import { isValidNpm ,validateNpm, isValidDenoLand, validateDenoLand, isValidNestLand, validateNestLand } from "https://cdn.skypack.dev/is-valid-package-name";
</script>

:green_heart: Support

ie is no longer supported to reduce bundle size.

The TypeScript version must be 4.1.0 or higher.

This project provides ES modules and Commonjs.

If you have an opinion about what to support, you can open an issue to discuss it.

The browserslist has the following settings.

defaults
last 8 version
not IE <= 11
not ie_mob <= 11
node 6

| Deno | Node.js | Edge | Firefox | Chrome | Safari | iOS Safari | Samsung | Opera | | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | ^1.6.0 | ^6.17.0 | ^83 | ^78 | ^83 | ^11 | ^12.0 | ^7.2 | ^68 |

:handshake: Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues.

:seedling: Show your support

Give a ⭐️ if this project helped you!

:bulb: License

Copyright © 2021-present TomokiMiyauci.

Released under the MIT license