Comments (3)
I support the idea, esp for flags, its unclear if encoding
are the same everywhere though.
from reason-nodejs.
@sikanhe gotcha. I'll send a PR for the flag parameter then.
from reason-nodejs.
@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)
- Documentation needed
- Testing needed
- Conventions on Style, Techniques, Naming, etc.
- Binding EventEmitter class for custom events HOT 14
- Abstract return type of callbacks HOT 8
- Make `Fs.Constants` abstract? HOT 6
- Doesnโt compile with bs-platform 8.2 HOT 2
- Stream objectMode implementation callbacks HOT 4
- Fs add bindings for callback implementations
- Examples should show namespace HOT 3
- Incorrect execSync typing HOT 1
- ChildProcess incorrect types HOT 4
- `Fs.createWriteStreamOptions` returns wrong type HOT 1
- How to add `utf8` read option for the `Fs.readFileSync`? HOT 2
- How to create https server?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reason-nodejs.