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 🙏

© 2025 – Pkg Stats / Ryan Hefner

text-is-upper-case

v1.2.9

Published

Returns `true` if text is upper case only.

Readme

Is Upper Case

NPM version NPM downloads Bundle size License: MIT TypeScript

Check if a string is in UPPERCASE format.

🚀 Features

  • Lightweight - Only ~200B minified + gzipped
  • Type-safe - Full TypeScript support with comprehensive type definitions
  • Zero dependencies - No external dependencies
  • Tree-shakeable - ES modules support
  • Universal - Works in browsers, Node.js, and serverless environments
  • Well-tested - Comprehensive test suite with edge cases

📦 Installation

# npm
npm install text-is-upper-case

# yarn
yarn add text-is-upper-case

# pnpm
pnpm add text-is-upper-case

# bun
bun add text-is-upper-case

🎯 Quick Start

import { isUpperCase } from "text-is-upper-case";

console.log(isUpperCase("HELLO WORLD")); // true
console.log(isUpperCase("Hello World")); // false
console.log(isUpperCase("hello world")); // false

📖 Usage

ES Modules (Recommended)

import { isUpperCase } from "text-is-upper-case";

console.log(isUpperCase("HELLO")); // true

CommonJS

const { isUpperCase } = require("text-is-upper-case");

console.log(isUpperCase("HELLO")); // true

TypeScript

import { isUpperCase } from "text-is-upper-case";

const result: boolean = isUpperCase("HELLO WORLD");
console.log(result); // true

🔄 Validation Examples

Basic Validation

import { isUpperCase } from "text-is-upper-case";

// Valid uppercase
isUpperCase("HELLO"); // true
isUpperCase("HELLO WORLD"); // true
isUpperCase("TEST123"); // true
isUpperCase("USER_NAME"); // true
isUpperCase("API-KEY"); // true

// Invalid (not uppercase)
isUpperCase("Hello"); // false
isUpperCase("hello"); // false
isUpperCase("Hello World"); // false
isUpperCase("camelCase"); // false
isUpperCase("PascalCase"); // false

Edge Cases

import { isUpperCase } from "text-is-upper-case";

// Numbers and symbols
isUpperCase("123"); // true
isUpperCase("HELLO123"); // true
isUpperCase("[email protected]"); // true
isUpperCase("USER_123"); // true

// Empty and whitespace
isUpperCase(""); // true
isUpperCase("   "); // true
isUpperCase("\n\t"); // true

// Special characters
isUpperCase("HELLO-WORLD"); // true
isUpperCase("TEST_CASE"); // true
isUpperCase("FILE.TXT"); // true

🌍 Real-World Examples

Environment Variable Validation

import { isUpperCase } from "text-is-upper-case";

function validateEnvVarName(name) {
  if (!isUpperCase(name)) {
    return "Environment variable names should be uppercase";
  }
  return null;
}

console.log(validateEnvVarName("DATABASE_URL")); // null (valid)
console.log(validateEnvVarName("databaseUrl")); // "Environment variable names should be uppercase"

Constant Validation

import { isUpperCase } from "text-is-upper-case";

function validateConstantName(name) {
  if (!isUpperCase(name)) {
    return "Constants should be uppercase";
  }
  return null;
}

console.log(validateConstantName("MAX_RETRIES")); // null
console.log(validateConstantName("maxRetries")); // "Constants should be uppercase"

HTTP Header Validation

import { isUpperCase } from "text-is-upper-case";

function validateHeaderMethod(method) {
  if (!isUpperCase(method)) {
    return "HTTP methods should be uppercase";
  }
  return null;
}

console.log(validateHeaderMethod("GET")); // null
console.log(validateHeaderMethod("get")); // "HTTP methods should be uppercase"

Configuration Validation

import { isUpperCase } from "text-is-upper-case";

function validateConfigConstants(config) {
  const invalidKeys = Object.keys(config).filter(
    (key) => key.startsWith("CONST_") && !isUpperCase(key),
  );

  if (invalidKeys.length > 0) {
    return `Invalid constant keys (must be uppercase): ${invalidKeys.join(", ")}`;
  }
  return null;
}

const config1 = { CONST_MAX_SIZE: 100, normalKey: "value" };
const config2 = { CONST_max_size: 100, normalKey: "value" };

console.log(validateConfigConstants(config1)); // null
console.log(validateConfigConstants(config2)); // "Invalid constant keys..."

📖 API Reference

isUpperCase(input)

Checks if a string is in uppercase format.

Parameters

  • input (string): The string to check

Returns

  • boolean: true if the string is uppercase, false otherwise

📊 Bundle Size

This package is optimized for minimal bundle size:

  • Minified: ~200B
  • Gzipped: ~150B
  • Tree-shakeable: Yes
  • Side effects: None

🌍 Browser Support

  • Modern browsers: ES2015+ (Chrome 51+, Firefox 54+, Safari 10+)
  • Node.js: 12+
  • TypeScript: 4.0+
  • Bundle formats: UMD, ESM, CommonJS

🧪 Testing

# Run tests
pnpm test

# Run tests in watch mode
pnpm test --watch

# Run tests with coverage
pnpm test --coverage

# Type checking
pnpm typecheck

# Linting
pnpm lint

🔗 Related Packages

📜 License

MIT © Dmitry Selikhov

🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

🆘 Support


Made with ❤️ by Dmitry Selikhov