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

operator-checker

v1.0.4

Published

Iranian mobile operator detection package for Vue 3 and TypeScript

Readme

Operator Checker - تشخیص اپراتور موبایل ایران

A TypeScript package for detecting Iranian mobile operators (Irancell, Hamrah-e-Aval, and RighTel) based on phone number prefixes. Perfect for Vue 3 Composition API projects.

Features

  • 🎯 Accurate Detection: Detects operators based on the first 4 digits of phone numbers
  • 🚀 Vue 3 Ready: Built-in Composition API support
  • 📱 TypeScript: Full TypeScript support with type definitions
  • 🔧 Flexible: Can be used in any JavaScript/TypeScript project
  • 🌐 Bilingual: Persian and English operator names
  • Validation: Built-in Iranian mobile number validation

Supported Operators

| Code | Operator | Persian Name | Prefixes | | ---- | ------------- | ------------ | ---------------------------------------- | | 0 | Irancell | ایرانسل | 0930, 0933, 0935, 0936, 0937, 0938, 0939 | | 1 | Hamrah-e-Aval | همراه اول | 0910-0919, 0990-0994 | | 2 | RighTel | رایتل | 0920, 0921, 0922 |

Installation

npm install operator-checker

Usage

Basic Usage

import { detectOperator } from 'operator-checker'

// Detect operator
const operator = detectOperator('09123456789')
console.log(operator) // 1 (Hamrah-e-Aval)

// Get operator name in Persian
import { getOperatorNameFa } from 'operator-checker'
const name = getOperatorNameFa('09351234567')
console.log(name) // "ایرانسل"

// Get operator name in English
import { getOperatorName } from 'operator-checker'
const nameEn = getOperatorName('09201234567')
console.log(nameEn) // "RighTel"

Vue 3 Composition API

<template>
  <div>
    <input v-model="phoneNumber" placeholder="شماره موبایل" />
    <div v-if="operator !== null">اپراتور: {{ operatorNameFa }} ({{ operator }})</div>
  </div>
</template>

<script setup lang="ts">
import { useOperatorChecker } from 'operator-checker'

const { phoneNumber, operator, operatorNameFa, checkOperator } = useOperatorChecker()

// Auto-check when phone number changes
watch(phoneNumber, (newValue) => {
  if (newValue) {
    checkOperator(newValue)
  }
})
</script>

Advanced Usage

import {
  detectOperator,
  getOperatorInfo,
  isValidIranianMobileNumber,
  Operator,
} from 'operator-checker'

// Get detailed operator information
const info = getOperatorInfo('09123456789')
console.log(info)
// {
//   code: 1,
//   name: 'Hamrah-e-Aval',
//   nameFa: 'همراه اول',
//   prefixes: ['0910', '0911', ...]
// }

// Validate phone number format
const isValid = isValidIranianMobileNumber('09123456789')
console.log(isValid) // true

// Use operator constants
if (detectOperator('09351234567') === Operator.IRANCELL) {
  console.log('This is an Irancell number')
}

API Reference

Functions

detectOperator(phoneNumber: string): Operator | null

Detects the mobile operator based on the phone number prefix.

Parameters:

  • phoneNumber (string): The phone number to check

Returns:

  • Operator enum value (0: Irancell, 1: Hamrah-e-Aval, 2: RighTel) or null if not found

getOperatorInfo(phoneNumber: string): OperatorInfo | null

Gets detailed operator information.

Returns:

interface OperatorInfo {
  code: Operator
  name: string
  nameFa: string
  prefixes: string[]
}

getOperatorName(phoneNumber: string): string | null

Gets the operator name in English.

getOperatorNameFa(phoneNumber: string): string | null

Gets the operator name in Persian.

isValidIranianMobileNumber(phoneNumber: string): boolean

Validates if the phone number is a valid Iranian mobile number.

Vue Composable

useOperatorChecker(options?: UseOperatorCheckerOptions)

Options:

interface UseOperatorCheckerOptions {
  autoValidate?: boolean // Default: true
  showDetails?: boolean // Default: false
}

Returns:

{
  // Reactive state
  phoneNumber: Ref<string>;
  operator: Ref<Operator | null>;
  operatorInfo: Ref<OperatorInfo | null>;
  operatorName: Ref<string | null>;
  operatorNameFa: Ref<string | null>;
  isValid: Ref<boolean>;
  isLoading: Ref<boolean>;
  error: Ref<string | null>;

  // Computed
  operatorCode: ComputedRef<Operator | null>;
  operatorDetails: ComputedRef<{...}>;

  // Methods
  checkOperator: (number: string) => void;
  reset: () => void;
  validateNumber: (number: string) => boolean;

  // Constants
  Operator: typeof Operator;
}

Enums

Operator

enum Operator {
  IRANCELL = 0, // ایرانسل
  HAMRAH_E_AVAL = 1, // همراه اول
  RIGHTEL = 2, // رایتل
}

Examples

React/Next.js

import { detectOperator } from 'operator-checker';

function PhoneInput() {
  const [phoneNumber, setPhoneNumber] = useState('');
  const [operator, setOperator] = useState(null);

  const handleChange = (e) => {
    const number = e.target.value;
    setPhoneNumber(number);
    setOperator(detectOperator(number));
  };

  return (
    <div>
      <input value={phoneNumber} onChange={handleChange} />
      {operator !== null && <p>Operator: {operator}</p>}
    </div>
  );
}

Node.js

const { detectOperator, getOperatorNameFa } = require('operator-checker')

const operator = detectOperator('09123456789')
const name = getOperatorNameFa('09123456789')

console.log(`Operator: ${operator}, Name: ${name}`)

Development

Setup

git clone https://github.com/yourusername/operator-checker.git
cd operator-checker
npm install

Build

npm run build

Development Server

npm run dev

Type Checking

npm run type-check

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

License

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

Support

If you have any questions or need help, please open an issue on GitHub.


نکته: این پکیج برای تشخیص اپراتورهای موبایل ایران طراحی شده است و با شماره‌های سایر کشورها کار نمی‌کند.