$ npm install ramdisk
What? Why? How does it work?!
This is just the easiest & quickest cross-platform solution that I just happened to come up with at the time. I mainly need it to test file system implementations and the like. The API is pretty much the same as blockdevice's, which features some crappy documentation on it. It's most likely worse than just reading the code. I'll work on it, I promise.
Thing is, it allocates sparsely (with the worst possible allocator (if you can even call it that) ever written to date) - meaning - you can specify 4 GB as size & you won't occupy 4 GB of memory, until you actually write to every sector.
var RamDisk =
// Options, with their defaultsvar device =// Emulated (?) device block sizeblockSize: 512// Cluster size. It allocates in these.clusterSize: 4096// The grand total (absolutely imaginary) size// of the entire contraption!size: 10 * 1024 * 1024
// Supplying a buffer to .readBlocks() is optionalvar buffer = deviceblockSizedevice