Rich-Harris/sander

API design suggestion: path arrays

callumlocke opened this issue · 0 comments

Hi Rich

I really like the way sander automatically path-resolves multiple string arguments.

But this comes at a cost:

  • you have to invent a new API for all methods that involve two paths (the .to() chain)
  • you can't support shortcuts like utf8 for {encoding: 'utf8'}

IMO these are big caveats. They stop sander from feeling like a drop-in replacement for fs. And I still trip up on them a lot and find myself scanning the readme again, even though I've been using sander for a long time.

Why not just provide this functionality via arrays? ie...

sander.writeFile([someDir, 'foo.txt'], content);

That is, any path arguments would have to be provided as either a single string or an array of strings. But always a single argument. (Obviously this would entail a major version bump.)