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

disk-scheduler

v1.0.0

Published

A comprehensive npm package implementing all basic OS disk scheduling algorithms including FCFS, SSTF, SCAN, C-SCAN, LOOK, and C-LOOK

Readme

Disk Scheduler

A comprehensive npm package implementing all basic OS disk scheduling algorithms for educational and practical purposes.

🚀 Features

This package provides implementations of the following disk scheduling algorithms:

  • FCFS (First Come First Serve) - Processes requests in the order they arrive
  • SSTF (Shortest Seek Time First) - Selects the request with minimum seek time
  • SCAN - Moves the disk arm in one direction until it reaches the end, then reverses
  • C-SCAN - Circular SCAN that returns to the beginning after reaching the end
  • LOOK - Similar to SCAN but stops at the last request in each direction
  • C-LOOK - Circular LOOK that returns to the first request after reaching the last

📦 Installation

npm install disk-scheduler

🎯 Usage

Basic Usage

import { 
  fcfs, 
  sstf, 
  scan, 
  cscan, 
  look, 
  clook,
  DiskScheduler,
  SchedulingResult 
} from 'disk-scheduler';

// Create a disk scheduler instance
const scheduler = new DiskScheduler();

// Example: FCFS scheduling
const requests = [98, 183, 37, 122, 14, 124, 65, 67];
const initialHead = 53;
const totalCylinders = 200;

const result: SchedulingResult = scheduler.fcfs(requests, initialHead, totalCylinders);

console.log(`Total head movements: ${result.totalHeadMovements}`);
console.log(`Seek sequence: ${result.seekSequence.join(' -> ')}`);
console.log(`Average seek time: ${result.averageSeekTime}`);

All Algorithms

// FCFS - First Come First Serve
const fcfsResult = scheduler.fcfs(requests, initialHead, totalCylinders);

// SSTF - Shortest Seek Time First
const sstfResult = scheduler.sstf(requests, initialHead, totalCylinders);

// SCAN - with direction
const scanLeftResult = scheduler.scan(requests, initialHead, totalCylinders, 'left');
const scanRightResult = scheduler.scan(requests, initialHead, totalCylinders, 'right');

// C-SCAN - Circular SCAN
const cscanResult = scheduler.cscan(requests, initialHead, totalCylinders, 'right');

// LOOK - optimized SCAN
const lookResult = scheduler.look(requests, initialHead, totalCylinders, 'left');

// C-LOOK - Circular LOOK
const clookResult = scheduler.clook(requests, initialHead, totalCylinders, 'right');

Using Individual Functions

// You can also use individual algorithm functions directly
import { fcfs, sstf, scan, cscan, look, clook } from 'disk-scheduler';

const result = fcfs(requests, initialHead);
const scanResult = scan(requests, initialHead, totalCylinders, 'left');

📊 Algorithm Comparison

| Algorithm | Advantages | Disadvantages | Best Use Case | |-----------|------------|---------------|---------------| | FCFS | Simple, fair | High seek time | When simplicity is preferred | | SSTF | Lower average seek time | Starvation possible | Interactive systems | | SCAN | No starvation, good performance | Uneven wait times | General purpose | | C-SCAN | More uniform wait times | Higher seek time than SCAN | Real-time systems | | LOOK | Better than SCAN | Similar to SCAN | Modern systems | | C-LOOK | Best uniform wait times | Complex implementation | High-performance systems |

📁 Examples

Check out the comprehensive examples in the examples/ directory:

  • basic-usage.js - Complete usage examples for all algorithms
  • performance-benchmark.js - Performance testing and comparison suite
  • typescript-example.ts - TypeScript usage with full type safety
  • README.md - Detailed examples documentation
# Run basic examples
node examples/basic-usage.js

# Run performance benchmarks
node examples/performance-benchmark.js

# Compile and run TypeScript example
npx tsc examples/typescript-example.ts --target es2020 --module commonjs
node examples/typescript-example.js

🧪 Testing

npm test

📈 Performance Metrics

Each algorithm returns a SchedulingResult object containing:

  • totalHeadMovements: Total number of cylinder movements
  • seekSequence: Array showing the order of cylinder access
  • averageSeekTime: Average time per seek operation
  • algorithm: Name of the algorithm used

🔧 Development

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Run tests
npm test

📚 Educational Value

This package is designed for:

  • Students learning operating systems concepts
  • Developers implementing disk management systems
  • Researchers comparing algorithm performance
  • Educators demonstrating scheduling concepts

Learning Path

  1. Start with examples/basic-usage.js - Understand basic algorithm differences
  2. Run examples/performance-benchmark.js - See performance characteristics
  3. Study examples/typescript-example.ts - Learn proper TypeScript integration
  4. Experiment with different workloads - Modify examples with your own data

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.

📄 License

MIT License - see LICENSE file for details.

🗓️ Development Progress

This package is being developed over a 7-day period with daily commits. See PROGRESS.md for detailed development timeline and milestones.