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

simple-fs

v0.0.3

Published

A node.js implementation of the simple-stream and continuable based fs interface for js-git.

Downloads

4

Readme

simple-fs

A node.js implementation of the simple-stream and continuable based fs interface for js-git.

File System Interface

This module implements the following functions from the fs interface which is described in detail at https://github.com/creationix/js-git/blob/master/specs/fs.md

  • stat(path) -> continuable
  • read(path, [encoding]) -> continuable
  • write(path, value, [encoding]) -> continuable
  • readStream(path, [options]) -> stream
  • writeStream(path, [options]) -> sink
  • unlink(path) -> continuable
  • readlink(path) -> continuable
  • symlink(path, target) -> continuable
  • readdir(path) -> stream
  • rmdir(path) -> continuable
  • mkdir(path) -> continuable
  • rename(path, target) -> continuable
var fs = require('simple-fs');

// Streaming copy a file

// Set up a source, the file isn't actually opened till the stream is read from.
var source = fs.readStream("input.txt");

// Set up a sink.  The file isn't actually opened yet.
var sink = fs.writeStream("copy.txt");

// Hook the source to the sink, but still don't create either file or start moving yet.
var continuable = sink(source);

// Now, create both files and stream the contents.  If there is a problem it will be reported here.
// Otherwise the continuable will resolve with no error when done streaming.
continuable(function (err) {
  if (err) throw err;
  console.log("Done Streaming");
});

You don't have to store all the steps into variables, so you can simply chain the calls.

Also if you're in an ES6 generator using gen-run, then consuming the continuable is even easier.

var run = require('gen-run');
var fs = require('simple-fs');

function* copy(source, dest) {
  yield fs.writeStream(dest)(fs.readStream(source));
}

run(function* () {
  yield* copy("input.txt", "copy.txt");
});

chroot(root) -> fs

In addition to the exports object implementing the fs interface with respect to the filesystem root, you can also create a fs instance that is chrooted to some directory.

var fs = require('simple-fs')("/home/tim/Code/js-git/.git");

// read the first chunk in the staging area's index.
fs.readStream("/index")(null, console.log);