Comments (6)
Yeah, you're totally right. I think that's the right call. I want to say we inspected the values at runtime to see what they were under the hood, but it's probably irrelevant. Abstract types make sense.
from reason-nodejs.
Thanks Austin. I just realized that these constants are expected to be used as ints, e.g. from https://nodejs.org/dist/latest-v10.x/docs/api/fs.html#fs_fs_copyfile_src_dest_flags_callback:
flags
is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE
).
So the type of all flags would also need to be changed to Constants.t
and also a logical-or operator (or function) would need to be added to allow doing bitmasks. But that is reasonably easy, e.g.
module Constants: {
type t;
...
let (||): (t, t) => t;
} = {
type t = int;
...
let (||)(t1, t2) = t1 lor t2;
};
from reason-nodejs.
On the other hand, if the constants are each instances of separate abstract types, then it's tricky to pattern match on them. And I can imagine use cases for pattern matching. What do you think?
from reason-nodejs.
Yeah you're right, that can also be solved by using a pri int
type, since the docs do implicitly say that it should be an int
.
from reason-nodejs.
from reason-nodejs.
Sure, I'll send a PR soon.
from reason-nodejs.
Related Issues (16)
- Documentation needed
- Testing needed
- Conventions on Style, Techniques, Naming, etc.
- Factor out file permissions flag type? HOT 3
- Binding EventEmitter class for custom events HOT 14
- Abstract return type of callbacks HOT 8
- 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.