WIP: Add conditional support for gfs.promises. #166
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This support is dependent on
util.promisify
existing, so node.js 8+.Fixes #160
@isaacs I think the code itself is complete, I want to seek feedback before I spend the time on more test coverage. Of note unlike native
fs.promises
, reading thegfs.promises
property will never produce an 'experimental' warning. Additionally nativefs.promises
is not available in node.js 8 or 9,gfs.promises
is available in those versions. The list of functions that are promisified is fromObject.keys(require('fs').promises).sort()
in node.js 12.7.0.One difference,
require('fs').promises
appears to be separate wrappers around internal functions. Sofs.promises.stat
is not the result ofutil.promisify(fs.stat)
. Technically speaking the correct way to deal with this would be to reimplement all patched functions based directly onfs.promises
but that seems like it would be a maintenance burden and would limit use of gfs.promises to the versions of node.js which provide fs.promises. I'm not sure if there is someone from node.js we should ask if this makes an actual difference in any cases or if the node.js implementation does the same thing as util.promisify but with better performance.