Node-fs-extra: es6 refactoring

Created on 13 Feb 2017  路  4Comments  路  Source: jprichardson/node-fs-extra

Since just Node v4+ is supported wouldn't it be could to rewrite everything into ES6?

enhancement

Most helpful comment

@manidlou: @jprichardson & I have discussed promise support via email in the past. It's something we definitely want to do sometime, but we want to do it right. That means:

  • We need to support both promises & callbacks; if a callback is passed, use it; otherwise return a promise.
  • We need to wrap the native fs methods as well.

We also want a solution that will allow incremental porting of the internals to promises (i.e. our solution must be able to wrap both promise and callback functions).

I've been planning on attacking this as soon as I get time; I wanted to do it for v2, but it didn't happen.

All 4 comments

Yeah, Node 4+ supports most, but not all ES6 features. Given that this is a large codebase, porting to ES6 will take some time.

Currently, I've had a fairly passive approach to this; when I worked on a certain part of the codebase, I would port it to ES6.

If you want to work on this, thought, PRs welcome.


@jprichardson Do you have ES6 stylistic preferences? (i.e. should var be used)

@jprichardson Do you have ES6 stylistic preferences? (i.e. should var be used)

We should avoid var and use let/const if we can.

@jprichardson @RyanZim regarding the codebase, both internally and for the exported functions, do we want to keep the callback style or we want to change that to promise-based?

@manidlou: @jprichardson & I have discussed promise support via email in the past. It's something we definitely want to do sometime, but we want to do it right. That means:

  • We need to support both promises & callbacks; if a callback is passed, use it; otherwise return a promise.
  • We need to wrap the native fs methods as well.

We also want a solution that will allow incremental porting of the internals to promises (i.e. our solution must be able to wrap both promise and callback functions).

I've been planning on attacking this as soon as I get time; I wanted to do it for v2, but it didn't happen.

Was this page helpful?
0 / 5 - 0 ratings