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

filed

v0.2.1

Published

Simplified file library.

Downloads

12,298

Readme

filed -- Simplified file library.

Install

Super simple to use

Filed does a lazy stat call so you can actually open a file and begin writing to it and if the file isn't there it will just be created.

var filed = require('filed');
var f = filed('/newfile')
f.write('test')
f.end()

Streaming

The returned file object is a stream so you can do standard stream stuff to it. Based on what you do the object it will be a read stream, a write stream.

So if you send data to it, it'll be a write stream.

fs.createReadStream.pipe(filed('/newfile'))

If you pipe it to a destination it'll be a read stream.

filed('/myfile').pipe(fs.createWriteStream('/out'))

And of course you can pipe a filed object from itself to itself and it'll figure it out.

filed('/myfile').pipe(filed('/newfile'))

Those familiar with request will be familiar seeing object capability detection when doing HTTP. filed does this as well.

http.createServer(function (req, resp) {
  filed('/data.json').pipe(resp)
})

Not only does the JSON file get streamed to the HTTP Response it will include an Etag, Last-Modified, Content-Length, and a Content-Type header based on the filed extension.

http.createServer(function (req, resp) {
  req.pipe(filed('/newfile')).pipe(resp)
})

When accepting a PUT request data will be streamed to the file and a 201 status will be sent on the HTTP Response when the upload is finished.

During a GET request a 404 Response will be sent if the file does not exist.

http.createServer(function (req, resp) {
  req.pipe(filed('/data.json')).pipe(resp)
})

The Etag and Last-Modified headers filed creates are based solely on the stat() call so if you pipe a request to an existing file the cache control headers will be taken into account; a 304 response will be sent if the cache control headers match a new stat() call. This can be very helpful in avoiding unnecessary disc reads.

http.createServer(function (req, resp) {
  req.pipe(filed('/directory')).pipe(resp)
})

Just to round out the full feature set and make it full file server if you give filed an existing directory it will actually check for an index.html file in that directory and serve it if it exists.

License

ASL 2.0, see LICENSE file.