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

@slimio/windrive

v1.5.0

Published

Windows Drive (disk) & Devices low level binding

Readme

Windrive

Maintenance MIT V1.0

SlimIO Windrive is a NodeJS binding which expose low-level Microsoft APIs on Logical Drive, Disk and Devices.

This binding expose the following methods/struct:

!!! All method are called asynchronously without blocking the libuv event-loop !!!

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/windrive
# or
$ yarn add @slimio/windrive

Usage example

Get all active logical drives and retrieve disk performance for each of them!

const windrive = require("@slimio/windrive");

async function main() {
    const logicalDrives = await windrive.getLogicalDrives();

    for (const drive of logicalDrives) {
        console.log(`drive name: ${drive.name}`);
        const diskPerformance = await windrive.getDevicePerformance(drive.name);
        console.log(diskPerformance);
    }
}
main().catch(console.error);

API

getLogicalDrives(): Promise< LogicalDrive[] >

Retrieves the currently available disk drives. An array of LogicalDrive is returned.

type LogicalDriveType = "UNKNOWN" | "NO_ROOT_DIR" | "REMOVABLE" | "FIXED" | "REMOTE" | "CDROM" | "RAMDISK";

export interface LogicalDrive {
    name: string;
    type: LogicalDriveType;
    bytesPerSect?: number;
    freeClusters?: number;
    totalClusters?: number;
    usedClusterPourcent?: number;
    freeClusterPourcent?: number;
}

Possible drive types are:

| type | description | | --- | --- | | UNKNOWN | The drive type cannot be determined. | | NO_ROOT_DIR | The root path is invalid; for example, there is no volume mounted at the specified path. | | REMOVABLE | The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader. | | FIXED | The drive has fixed media; for example, a hard disk drive or flash drive. | | REMOTE | The drive is a remote (network) drive. | | CDROM | The drive is a CD-ROM drive. | | RAMDISK | The drive is a RAM disk. |

CDROM Type have no FreeSpaces (only name and type are returned).

getDosDevices(): Promise< DosDevices >

Retrieves information about MS-DOS device names. Return an key -> value Object where the key is the device name and value the path to the device.

interface DosDevices {
    [name: string]: string;
}

For example, you can filter the result to retrieves Logical and Physical Drives information & performance:

const isDisk = /^[A-Za-z]{1}:{1}$/;
const isPhysicalDrive = /^PhysicalDrive[0-9]+$/;
function isLogicalOrPhysicalDrive(driveNameStr) {
    return isDisk.test(driveNameStr) || isPhysicalDrive.test(driveNameStr) ? true : false;
}

async function main() {
    const dosDevices = await windrive.getDosDevices();
    const physicalAndLogicalDriveDevices = Object.keys(dosDevices).filter(isLogicalOrPhysicalDrive);
    const allDrivePerformance = await Promise.all(
        physicalAndLogicalDriveDevices.map(dev => windrive.getDevicePerformance(dev))
    );
    console.log(allDrivePerformance);
}
main().catch(console.error);

getDevicePerformance(deviceName: string): Promise< DevicePerformance >

Provides disk performance information about a given device (drive). Return a DevicePerformance Object.

interface DevicePerformance {
    bytesRead: number;
    bytesWritten: number;
    readTime: number;
    writeTime: number;
    idleTime: number;
    readCount: number;
    writeCount: number;
    queueDepth: number;
    splitCount: number;
    queryTime: number;
    storageDeviceNumber: number;
    storageManagerName: string;
}

getDiskCacheInformation(deviceName: string): Promise< DiskCacheInformation >

Provides information about the disk cache. Return a DiskCacheInformation Object.

The result of the property prefetchScalar define which of scalarPrefetch (true) or blockPrefect (false) should be filled/completed.

interface DiskCacheInformation {
    parametersSavable: boolean;
    readCacheEnabled: boolean;
    writeCacheEnabled: boolean;
    prefetchScalar: boolean;
    readRetentionPriority: "EqualPriority" | "KeepPrefetchedData" | "KeepReadData";
    writeRetentionPriority: number;
    disablePrefetchTransferLength: number;
    scalarPrefetch?: {
        minimum: number;
        maximum: number;
        maximumBlocks: number;
    };
    blockPrefetch?: {
        minimum: number;
        maximum: number;
    };
}

getDeviceGeometry(deviceName: string): Promise< DeviceGeometry >

Describes the geometry of disk devices and media. Return a DeviceGeometry Object.

interface DeviceGeometry {
    diskSize: number;
    mediaType: number;
    cylinders: number;
    bytesPerSector: number;
    sectorsPerTrack: number;
    tracksPerCylinder: number;
    partition: {
        diskId: string;
        size: number;
        style: "MBR" | "GPT" | "RAW";
        mbr: {
            signature: number;
            checksum: number;
        }
    };
    detection: {
        size: number;
        type: "ExInt13" | "Int13" | "None";
        int13?: {
            driveSelect: number;
            maxCylinders: number;
            sectorsPerTrack: number;
            maxHeads: number;
            numberDrives: number;
        };
        exInt13?: {
            bufferSize: number;
            flags: number;
            cylinders: number;
            heads: number;
            sectorsPerTrack: number;
            sectorsPerDrive: number;
            sectorSize: number;
            reserved: number;
        };
    }
}

Media type enumeration can be retrieved here.

How to build the project

Before building the project, be sure to get the following npm package installed:

Then, just run normal npm install command:

$ npm install

Available commands

All projects commands are described here:

| command | description | | --- | --- | | npm run prebuild | Generate addon prebuild | | npm run doc | Generate JSDoc .HTML documentation (in the /docs root directory) | | npm run coverage | Generate coverage of tests | | npm run report | Generate .HTML report of tests coverage |

the report command have to be triggered after the coverage command.