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

fs-gjs

v1.0.1

Published

Collection of file system utility functions for Gnome JavaScript (GJS).

Readme

fs-gjs

Collection of file system utility functions for Gnome JavaScript (GJS).

Usage

fs-gjs provides two sets of functions, synchronous and asynchronous. First can be accessed vias SyncFs class and the latter via Fs class. Both have almost exactly the same API, with the only difference that asynchronous functions need to be awaited.

  1. Reading files
  2. Writing files
  3. Appending to files
  4. Copying files
  5. Moving files
  6. Deleting files
  7. Creating directories
  8. Create symbolic links
  9. Change file permissions
  10. Change file ownership
  11. List directory contents
  12. Check if file exists
  13. Get file info
  14. IOStreams

Reading files

import { Fs } from "./node_modules/fs-gjs/index.js";

// Read file as bytes
const bytes = await Fs.readFile("/path/to/file");

// Read file as text
const text = await Fs.readTextFile("/path/to/file");

Writing files

import { Fs } from "./node_modules/fs-gjs/index.js";

// Write bytes to file
const bytes = new Uint8Array([1, 2, 3]);
await Fs.writeFile("/path/to/file", bytes);

// Write text to file
const text = "Hello, world!";
await Fs.writeTextFile("/path/to/file", text);

Appending to files

import { Fs } from "./node_modules/fs-gjs/index.js";

// Append bytes to file
const bytes = new Uint8Array([1, 2, 3]);
await Fs.appendFile("/path/to/file", bytes);

// Append text to file
const text = "Hello, world!";
await Fs.appendTextFile("/path/to/file", text);

Copying files

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.copyFile("/path/to/source", "/path/to/destination");

Moving files

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.moveFile("/path/to/source", "/path/to/destination");

Deleting files

import { Fs } from "./node_modules/fs-gjs/index.js";

// Permanently delete file
await Fs.deleteFile("/path/to/file");

// Move file to trash
await Fs.deleteFile("/path/to/file", { trash: true });

Creating directories

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.makeDir("/path/to/directory");

Create symbolic links

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.makeLink("/path/to/link", "/path/to/target");

Change file permissions

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.chmod("/path/to/file", 0o755);
// or
await Fs.chmod("/path/to/file", "rwxr-xr-x");
// or
await Fs.chmod("/path/to/file", {
  owner: { read: true, write: true, execute: true },
  group: { read: true, write: false, execute: true },
  others: { read: true, write: false, execute: true },
});

Change file ownership

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.chown("/path/to/file", /* uid */ 1000, /* gid */ 1000);

List directory contents

import { Fs } from "./node_modules/fs-gjs/index.js";

// get array of FileInfo objects
await Fs.listDir("/path/to/directory");

// get array of file names
await Fs.listFilenames("/path/to/directory");

Check if file exists

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.fileExists("/path/to/file");

Get file info

import { Fs } from "./node_modules/fs-gjs/index.js";

await Fs.fileInfo("/path/to/file");

IOStreams

IOStreams can be opened in one of three modes:

  • CREATE - a new file will be created, will fail if file already exists
  • REPLACE - a new file will be created, will replace existing file if it exists
  • OPEN - an existing file will be opened, will fail if file does not exist
import { Fs } from "./node_modules/fs-gjs/index.js";

const stream = await Fs.openIOStream("/path/to/file", "CREATE");

// Read the first 1024 bytes from stream
const bytes = await stream.read(1024);

// Read all the remaining bytes from stream
const bytes = await stream.readAll();

// Write bytes to stream
const bytes = new Uint8Array([1, 2, 3]);
await stream.write(bytes);

// Skip 1024 bytes from the stream
await stream.skip(1024);

// Move cursor position by 1024 bytes forward
await stream.seek(1024);

// Move cursor to 1024 from the stream start
await stream.seekFromStart(1024);

// Move cursor to 1024 from the stream end
await stream.seekFromEnd(1024);

// Truncate the stream to the length of 1024 bytes
await stream.truncate(1024);

// Get current cursor position
const position = await stream.currentPosition();

// Close the stream
await stream.close();