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 ezfs
How do you use this?
const ezfs = const root = rootfoobarbazqux = 'ES6 is freakin neeto!'// go check your disk- You'll find the full directory tree and a file named `qux` console// <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// ES6 is freakin neeto! // an alternative way for reading / writing deep files...console delete rootfoo// 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// {"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// orroot// orforlet item of root console // want to get the resolved path? Use the `fs2.path` Symbol...console// /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:consoleconsole // Certainly problematic to keep references like this. Let's clear it...ezfsconsoleconsole// {}
License
MIT