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 🙏

© 2024 – Pkg Stats / Ryan Hefner

dom-filesystem

v1.0.8

Published

Use the DOM as filesystem, you give you access to Node.js fs API such as: fs.readFileSync, fs.watch etc.

Downloads

5

Readme

Dom Filesystem

Use the Node.js filesystem API inside the browser, but not storing it inside LocalStorage, it stores it inside the DOM.

So if you press ctrl+s and save the .html file, the changes will persist in the file, so you can create HTML quines with this library without chancing the way you use your Node.js app, but simply changing libraries.

I made this mostly for making Digital Gardens On: https://github.com/ilse-langnar/notebook and other projects where a quine is desirable.

How to use

const fs = require("dom-filesystem")(document)

// Sync
fs.writeFileSync( "/hello-world.txt", "Hello, World" )

let hello_world = fs.readFileSync( "/hello-world.txt" )
console.log( "hello_world -> ", hello_world )

// Async
fs.writeFile( "/hello-world.txt", "Hello, World", err => {
    if( err ) throw new Error( `Could not write file. ${err}` )
    let hello_world = fs.readFile( "/hello-world.txt", ( err2, data ) => {
        if( err2 ) throw new Error( `Could not read file: ${err2}` )
        console.log( "data -> ", data )
    })
})

