Open ajvincent opened 1 year ago
I'm not sure what you're suggesting here - afaik unionfs
should already work with fs.promises
; could you explain in more detail what you're experiencing, and what you think could be improved?
Okay, you're looking for a genuine use case. Yes, unionfs
works with fs.promises
, at least as far as I can see. (Forgive me for filing right away, as I'm a first-time user of this library.)
Whenever possible, I prefer to use await
statements and async
functions. I usually import fs/promises
instead of fs
.
I was reading npmjs's package pages for unionfs and memfs, and thinking, "wow, this is really nice, and simple." Union instances have a .use()
method for adding typeof fs
instances.
My ideal case would be something like this:
import fs from "fs/promises";
import { Union } from "unionfs/promises";
import { Volume, createFSFromVolume } from "memfs/promises";
export function TemporaryFSPromises() : Union {
const vol = new Volume;
const inMemoryFS = createFsFromVolume(vol);
const unionFS = new Union;
return unionFS.use(fs).use(inMemoryFS);
}
In other words, like the synchronous filesystem API of Union.prototype.use
, I'm looking for an asynchronous filesystem API for Union.prototype.promise.use
or UnionPromise.prototype.use
(assuming the latter would exist as a spin-off into its own export or package).
As my code sample in the original post suggests, I've already figured out how to emulate this on my own, so it's not a strict need. I just think, for parity with the fs/promises
NodeJS package, it would be nice to have.
Right, so you're asking for a /promises
aliases - I'm not against exploring that, though I don't know if it'll actually be worth it since fs/promises
is literally an alias of fs.promises
that's exported directly which we already support, and it might require some complexity to maintain two different versions of the Union
class? (which probably should actually be the same class 🤔)
I don't always use
fs
, but when I do, I preferfs/promises
. 😄