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

virtualfs

v2.2.0

Published

In-memory fs replacement

Downloads

660

Readme

VirtualFS

VirtualFS is a virtual posix-like filesystem that runs completely in memory. It is intended to work in browsers and in NodeJS. For browser usage, make use of a bundler like Webpack, Browserify or Rollup.

It includes:

  • Proper stat metadata with MAC time handling
  • Symlink support
  • Hardlink support
  • Virtual inodes
  • File descriptor support
  • Proper streams implementation
  • Character device support (/dev/null, /dev/full, /dev/tty...)
  • Current working directory support
  • Simulation of Unix file permissions
  • Umask is considered when creating new iNodes
  • Simulates POSIX filesystem errors
  • Emulates mmap with MAP_PRIVATE and MAP_SHARED
  • Usage of Flow types
  • Removal of all Windows path support
  • Practically complete compatibility with Node's FileSystem API

This package will be maintained as long as the Polykey project is maintained. All tests are passing in this fork.

Documentation

Documentation is located in the doc folder. You can also view the rendered HTML.

The VirtualFS API extends Node's fs API, while also leaving out functions that are not emulatable in-memory. For the functions that have the same name, you can just refer to Node's FS API: https://nodejs.org/api/fs.html. For the functions that don't have the name, refer to the generated API documentation that uses flow types. The source code is understandable so you can just read that as well.

To use VirtualFS as a global polyfill for fs, all you need to do is:

import vfs from 'virtualfs';
(typeof self === 'undefined' ? typeof global === 'undefined' ? this : global : self).fs = vfs;
// alternatively use the global package `import global from 'global'; global.fs = vfs;`

All subsequent uses of fs in the current module, subsequently imported modules, and any module that imports the current module will also use the same fs. The above monkeypatch works in Node, Browsers and Web Workers. However this will also make /dev/tty not work because it uses Node's real fs. Instead you should rely on a per-module override. Unless of course you're not using /dev/tty in Node.

In order to only override on a per-module basis you'll need to use the rewire package or the https://github.com/speedskater/babel-plugin-rewire babel plugin.

When using this in a CommonJS environment, you can gain access to the default fs replacement by using var fs = require('virtualfs').default;.

Development

To run flow type checks:

flow status
flow stop

To build this package for release:

npm run build

It will run tests, generate documentation and output multiple targets. One for browsers and one for nodejs. See rollup.config.js to see the target specification.

If your bundler is aware of the module field in package.json, you'll get the ES6 module directly.

Once you've updated the package run this:

npm version <update_type>
npm publish

The browser target makes use of these polyfills:

  • buffer - Used everywhere.
  • events - Used by streams dependency.
  • path - Used for join.
  • process - Used for nextTick and stdin and stdout streams.
  • stream - Used for filesystem streaming

They are currently supplied through Rollup plugins.

Todo

  • Investigate mounting implementation