trxcllnt / rxjs-fs

RxJS wrappers around some of the node fs lib.
MIT License
12 stars 5 forks source link

Update rxjs-fs for the latest rxjs 5 and introduce typescript #2

Open alex3165 opened 7 years ago

alex3165 commented 7 years ago

I have started an udpate of your library using typescript, if you are interested about it once I am done I can create a Pull Request, let me know.

https://github.com/alex3165/rxjs-fs

Also I think we should get rid of lodash as a dependency

trxcllnt commented 7 years ago

@alex3165 oh very interesting. I've actually started on a better version (cleaned up, Rx5, ES6), but haven't had time to work on it lately. Would it help if I pushed that branch to GH? I wouldn't mind migrating the new stuff to TS if you're keen.

alex3165 commented 7 years ago

Hey, yes happy to merge it with your branch 👍 if you can push to GH that would be awesome.

alex3165 commented 7 years ago

And I think it make sense to write it using typescript as rxjs is written in typescript and peoples will benefit of the type definition files for free.

trxcllnt commented 7 years ago

That's fine, TS just isn't the language I prefer when I'm dev'ing solo, but happy to collaborate if you want to contribute the build and deploy steps.

trxcllnt commented 7 years ago

@alex3165 pushed to https://github.com/trxcllnt/rxjs-fs/tree/rxjs5

trxcllnt commented 7 years ago

Let me know if there's anything I can clarify beyond these notes:

  1. The FileSystem class is meant to extend Observable, so you can flatMap etc., yet still access the FileSystem class's instance methods.
  2. The instance methods are all designed to emit wrapper Objects, where each key in the emitted values correspond to the methods that created them. For example, FileSystem.dir('./').stats().file() will emit Objects with a { path, stats, file } shape (assuming ./ has any files). Each wrapper Object should at least have a path. This way instance methods can be lossless-ly chained without breaking the Observable comprehension.
  3. The stats, lstats and fstats instance methods check the incoming value and to avoid calling the FS stat method redundantly. This may be an unsafe assumption, or it may be necessary to cache stats by path inside the monad.
  4. I've started with a few tests (in src/__tests__) as Jest snapshot tests via babel-jest. I'm not sure if Jest supports TS, but feel free to change the config if it does.
trxcllnt commented 7 years ago

@alex3165 just added a few more tests.

trxcllnt commented 7 years ago

Also more instance methods need to be added (and file() needs to be renamed to readFile()) for most fs operation that can be run on a path. I'm thinking exists, unlink, mkdir, etc.