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

losetup

v0.1.0

Published

losetup -------

Downloads

21

Readme

losetup

npm version dependencies

Losetup library for node.js.

Allows attaching, detaching, and listing loop devices in a Linux system.

Installation

$ npm install losetup

Documentation

losetup.LoopDevice(path, isUsed, device, inode, fileName)

Class describing a loop device.

Properties:

  • path: String
  • isUsed: Boolean
  • device: Integer
  • inode: Integer
  • fileName: String
  • offset: Integer

losetup.errors

Contains all the exported error classes:

  • LosetupError: All errors inherit from this class.
  • NotLoopDeviceError: The device is not a loop device.
  • LoopDeviceBusyError: The device is busy (already attached).
  • LoopDeviceNotUsedError: The device was expected to be attached, but isn't.
  • LoopDeviceNotFoundError: The device does not exist at all.

losetup.isLoopDevice(String path) => Promise Boolean

Promise resolves to true if path is a loop device.

losetup.getLoopDevice(String path) => Promise LoopDevice

Resolves to a LoopDevice describing the device in path.

losetup.listAll(String path = "/dev") => Promise [LoopDevice]

Resolves to a list of LoopDevice for all the loop devices in path.

losetup.listUsed(String path = "/dev") => Promise [LoopDevice]

List all the loop devices in path that are currently attached to a file.

losetup.findUnused(String path = "/dev") => Promise LoopDevice

Finds the first loop device in path that is currently not used.

losetup.attach(LoopDevice dev, String path, Object opts = {}) => Promise LoopDevice

Attaches the loop device dev to the file in path.

Result promise resolves to an updated loop device description. Does not alter the input object.

The third argument defines additional options:

  • partscan: Enable partition scanning on device. Boolean, defaults to false.
  • offset: Attach to an offset in the file, in bytes. Number, defaults to 0.

losetup.detach(LoopDevice dev) => Promise LoopDevice

Detaches any files from loop device dev.

Result promise resolves to an updated loop device description. Does not alter the input object.

losetup.reloadPartitionTable(LoopDevice dev) => Promise

Forces the operating system to reload partition table for device.

Uses BLKRRPART ioctl command.

If device /dev/loopX is a disk with many partitions, then after calling this function, the operating system will create /dev/loopXpY for each partition of the disk.

To make sure the operating system will scan the partition table, attach the device with partscan option enabled.

Support

If you're having any problem, please raise an issue on GitHub.

Contribute

License

The project is licensed under the Apache License 2.0.