TODO

  • [ ] fs.rename(oldPath, newPath, callback); // Asynchronous rename. No arguments other than a possible exception are given to the completion callback.Asynchronous ftruncate. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.renameSync(oldPath, newPath); // Synchronous rename.

  • [ ] fs.ftruncate(fd, len, callback); // Asynchronous ftruncate. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.ftruncateSync(fd, len); // Synchronous ftruncate.

  • [ ] fs.truncate(path, len, callback); // Asynchronous truncate. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.truncateSync(path, len); // Synchronous truncate.

  • [ ] fs.chown(path, uid, gid, callback); // Asynchronous chown. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.chownSync(path, uid, gid); // Synchronous chown.

  • [ ] fs.fchown(fd, uid, gid, callback); // Asynchronous fchown. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.fchownSync(fd, uid, gid); // Synchronous fchown.

  • [ ] fs.lchown(path, uid, gid, callback); // Asynchronous lchown. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.lchownSync(path, uid, gid); // Synchronous lchown.

  • [ ] fs.chmod(path, mode, callback); // Asynchronous chmod. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.chmodSync(path, mode); // Synchronous chmod.

  • [ ] fs.fchmod(fd, mode, callback); // Asynchronous fchmod. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.fchmodSync(fd, mode); // Synchronous fchmod.

  • [ ] fs.lchmod(path, mode, callback); // Asynchronous lchmod. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.lchmodSync(path, mode); // Synchronous lchmod.

  • [ ] fs.stat(path, callback); // Asynchronous stat. The callback gets two arguments (err, stats) where stats is a fs.Stats object.

  • [ ] fs.statSync(path); // Synchronous stat. Returns an instance of fs.Stats.

  • [ ] fs.lstat(path, callback); // Asynchronous lstat. The callback gets two arguments (err, stats) where stats is a fs.Stats object. lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, not the file that it refers to.

  • [ ] fs.lstatSync(path); // Synchronous lstat. Returns an instance of fs.Stats.

  • [ ] fs.fstat(fd, callback); // Asynchronous fstat. The callback gets two arguments (err, stats) where stats is a fs.Stats object. fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd.

  • [ ] fs.fstatSync(fd); // Synchronous fstat. Returns an instance of fs.Stats.

  • [ ] fs.link(srcpath, dstpath, callback); // Asynchronous link. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.linkSync(srcpath, dstpath); // Synchronous link.

  • [ ] fs.symlink(srcpath, dstpath, [type], callback); // Asynchronous symlink. No arguments other than a possible exception are given to the completion callback. The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows (ignored on other platforms)

  • [ ] fs.symlinkSync(srcpath, dstpath, [type]); // Synchronous symlink.

  • [ ] fs.readlink(path, callback); // Asynchronous readlink. The callback gets two arguments (err, linkString).

  • [ ] fs.readlinkSync(path); // Synchronous readlink. Returns the symbolic link's string value.

  • [ ] fs.unlink(path, callback); // Asynchronous unlink. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.unlinkSync(path); // Synchronous unlink.

  • [ ] fs.realpath(path, [cache], callback); // Asynchronous realpath. The callback gets two arguments (err, resolvedPath).

  • [ ] fs.realpathSync(path, [cache]); // Synchronous realpath. Returns the resolved path.

  • [ ] fs.rmdir(path, callback); // Asynchronous rmdir. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.rmdirSync(path); // Synchronous rmdir.

  • [ ] fs.mkdir(path, [mode], callback); // Asynchronous mkdir. No arguments other than a possible exception are given to the completion callback. mode defaults to 0777.

  • [ ] fs.mkdirSync(path, [mode]); // Synchronous mkdir.

  • [ ] fs.readdir(path, callback); // Asynchronous readdir. Reads the contents of a directory. The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.

  • [ ] fs.readdirSync(path); // Synchronous readdir. Returns an array of filenames excluding '.' and '..'.

  • [ ] fs.close(fd, callback); // Asynchronous close. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.closeSync(fd); // Synchronous close.

  • [ ] fs.open(path, flags, [mode], callback); // Asynchronous file open.

  • [ ] fs.openSync(path, flags, [mode]); // Synchronous version of fs.open().

  • [ ] fs.utimes(path, atime, mtime, callback); // Change file timestamps of the file referenced by the supplied path.

  • [ ] fs.utimesSync(path, atime, mtime); // Synchronous version of fs.utimes().

  • [ ] fs.futimes(fd, atime, mtime, callback); // Change the file timestamps of a file referenced by the supplied file descriptor.

  • [ ] fs.futimesSync(fd, atime, mtime); // Synchronous version of fs.futimes().

  • [ ] fs.fsync(fd, callback); // Asynchronous fsync. No arguments other than a possible exception are given to the completion callback.

  • [ ] fs.fsyncSync(fd); // Synchronous fsync.

  • [ ] fs.write(fd, buffer, offset, length, position, callback); // Write buffer to the file specified by fd.

  • [ ] fs.writeSync(fd, buffer, offset, length, position); // Synchronous version of fs.write(). Returns the number of bytes written.

  • [ ] fs.read(fd, buffer, offset, length, position, callback); // Read data from the file specified by fd.

  • [ ] fs.readSync(fd, buffer, offset, length, position); // Synchronous version of fs.read. Returns the number of bytesRead.

  • [ ] fs.readFile(filename, [options], callback); // Asynchronously reads the entire contents of a file.

  • [x] fs.readFileSync(filename, [options]); // Synchronous version of fs.readFile. Returns the contents of the filename. If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

  • [ ] fs.writeFile(filename, data, [options], callback); // Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer.

  • [x] fs.writeFileSync(filename, data, [options]); // The synchronous version of fs.writeFile.

  • [ ] fs.appendFile(filename, data, [options], callback); // Asynchronously append data to a file, creating the file if it not yet exists. data can be a string or a buffer.

  • [ ] fs.appendFileSync(filename, data, [options]); // The synchronous version of fs.appendFile.

  • [ ] fs.watch(filename, [options], [listener]); // Watch for changes on filename, where filename is either a file or a directory. The returned object is a fs.FSWatcher. The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename is the name of the file which triggered the event.

  • [ ] fs.exists(path, callback); // Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false. (should not be used)

  • [ ] fs.existsSync(path); // Synchronous version of fs.exists. (should not be used)

  • [ ] // fs.Stats: objects returned from fs.stat(), fs.lstat() and fs.fstat() and their synchronous counterparts are of this type.

  • [ ] stats.isFile();

  • [ ] stats.isDirectory()

  • [ ] stats.isBlockDevice()

  • [ ] stats.isCharacterDevice()

  • [ ] stats.isSymbolicLink() // (only valid with fs.lstat())

  • [ ] stats.isFIFO()

  • [ ] stats.isSocket()

  • [ ] fs.createReadStream(path, [options]); // Returns a new ReadStream object.

  • [ ] fs.createWriteStream(path, [options]); // Returns a new WriteStream object.