Skip to content

Commit

Permalink
Merge pull request #3 from zth/integrate-node-bindings
Browse files Browse the repository at this point in the history
Copy rescript-nodejs bindings into repo
  • Loading branch information
zth committed Dec 28, 2023
2 parents fe46929 + c1b58eb commit 984fe4a
Show file tree
Hide file tree
Showing 82 changed files with 7,365 additions and 1,356 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# main

- Integrate Node bindings from [`rescript-nodejs`](https://github.com/TheSpyder/rescript-nodejs).

# 0.2.1

- Fix `Glob`.
Expand Down
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Include them in your `rescript.json`:
This will make all of Bun available to you without needing to dip into the `RescriptBun` module explicitly.

## Credits

This lib copies [`rescript-nodejs`](https://github.com/TheSpyder/rescript-nodejs) for Bun's Node compatible bindings. Shout out to the maintainers of that project!

## Examples

Here's a few examples of how it looks. More examples (often inspired by `https://bun.sh/guides`) can be found in the `playground/examples` directory in this repo.
Expand Down Expand Up @@ -152,47 +156,47 @@ Currently, bindings exist for the most common things. There's still a good amoun
- [x] Globals
- [x] Bun
- [x] Tests
- [ ] Fs
- [ ] Stream (some stream utils already exist in Globals + Bun)
- [x] Fs
- [x] Stream (some stream utils already exist in Globals + Bun)
- [x] Path

#### Prio 2

- [x] AsyncHooks
- [ ] Crypto
- [ ] Buffer
- [ ] Child_process (needs Stream?)
- [x] Crypto
- [x] Buffer
- [x] Child_process (needs Stream?)
- [x] HTML Rewriter
- [x] Os
- [ ] Sqlite
- [x] Perf hooks
- [x] StringDecoder
- [ ] Readline (needs Stream?)
- [x] Readline (needs Stream?)
- [x] WorkerThreads

#### Prio 3

- [ ] FFI
- [ ] Util
- [x] Util
- [ ] SupportsColors
- [ ] Timers
- [ ] Tls
- [ ] Tty
- [x] Timers
- [x] Tls
- [x] Tty

#### Unclear if needed

- [ ] Assert
- [x] Assert
- [ ] Diagnostics channel
- [ ] Dns
- [x] Dns
- [ ] Domain
- [ ] Events
- [x] Events
- [ ] JSC
- [ ] Module
- [ ] Net
- [ ] VM
- [x] Module
- [x] Net
- [x] VM
- [ ] WS (already multiple websocket things present)
- [ ] Zlib (bun has its own gzip?)
- [ ] Http (Nodes built in HTTP, should use Bun's own, right?)
- [x] Zlib (bun has its own gzip?)
- [x] Http (Nodes built in HTTP, should use Bun's own, right?)

#### Definitively not needed

Expand Down
4 changes: 2 additions & 2 deletions playground/examples/HTTP.E3.StreamFile.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"name": "rescript-bun",
"namespace": true,
"sources": {
"dir": "src"
"dir": "src",
"subdirs": true
},
"package-specs": {
"module": "es6",
Expand Down
9 changes: 9 additions & 0 deletions src/Assert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/Assert.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@module("node:assert") external ok: 'a => unit = "ok"
@module("node:assert") external equal: ('a, 'a) => unit = "equal"
@module("node:assert") external notEqual: ('a, 'a) => unit = "notEqual"
@module("node:assert") external deepEqual: ('a, 'a) => unit = "deepEqual"
@module("node:assert") external notDeepEqual: ('a, 'a) => unit = "notDeepEqual"
@module("node:assert") external strictEqual: ('a, 'a) => unit = "strictEqual"
@module("node:assert")
external notStrictEqual: ('a, 'a) => unit = "notStrictEqual"
@module("node:assert")
external deepStrictEqual: ('a, 'a) => unit = "deepStrictEqual"
@module("node:assert")
external notDeepStrictEqual: ('a, 'a) => unit = "notDeepStrictEqual"
@module("node:assert")
external throws: (@uncurry (unit => 'a)) => unit = "throws"
@module("node:assert")
external throwsError: (@uncurry (unit => 'a), 'e) => unit = "throws"
@module("node:assert")
external doesNotThrow: (@uncurry (unit => 'a)) => unit = "doesNotThrow"
@module("node:assert")
external doesNotThrowError: (@uncurry (unit => 'a), 'e) => unit = "doesNotThrow"
@module("node:assert") external ifError: 'a => unit = "ifError"
@module("node:assert")
external rejects: (@uncurry (unit => Js.Promise.t<'a>)) => unit = "rejects"
@module("node:assert")
external rejectsError: (@uncurry (unit => Js.Promise.t<'a>), 'e) => unit = "rejects"
@module("node:assert")
external doesNotReject: (@uncurry (unit => Js.Promise.t<'a>)) => unit = "doesNotReject"
@module("node:assert")
external doesNotRejectError: (@uncurry (unit => Js.Promise.t<'a>), 'e) => unit = "doesNotReject"

module AssertionError = Errors.AssertionError
34 changes: 34 additions & 0 deletions src/BigInt.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions src/BigInt.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
type t

@val external fromInt: int => t = "BigInt"
@val external fromFloat: float => t = "BigInt"
@val external toInt: t => int = "Number"

%%private(let _NEGATIVE_ONE = fromInt(-1))

external \"~-": t => t = "%negfloat"
external \"+": (t, t) => t = "%addfloat"
external \"-": (t, t) => t = "%subfloat"
external \"*": (t, t) => t = "%mulfloat"
external \"/": (t, t) => t = "%divfloat"
let mod: (t, t) => t = Obj.magic(mod_float)
let \"**": (t, t) => t = %raw(`function (a, b) { return (a ** b); }`)
external land: (t, t) => t = "%andint"
external lor: (t, t) => t = "%orint"
external lxor: (t, t) => t = "%xorint"
let lnot: t => t = x => lxor(x, _NEGATIVE_ONE)
external lsl: (t, t) => t = "%lslint"
external asr: (t, t) => t = "%asrint"

external negate: t => t = "%negfloat"
external add: (t, t) => t = "%addfloat"
external subtract: (t, t) => t = "%subfloat"
external multiply: (t, t) => t = "%mulfloat"
external divide: (t, t) => t = "%divfloat"
let modulo: (t, t) => t = Obj.magic(mod_float)
let power: (t, t) => t = \"**"
external logicalAnd: (t, t) => t = "%andint"
external logicalOr: (t, t) => t = "%orint"
external logicalXor: (t, t) => t = "%xorint"
let logicalNot: t => t = x => lxor(x, _NEGATIVE_ONE)
external logicalShiftLeft: (t, t) => t = "%lslint"
external arithmeticShiftRight: (t, t) => t = "%asrint"
159 changes: 159 additions & 0 deletions src/BinaryLike.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 984fe4a

Please sign in to comment.