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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vibe-iseven

v1.0.1

Published

Determines if a number is even using OpenAI API - because why not add some AI magic to basic math!

Readme

🔮 vibe-iseven

Determines if a number is even using OpenAI API.

📖 Usage

Basic Usage

import { vibeIsEven } from 'vibe-iseven';

// Simple check
const result = await vibeIsEven(42);
console.log(result);
// {
//   number: 42,
//   isEven: true,
//   confidence: 0.95,
//   reasoning: "The number 42 divides perfectly by 2, leaving no remainder"
// }

Class Instance with Options

import VibeIsEven from 'vibe-iseven';

const checker = new VibeIsEven({
  apiKey: 'your-api-key',  // Optional if using env var
  model: 'gpt-4',          // Optional, defaults to 'gpt-3.5-turbo'
  temperature: 0.8         // Optional, defaults to 0.7
});

const result = await checker.checkIsEven(13);
console.log(result);
// {
//   number: 13,
//   isEven: false,
//   confidence: 0.99,
//   reasoning: "13 divided by 2 gives 6.5, indicating an odd number"
// }

Batch Processing

const checker = new VibeIsEven();
const numbers = [2, 3, 4, 5, 6];
const results = await checker.checkMultiple(numbers);

results.forEach(result => {
  console.log(`${result.number}: ${result.isEven ? 'Even' : 'Odd'} (${result.confidence * 100}% confident)`);
});

Error Handling

try {
  const result = await vibeIsEven(3.14);
} catch (error) {
  console.error(error.message); // "Input must be an integer"
}

try {
  const checker = new VibeIsEven(); // No API key provided
} catch (error) {
  console.error(error.message); // "OpenAI API key is required..."
}

✨ Features

  • 🤖 AI-Powered: Uses OpenAI's GPT models to determine if numbers are even
  • 🧠 AI Reasoning: Get detailed explanations for the mathematical determination
  • 📊 Confidence Scoring: AI provides confidence levels for its mathematical intuition
  • 🛡️ Fallback Logic: Mathematical backup in case the AI gets too creative
  • 🚀 TypeScript: Full type safety and IntelliSense support
  • Batch Processing: Check multiple numbers at once

🚀 Installation

npm install vibe-iseven

🔑 Setup

You'll need an OpenAI API key. Get one from OpenAI's website.

Set your API key as an environment variable:

export OPENAI_API_KEY="your-api-key-here"

Or pass it directly when creating the instance (see usage examples below).

🔧 API Reference

vibeIsEven(number, options?)

Convenience function for one-off checks.

Parameters:

  • number: number - The integer to check
  • options?: VibeIsEvenOptions - Optional configuration

Returns: Promise<VibeIsEvenResult>

new VibeIsEven(options?)

Create a reusable instance.

Options:

  • apiKey?: string - OpenAI API key (defaults to OPENAI_API_KEY env var)
  • model?: string - OpenAI model to use (defaults to 'gpt-3.5-turbo')
  • temperature?: number - AI creativity level 0-1 (defaults to 0.7)

checker.checkIsEven(number)

Check if a single number is even.

Parameters:

  • number: number - The integer to check

Returns: Promise<VibeIsEvenResult>

checker.checkMultiple(numbers)

Check multiple numbers at once.

Parameters:

  • numbers: number[] - Array of integers to check

Returns: Promise<VibeIsEvenResult[]>

📊 Response Format

interface VibeIsEvenResult {
  number: number;        // The input number
  isEven: boolean;       // true if even, false if odd
  confidence: number;    // AI confidence level (0-1)
  reasoning: string;     // AI's mathematical explanation
}

🎯 Why This Exists

This package is a playful exploration of combining AI with simple mathematical operations. While checking if a number is even is trivial (number % 2 === 0), sometimes you want to add AI reasoning and confidence scoring to your mathematical operations.

Perfect for:

  • 🎮 Fun side projects
  • 🎨 Creative coding experiments
  • 🧪 Testing AI integration patterns
  • 🤖 Adding AI explanations to mathematical operations
  • 🎪 Demonstrating API integration in workshops

🔒 Security & Privacy

  • API keys are never logged or stored
  • Only the number being checked is sent to OpenAI
  • No personal data is transmitted
  • Fallback mathematical calculation if AI fails

📝 License

MIT - Feel free to use this in your projects!

🤝 Contributing

Found a bug or have a feature idea? Open an issue or submit a PR!

🙏 Credits

  • OpenAI for making AI accessible
  • The mathematical concept of even numbers (ancient mathematicians)
  • You, for exploring AI-powered mathematical operations

Remember: With great power comes great responsibility. Use your AI-powered even number detection wisely.