Giter Club home page Giter Club logo

Comments (3)

sikanhe avatar sikanhe commented on June 18, 2024

I support the idea, esp for flags, its unclear if encoding are the same everywhere though.

from reason-nodejs.

yawaramin avatar yawaramin commented on June 18, 2024

@sikanhe gotcha. I'll send a PR for the flag parameter then.

from reason-nodejs.

austindd avatar austindd commented on June 18, 2024

@yawaramin @sikanhe , Hey, just so you guys know, I have another branch in which I am making dramatic changes to this module:
https://github.com/sikanhe/reason-node/tree/events-overhaul
To be honest, these changes are technically out of the scope of what I intended for the branch, but I noticed a lot of issues and inconsistencies with parts of the FS API. We just haven't touched it in a while...

As for the encoding parameter, I am removing it altogether across the library. Specifying an encoding in the function parameter will coerce the "data" parameter to string. That is, the expected type of data input will become string instead of Buffer.t, and for all readable streams, the output will be coerced to string as well. This is inherently unsafe, unless we want to do the abstract StringBuffer.t technique, and provide boxing/unboxing functions to the user. We have done this before, and I'm not sure it's worth it... I already mentioned this issue to @sikanhe before.

I personally think the best way to deal with this issue is to only allow Buffer.t, and eliminate the ability to pass an encoding argument. If the encoding does need to be specified, the Buffer API has a function to let you set the encoding of the underlying byte-array, which is 100% equivalent in practice. If users want to work with strings, they can use the Buffer.toString/Buffer.fromString functions, both of which provide a way to specify the encoding.

This is not a 100% perfect solution, but it will dramatically reduce the amount of hoops we have to jump through to make IO operations safe.

Anyway, those are some of the changes I want to make with my current branch, but I'd be happy to take a look at the solution you suggested @yawaramin. Maybe submit a PR to my branch and we can merge it upstream later?

from reason-nodejs.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.