-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Open
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
What is the problem this feature will solve?
Sometimes, package developers want to allow users to specify a file path, fd (a number), or FileHandle as a single parameter for file operations. Unfortunately, there isn’t a reliable method for developers to check if an instance of the FileHandle class is provided. By implementing this feature, developers can easily and consistently check for the presence of a FileHandle instance.
What is the feature you are proposing to solve the problem?
I propose adding the following methods to the support:
- Make the
FileHandleclass accessible fromfs.FileHandleorfs.promises.FileHandle, allowing developers to check directly withinstanceof. - Implement a static method
FileHandle.isFileHandle(), similar to whatBufferdoes. - If feasible, provide a method in
FileHandle(fd)orFileHandle.from(fd)to convert afdnumber into aFileHandle.
What alternatives have you considered?
Checking the object’s methods and properties directly is not a smart approach. Obtaining the FileHandle class by opening any file is slow.
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Type
Projects
Status
Awaiting Triage