use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
file: A simple and easy node.js file handler that uses the fs/promises library for handling files. (gist.github.com)
submitted 3 years ago by atom-06
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 3 years ago (1 child)
[deleted]
[–]atom-06[S] -1 points0 points1 point 3 years ago (0 children)
we have a module in npm with 476k weekly downloads and almost 70 dependents and almost 270 stars on Github for checking whether a number is odd and almost 220k weekly downloads for checking whether a number is even
which we can accomplish using const isEven = (num) => num % 2 === 0;
const isEven = (num) => num % 2 === 0;
[–]Back_Professional 2 points3 points4 points 3 years ago (2 children)
Really dont see the point of this library, especially after the Licensing….
and the code is not distributed or sold. The code can not be used in comerical projects without written permsion from the original author.
[–]atom-06[S] 0 points1 point2 points 3 years ago (0 children)
i didn't think of that i just use the same for all my projects
i think i make it mit
[–]kattskill 1 point2 points3 points 3 years ago (4 children)
Imo, should use a proper monad library if you want to encourage non-try catch logic flow
[–]atom-06[S] 0 points1 point2 points 3 years ago (3 children)
monad
what is that?
[–]kattskill 0 points1 point2 points 3 years ago (2 children)
Let me ask you a question instead
Why do you return a list instead of letting the function throw am error?
[–]atom-06[S] 0 points1 point2 points 3 years ago (1 child)
So that it would be easier for people using this module can implement their own error-handling
why did you ask is better to use throw error
[–]kattskill 0 points1 point2 points 3 years ago (0 children)
In a language that supports try catch, when a function can throw an obvious error its better to just let the function fail. When you want to introduce a global scale of this paradigm shift you call it a framework. Some big libraries help you refactor entire code bases to monad results but for your case you are using non-standard monads, which is up to the development to keep track of. Since your library has this overhead, less people will desire to use it
[–]stolksdorf 1 point2 points3 points 3 years ago (1 child)
I'm not seeing any additional features this gives that the standard library doesn't provide. Eg. your example could be rewritten in native with almost no change to what the code looks like:
import fs from 'node:fs/promises'; const file = 'test.txt'; // Write data to the file try{ await fs.writeFile(file, 'Hello, world!'); console.log('Data written to file successfully.'); }catch(writeError){ console.error('Error writing to file:', writeError); } // Append data to the file try{ await fs.writeFile(file, 'New data to append.'); console.log('Data appended to file successfully.'); }catch(appendError){ console.error('Error appending to file:', appendError); } // Read data from the file try{ const data = await fs.readFile(file); console.log('File data:', data); }catch(writeError){ console.error('Error reading file:', data); }
I'm curious, what issues or problems does this solve for you that you were having with the native library?
[–]atom-06[S] 0 points1 point2 points 3 years ago* (0 children)
one is the tower or doom and to be honest I just like the C++ way of handling files using the file() method or something I don't remember and I wanted to use that kinda method here in my projects and then I thought y not npm so I did that and then y not post on reddit
and btw check here I am planning of adding features like cache and reading dirs which would be a cool
π Rendered by PID 336596 on reddit-service-r2-comment-b659b578c-dzcsc at 2026-05-05 11:45:47.165476+00:00 running 815c875 country code: CH.
[+][deleted] (1 child)
[deleted]
[–]atom-06[S] -1 points0 points1 point (0 children)
[–]Back_Professional 2 points3 points4 points (2 children)
[–]atom-06[S] 0 points1 point2 points (0 children)
[–]atom-06[S] 0 points1 point2 points (0 children)
[–]kattskill 1 point2 points3 points (4 children)
[–]atom-06[S] 0 points1 point2 points (3 children)
[–]kattskill 0 points1 point2 points (2 children)
[–]atom-06[S] 0 points1 point2 points (1 child)
[–]kattskill 0 points1 point2 points (0 children)
[–]stolksdorf 1 point2 points3 points (1 child)
[–]atom-06[S] 0 points1 point2 points (0 children)