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

@muski/iptv-shared-types

v1.0.3

Published

Shared TypeScript types, constants, and utilities for IPTV Player

Downloads

7

Readme

IPTV Player - Shared Types

Shared TypeScript types, constants, and utilities for the IPTV Player application. This package provides a single source of truth for data structures and common functionality across web, mobile, and TV client applications.

Features

  • Type Definitions: Comprehensive TypeScript types for all entities
  • Constants: API endpoints, app configuration, and common values
  • Utilities: Validation, formatting, and HTTP client helpers
  • Type Safety: Ensures consistency across all client applications

Installation

npm install @iptv-player/shared-types

Usage

Types

import {
  Content,
  Channel,
  User,
  EPGProgram,
  ContentType,
  UserRole,
  StreamQuality
} from '@iptv-player/shared-types';

const content: Content = {
  id: 1,
  title: 'Sample Movie',
  streamUrl: 'https://example.com/stream',
  type: ContentType.Movie,
  // ...
};

Constants

import {
  API_ENDPOINTS,
  PAGINATION,
  STREAMING_CONFIG
} from '@iptv-player/shared-types';

// Use API endpoints
const contentUrl = `${API_BASE_PATH}${API_ENDPOINTS.CONTENT.BY_ID(123)}`;

// Use pagination defaults
const limit = PAGINATION.DEFAULT_LIMIT;

Utilities

import {
  validateEmail,
  formatDuration,
  formatDate,
  makeRequest,
  buildUrl
} from '@iptv-player/shared-types';

// Validate email
const result = validateEmail('[email protected]');
if (!result.isValid) {
  console.log(result.errors);
}

// Format duration
const formatted = formatDuration(3665); // "01:01:05"

// Format date
const date = formatDate('2025-01-15T12:00:00Z'); // "Jan 15, 2025"

// Make HTTP request
const response = await makeRequest('/api/content', {
  method: 'GET',
  headers: { 'Authorization': 'Bearer token' }
});

Package Structure

shared-types/
├── src/
│   ├── types/
│   │   ├── content.types.ts    # Content and media types
│   │   ├── epg.types.ts        # EPG types
│   │   ├── user.types.ts       # User and auth types
│   │   ├── streaming.types.ts  # Streaming and playback types
│   │   └── index.ts
│   ├── constants/
│   │   ├── api.constants.ts    # API endpoints
│   │   ├── app.constants.ts    # App configuration
│   │   └── index.ts
│   ├── utils/
│   │   ├── validators.ts       # Validation functions
│   │   ├── formatters.ts       # Formatting functions
│   │   ├── http-client.ts      # HTTP helpers
│   │   └── index.ts
│   └── index.ts
├── tests/                      # Unit tests
├── package.json
├── tsconfig.json
└── README.md

Type Categories

Content Types

  • Content - Media content entity
  • Channel - Live TV channel entity
  • ContentType - Content type enum
  • CreateContentDto, UpdateContentDto - DTOs for content operations
  • ContentFilters, PaginatedContentResponse - Search and pagination

EPG Types

  • EPGProgram - Electronic Program Guide entry
  • EPGSchedule - Channel schedule
  • EPGGrid - Multi-channel grid data
  • ChannelSchedule - Current and upcoming programs

User Types

  • User - User entity
  • UserRole - User role enum
  • UserPreference - User preferences
  • ViewingHistory - Viewing history entry
  • AuthResponse - Authentication response
  • DTOs for registration, login, password reset, etc.

Streaming Types

  • StreamQuality - Quality level enum
  • PlaybackState - Playback state enum
  • StreamInfo - Stream information
  • PlayerConfig - Player configuration
  • PlayerState - Player state
  • SubtitleTrack, AudioTrack - Track information

Validation

The package provides comprehensive validation functions:

  • validateEmail(email) - Email validation
  • validateUsername(username) - Username validation
  • validatePassword(password) - Password validation
  • validateUrl(url) - URL validation
  • validateStreamUrl(url) - Stream URL validation
  • validateContentTitle(title) - Content title validation
  • validateRating(rating) - Rating validation
  • validateDateString(date) - Date validation
  • validateTimeRange(start, end) - Time range validation

All validators return a ValidationResult object:

interface ValidationResult {
  isValid: boolean;
  errors: string[];
}

Formatting

Formatting utilities for common display needs:

  • formatDuration(seconds) - Format duration (HH:MM:SS)
  • formatDurationHuman(seconds) - Human-readable duration (1h 30m)
  • formatDate(dateString) - Format date (Jan 15, 2025)
  • formatTime(dateString) - Format time (3:30 PM)
  • formatDateTime(dateString) - Format date and time
  • formatEPGTime(dateString) - EPG time format (15:30)
  • formatRelativeTime(dateString) - Relative time (2 hours ago)
  • formatFileSize(bytes) - File size (1.5 MB)
  • formatBitrate(kbps) - Bitrate (5.2 Mbps)
  • formatPercentage(value) - Percentage (85.5%)
  • truncateText(text, maxLength) - Truncate with ellipsis
  • formatNumber(num) - Number with separators (1,000,000)
  • formatViewerCount(count) - Viewer count (1.5K, 2M)

HTTP Client

HTTP client helpers for API communication:

  • makeRequest(url, options) - Make HTTP request with timeout
  • get(url, params, headers) - GET request
  • post(url, body, headers) - POST request
  • put(url, body, headers) - PUT request
  • patch(url, body, headers) - PATCH request
  • del(url, headers) - DELETE request
  • buildUrl(baseUrl, params) - Build URL with query params
  • createDefaultHeaders(includeAuth, token) - Create default headers
  • retryRequest(requestFn, maxRetries, delayMs) - Retry failed requests

Development

# Install dependencies
npm install

# Build the package
npm run build

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Watch mode
npm run test:watch

Testing

All utilities are thoroughly tested. Run the test suite with:

npm test

Coverage threshold is set to 80% for branches, functions, lines, and statements.

License

MIT