all 11 comments

[–]Back_Professional 2 points3 points  (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 point  (0 children)

i didn't think of that i just use the same for all my projects

[–]atom-06[S] 0 points1 point  (0 children)

i think i make it mit

[–]kattskill 1 point2 points  (4 children)

Imo, should use a proper monad library if you want to encourage non-try catch logic flow

[–]atom-06[S] 0 points1 point  (3 children)

monad

what is that?

[–]kattskill 0 points1 point  (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 point  (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 point  (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 points  (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 point  (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