Closed HRIDYANSHU054 closed 5 months ago
Hi @kgryte , @Planeshifter, @steff456
can you kindly review this proposal and if there are any ambiguities which should be cleared in it and any other general changes. Please can you also comment on the schedule.
@HRIDYANSHU054 thanks for filing the proposal, looks good. Would be worth mentioning about your plans in community bonding period, you may wrap a few things up to compensate for your exams during May 22 - June 22 which overlaps more with Phase1 . Also, can you please mention how many hours are you targeting ( 175 / 350 ) ?
@HRIDYANSHU054 Thank you for sharing a draft of your proposal. A few comments:
fs.cp
was added in v16.7.0
. One of the core principles of stdlib is ensuring backward compatibility. Historically, we've supported all the way back to Node.js v0.10
. While we could potentially relax this requirement, how do you plan to support stdlib APIs which can accommodate and smooth over the differences across Node.js versions?cp
, writevSync
, fchmod
, etc). Would you mind sharing why you've chosen the API set you have?Ideally, any fs
API we provide should work across all versions of Node.js that we support. And thus, for Node.js versions with missing functionality, we'd need to provide polyfills. And this could potentially be quite involved, and, if so, could affect your project timeline.
Thank you @Pranavchiku for reviewing this proposal, I have added my plan for the community bonding period , this was somehow left in the initial proposal.
In both the above possible schedules(12 weeks and 16 weeks) the project scope will span over 350 hours.
Thank you @kgryte for this review
First of all I really appreciate that you have given me the freedom to take the 16 weeks schedule .
Regarding your 2nd Question I am planning to use version checking and Pollyfilling and then provide the appropriate functionality for the user's Node version
I am taking an example of what I have thought of implementing promises these promisified versions would be provided as seperate APIs just like sync and async APIs are provided so fs.promises were supported in Node version 10 , so if the process Node version is 10 r greater I will be providing a fs.promiseS functionality now a suitable way to replace this functionality in versions that are older than the version 10, is to use JavaScript native Promises constructor and combine them with the callback based versions of fs functions
a demo for mkdir( )
function mkdirPromise(path, options = {}) {
// Polyfill for Node.js versions below 10
// internally implement Native promise + callback based async API
if ( Number(process.versions.node.split('.')[0] ) < 10 ) {
return new Promise((resolve, reject) => {
fs.mkdir(path, options, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
});
}
// Using fs.promises API for versions greater than 10
return fs.promises.mkdir(path, options);
}
also we could have not even used the version checking and instead use the JavaScript promises along with callback based fs functions in the first place but then there are many options of the fs.promises functions which requires a lot of work to implement on our own .This I feel is something that I could start working on post GSOC.
Regarding 3rd, the APIs that I have seen in the codebase and documentations during this period could be implemented using native JavaScript promises and the functionalities which comes along with it , like then() and catch() ( not stating await and async since then and catch covers more older versions of Node JS), Promise.Resolve( ), Promise.Reject( ).
Regarding 4th
I have mentioned this in the proposal also under The Prior Art section that 13 ( close, exists, open, readDir, readFile, readFileList, readJSON, readWASM, rename, resolveParentPath, resolveParentPathBy, unlink, writeFile ) APIs have already been built by the stdlib contributors. So, the work for me on these APIs would be to refactor them if asked to and implement the promisified versions. Still, Also this list is subjected to changes .
@kgryte a simpler implementation for cp( ) promises using the above approach I stated would be like this
function cpPromise(src, dest, options = {}) {
if (Number(process.versions.node.split('.')[0] ) > 16) {
// Use fs.cp promise version for Node.js v16 and above
return fs.promises.cp(src, dest, options);
} else {
// Fallback functionality implemented by using streams
return new Promise((resolve, reject) => {
fs.stat(src, (err, stats) => {
if (err) {
reject(err);
return;
}
if (!stats.isDirectory()) {
// copies a single file
var rStream = fs.createReadStream(src);
var wStream = fs.createWriteStream(path.join(dest, path.basename(src)));
rStream.pipe(writeStream);
rStream.on('end', () => resolve());
return;
}
// copying entire directory
mkdir(dest, { recursive: true }, (err) => {
if (err) {
reject(err);
return;
}
var files = readdirSync(src);
var promises = [];
for (const file of files) {
var srcFile = path.join(src, file);
var destFile = path.join(dest, file);
promises.push(cp(srcFile, destFile, options)); // Recursively calling for subdirectories
}
Promise.all(promises)
.then(() => resolve())
.catch(err => reject(err));
});
});
});
}
}
This is just a rough implementation and would be broken, modified and refined upon whenever the times comes to implement this. Also implementation of cp( ) would directly come after createWriteStream( ) and createReadStream( ) has been implemented.
Please check whether this implementation aligns with your vision of keeping abstraction and Node js version independency in fs promises and fs API s for stdlib
Full name
Hridyanshu
University status
Yes
University name
Vivekananda Institute of Professional Studies Technical Campus
University program
BTech in AI & ML
Expected graduation
June 2025
Short biography
I am a pre final year student at VIPS TC School of Engineering and Technology, pursuing BTech in Ai & ML. Currently my skillset involves web development and machine learning. I started my coding journey during my first year in college in which I learned C and C++. My focus shifted towards web development because I wanted to create applications that were pleasant to the eyes in addition to being functional and not only limited to my console. I am also very excited by the potential machine learning holds in solving real world problems. I have been learning ML mainly through my college courses and online resources. Furthermore, I have done certain projects in ML that have contributed in piquing my interest. I like to code simply because it makes our lives much easier that is another reason I am a ML enthusiast. I believe in collaborative learning and contribute to open source projects whenever possible.
Timezone
India Standard Time ( UTC+5:30 )
Contact details
Hridyanshu054, 05417711621_ml@vips.edu, himank7794@gmail.com
Platform
Windows
Editor
VSCode mainly because its very easy to learn and start debugging with. Has a very clean and customizable interface, and it works great for my web development needs. I have also worked with Jupyter notebook and Pycharm for ML tasks.
Programming experience
These are some of my projects –
X-IDE - Web-based IDE designed to provide users with a streamlined coding experience directly within their web browser. BUilt usin modern technologies such as React JS, Typescript and Codemirror2.js offering a responsive and intuitive coding environment. ( https://hridyanshu-xide-3f3160.netlify.app/ )
News App - News App is a mobile-optimized web application that allows users to browse and filter news articles from multiple sources.It is built using Next.js, TypeScript, TailwindCSS, StepZen API, and GraphQL.This project showcases my proficiency in modern web development technologies and my ability to build complex applications with a clean codebase. ( https://news-app-sigma-khaki.vercel.app/ )
PhenoPal – an easy to use app to help users find their body phenotype and give recommendation accordingly , utilizes intent matching and nlp techniques built in Flutter. ( https://github.com/HRIDYANSHU054/PhenoPalVerOne )
Mapty - Mapty is a little tool that helps you log your running or cycling workouts based on location. Pretty simple, click on the map, select the type of workout, fill out the details of your workout and press enter! Mapty will create a workout on the map and in the sidebar. ( https://hridyanshu-mapty-3d6ce0.netlify.app/ )
LPG Gas Leakage Detector – An Arduino project designed by me to detect the presence of combustible constituents of LPG, such as Propane and Butane and then generate alerts to the homeowners and activates an alarm and exhaust fan until the room is clear from gases.
AOD Prime – A HAAR feature extractor and deep learning based animal vehicle collision avoidance and detection system currently given to be published in Scopus.
More on my portfolio https://jgjportfolio.vercel.app/
JavaScript experience
My JavaScript experience is well highlighted in the above projects. Project involving js are
My favorite features about Javascript are
My least favorite things about JavaScript
Node.js experience
I got introduced to node js from a book my friend recommended “Node Js Novice to Ninja”. I am using Node js mostly as a build tool, almost all my projects have some kind of node js involvement. I'm familiar with popular Node.js modules and frameworks like Express.js, furthermore I'm always eager to learn new ones relevant to the project demands. Currently I am also building a blog app with mongodb as a backend on Node js to integrate with my portfolio website.
C/Fortran experience
I was introduced to C programming in my first year of college. Since, then I have been using it mostly for my college coursework. Mostly I am familiar with C++, which I have used for both algorithmic problem solving and development. Also, I have worked with Arduino Programming language which is quite similar to C++ for my hardware projects.
Interest in stdlib
Something that excites me about contributing to stdlib is that it is aiming to provide a comprehensive library for JavaScript , something that is already there in other languages and which Javascript lacks , and something that I feel could really contribute to developers community. another thing about stdlib is that the way they truly implemented SOLID principles in their VAST codebase which makes everything look maintainable. To be among such batch of developers and to learn from them will prove a strong foundation in my career.
Version control
Yes
Contributions to stdlib
Open PR feat: add fs/append-file #1967 https://github.com/stdlib-js/stdlib/pull/1967 aligned with this project, I have aimed at bringing fs useful append-file functionality to stdlib and also this was an attempt o get familiar with the codebase by doing some wiring rewiring.
Async implementation
Synchronous implementation
Goals
The goal of this project is to provide feature parity with Node.js fs package, stdlib currently supports a limited number of fs functionalities. I would be contributing to add some more.
This project will also implement an abstraction layer so that these APIs will not become Node versions dependent and would instead use other workaround if user’s node versions requirement for a certain feature is not met.
Deliverables
After going through Node JS File System documentation and the existing fs functionalities within stdlib. I have decided on implementing the following APIs
access(path[, mode], clbk) ;
chmod(path, mode, clbk) ;
copyFile(src, dest[, mode], clbk) ;
chown(path, uid, gid, clbk) ;
chownLink(path, uid, gid, clbk) ;
createReadStream(path[, options]) ;
createWriteStream(path[, options]) ;
link(existingPath, newPath, clbk) ;
mkdir(path[, options], clbk) ;
mkdtemp(prefix[, options], clbk) ;
opendir(path[, options], clbk) ;
rmdir(path[, options], clbk) ;
rm(path[, options], clbk) ;
stat(path[, options], clbk) ;
statLink(path[, options], clbk) ;
statFs(path[, options], clbk) ;
symlink(target, path[, type], clbk) ;
truncate(path[, len], clbk) ;
unwatchFile(filename[, listener]) ;
utimes(path, atime, mtime, clbk) ;
utimesLink(path, atime, mtime, clbk) ;
watchFile(filename[, options], listener) ;
The sync versions of these functionalities will also be implemented. Please note these apis were considered as they covered the important functionalities for perforiming file system operations through stdlib, any addition or deletion to this list as or when suggested by the mentors would be priotised.
Testing
All of these API will be thoroughly tested using Tape framework to ensure proper functionality and interaction with the existing stdlib APIs, mocking APIs calls and checking whether expected data is returned.
Proper and elegant error handling will implemented providing concised error messages.
Proper compatability testing of these APIs will be done to ensure that they run as expected throughtout different Node versions.
Updates
Regular updates will be shared in my blog on the implemented APIs and challenges that I face that I face in implementing them.
Documentation and Refinement
I'll create detailed API documentation for each of the APIs that will be implemented, explaining exactly how to use them. For this I'll also include usage examples to make things crystal clear and cover any edge cases that users may face. Next, I'll update the stdlib user documentation to reflect these new functionalities. This way, anyone using stdlib will know exactly what these new fs methods do and how to use them. Finally I will remain energized and excited for the code reviews with my mentors, anything that could further optimized the code or the overall quality will be taken into consideration and implemented.
Why this project?
As a developer working on a project which simplifies development workflows and brings a more unified Node js environment is deeply rewardind. Also the code review sessions with the mentors gives me an excellent opportunity to learn best practices for efficient and maintainable code. Finally I believe that stdlib holds huge potential for bein a one stop solution for many things in Javascript be it numerical computing, data processing or even the built in Node js functionalities. I m eager to be a part of this ecosystem and to learn from mentors that are part of this.
Qualifications
I have a thorough understanding of Javascript fundamentals and experience with Node js which could be seen in my projects. I have a strong hold over file system operations and have used the fs package in many of my projects. Also through the Node js documentation and stdlib implementations I have gained some familiarity with the abstractions needed to be provided to support different env. I will be using this knowledge to ensure that all the apis re truly compatible across different Node JS versions. Also I have done some wiring rewiring in stdlib to create the append-file Api(currently an open PR), and as such I am familiar with the workings here and will use this in implementing the other Apis. Regarding the college coursework I have had subjects relevant to the project which includes Web Development, Software Engineering, Data Structures, Design and Analysis of Algorithms.
Prior art
Node js fs documentations. Stdlib already has some fs api including close, exists, open, readDir, readFile, readFileList, readJSON, readWASM, rename, resolveParentPath, resolveParentPathBy, unlink, writeFile ( in total 13 ) these provide sufficient examples from which the implementation of new APIs will take off. Readable-stream package.
Commitment
From May 22 to June 22 I will be having my end semester examinations. During this time I will not be able to dedicate much time in coding still I will try to allocate 2 to 3 hr. daily Apart from this I will be available to work full time on the project for the remaining timeframe.
Schedule
Assuming a 12 week schedule,
Will be extensively used for communicating with my mentors verifying the proposed plan of implementation and the order in which these APIs will be implemented, along with this I would also start implementation of some minor load Apis so that the first four weeks of coding in which I will be occupied in my exams could be consolidated. Also during this period, I would mostly like to communicate and clarify the Abstraction demand of the project, this would help me in sorting out the requirements and familiarizing myself with the plan in which these abstractions will be implemented so that I could make quality contribution to this aspect.
First 4 weeks ( Exam period )
During this time I will be working on creating the following api and opening PR for them access( ), chmod( ), chown( ), copyFile( ), link( ), chownLink( ) , stat( ), statFs( ), statLink( ) they will also be coming fully tested, documented, with enough suitable examples and benchmarking. I will also be opening any possible Issues regarding theses APIs. Though I will try to but as of now any changes in these implementations as or if demanded by code reviews only seems possible for me to implement in the 5th week.
5th week symslink( ) api will be implemented in this period. I will be implementing the changes demanded in code reviews in the APIs implemented in previous weeks. Any or modifications for them will be done in this week.
6th week midterm evaluation
7th and 8th week Opening PRs on the following APIs mkdir( ), mkdtemp( ), rmdir( ), openDir( ) They will also be thoroughly tested and fully documented with suitable examples to show working. Any modifications or optimizations as highlighted by the mentors will also be implemented. Issues on these APIs if any will be opened and addressed in these weeks.
9th and 10th week PRs will be opened on the following APIs rm( ), truncate( ), watchFile( ), unwatchFile( ) They will also be thoroughly tested and fully documented with suitable examples to show working. Any modifications or optimizations as highlighted by the mentors will also be implemented. Issues on these APIs if any will be opened and addressed in these weeks.
11th and 12th week createWriteStream( ), createReadStream( ), utimesLink( ), and utimes( )
This schedule is subjected to change if mentors demand and any API that is prioritized by the mentors will be implemented earlier.
I would like to highlight that this timeline is made in accordance to the 12 weeks timeline suggested. And I have adjusted my workload along with the exams to deliver this. But if the mentors allow and I sincerely request to extend this timeline from 12 to 16 weeks, this will also give me time to focus on my examinations and help in improving the quality of my contributions.
The 16 weeks schedule will include
First 4 weeks ( Exam period ) During this time I will be working on creating the following api and opening PR for them access( ), chmod( ), chown( ), copyFile( ), link( ) ,chownLink( ) they will also be coming fully tested, documented, with enough suitable examples and benchmarking. I will also be opening any possible Issues regarding theses APIs. Though I will try to but as of now any changes in these implementations as or if demanded by code reviews only seems possible for me to implement in the 5th week.
5th week symslink( ) api will be implemented in this period. I will be implementing the changes demanded in code reviews in the APIs implemented in previous weeks. Any or modifications for them will be done in this week.
6th and 7th week Opening PRs on the following APIs mkdir( ), mkdtemp( ), rmdir( ), openDir( ) They will also be thoroughly tested and fully documented with suitable examples to show working. Any modifications or optimizations as highlighted by the mentors will also be implemented. Issues on these APIs if any will be opened and addressed in these weeks.
8th and 9th week PRs will be opened on the following APIs rm( ), truncate( ), stat( ), statFs( ), statLink( ) They will also be thoroughly tested and fully documented with suitable examples to show working. Any modifications or optimizations as highlighted by the mentors will also be implemented. Issues on these APIs if any will be opened and addressed in these weeks.
10th week midterm evaluation
11th and 12th week Implementing the following APIs createWriteStream( ), createReadStream( ), utimesLink( ), and utimes( ) will be thoroughly tested and fully documented with suitable examples to show working. Any modifications or optimizations as highlighted by the mentors will also be implemented.
13th week watchFile( ), unwatchFile( ). Proper documentation , benchmarking and testing for the same.
14th and 15th week Implementing a promisified version for the async functionalities in these APIs. Proper documentation , benchmarking and testing for the same.
16th week Final revisions and testing.
Changes in this schedule from the 12 weeks one
Note
Related issues
Yes this idea has been proposed by @kgryte
link for the same - https://github.com/stdlib-js/google-summer-of-code/issues/10
Checklist
[RFC]:
and succinctly describes your proposal.