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

d.

v1.0.0

Published

Create/Read/Delete files and directories like they are JavaScript objects!

Downloads

2

Readme

d!

js-standard-style

ES6 Proxies enable us to do fun wacky things.

This module lets you access the file system as if it were JavaScript objects!

Dear Windows person: I'm sorry. I did not make this so it works on Windows. I wanted to keep it simple as a proof-of-concept. rimraf and mkdirp could probably be used to make it compatible. PR welcome ;)

npm install d!

How do you use this?

const disk = require('d!')
const root = disk(__dirname)
root.foo.bar.baz.qux = 'ES6 is freakin neeto!'
// go check your disk- You'll find the full directory tree and a file named `qux`

console.log(root.foo.bar.baz.qux)
// <Buffer 45 53 36 20 69 73 20 66 72 65 61 6b 69 6e 20 6e 65 65 74 6f 21>
// (it read the file, and returned the buffer)

console.log(root.foo.bar.baz.qux.toString())
// ES6 is freakin neeto!

// an alternative way for reading / writing deep files...
console.log(root['foo/bar/baz/qux'].toString())


delete root.foo
// go check your disk again- the foo folder is gone!

// Files without extensions are weird, you'll need to use `[]` notation..
root['data.json'] = { a:1, b:2 }

console.log(root['data.json'].toString())
// {"a":1,"b":2}
// (anything thats not a Buffer, string, boolean, or number is `JSON.stringify`ed)
// (but reading it back is not JSON.parsed!)

// directories are arrays... let's list your files..
console.log(root)
// or
root.forEach((item) => console.log(item))
// or
for(let item of root)
  console.log(item)

// want to get the resolved path? Use the `fs2.path` Symbol...
console.log(root['foo/bar/baz/qux'][disk.path])
// /Users/williamkapke/Desktop/node/fs!/data/foo/bar/baz/qux

// Directory lists and files contents are cached.
// This can be a really bad thing :/ Look at our cache:
console.log('\nbefore clear:')
console.log(disk.cache)

// Certainly problematic to keep references like this. Let's clear it...
disk.clearCache()
console.log('\nafter clear:')
console.log(disk.cache)
// {}