You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@
44
44
-__Async:__ Support Async Rust. Async codes are translated into Node.js promises.
45
45
-__Class:__ Rust struct can be accessed using Node.js classes.
46
46
-__Stream:__ Implement Node.js stream using Rust
47
-
-__N-API:__ Use Node.js N-API, which means you don't have to recompile your module.
47
+
-__N-API:__ Use Node.js N-API, which means you don't have to recompile your module.
48
48
49
49
# Compatibility with Node.js version
50
50
@@ -59,7 +59,7 @@ Following OS are supported:
59
59
60
60
# Why node-bindgen?
61
61
62
-
Writing native node-js requires lots of boilerplate code. Node-bindgen generates external "C" glue code from rust code, including native module registration. node-bindgen make it writing node-js module easy and fun.
62
+
Writing native node-js requires lots of boilerplate code. Node-bindgen generates external "C" glue code from rust code, including native module registration. node-bindgen make it writing node-js module easy and fun.
63
63
64
64
65
65
# Getting started
@@ -76,18 +76,18 @@ This is one time step.
76
76
77
77
## Configuring Cargo.toml
78
78
79
-
Add two dependencies to your projects' ```Cargo.toml```.
79
+
Add two dependencies to your projects' ```Cargo.toml```.
80
80
81
81
Add ```node-bindgen``` as a regular dependency (as below):
82
82
```
83
83
[dependencies]
84
-
node-bindgen = { version = "3.0.0" }
84
+
node-bindgen = { version = "4.0" }
85
85
```
86
86
87
87
Then add ```node-bindgen```'s procedure macro to your build-dependencies as below:
88
88
```
89
89
[build-dependencies]
90
-
node-bindgen = { version = "3.0.0", features = ["build"] }
90
+
node-bindgen = { version = "4.0", features = ["build"] }
91
91
```
92
92
93
93
Then update crate type to ```cdylib``` to generate node.js compatible native module:
@@ -116,7 +116,7 @@ use node_bindgen::derive::node_bindgen;
116
116
117
117
/// add two integer
118
118
#[node_bindgen]
119
-
fnsum(first:i32, second:i32) ->i32 {
119
+
fnsum(first:i32, second:i32) ->i32 {
120
120
first+second
121
121
}
122
122
@@ -141,7 +141,7 @@ nj-cli build --release
141
141
142
142
While developing your native module, you may want to watch for file changes and run a command when a change occurs, for example `cargo check` or `cargo build`.
143
143
144
-
For this, we can use `nj-cli watch`.
144
+
For this, we can use `nj-cli watch`.
145
145
146
146
`nj-cli watch` installs <small>[if it does not exist]</small> and passes arguments to [`cargo watch`](https://crates.io/crates/cargo-watch). By default, `nj-cli watch` will run `cargo check` against your `./src` files.
147
147
@@ -161,7 +161,7 @@ Type ".help" for more information.
161
161
undefined
162
162
>addon.sum(2,3)
163
163
5
164
-
>
164
+
>
165
165
```
166
166
167
167
@@ -171,8 +171,8 @@ undefined
171
171
172
172
```rust
173
173
#[node_bindgen(name="multiply")]
174
-
fnmul(first:i32,second:i32) ->i32 {
175
-
first*second
174
+
fnmul(first:i32,second:i32) ->i32 {
175
+
first*second
176
176
}
177
177
```
178
178
@@ -183,7 +183,7 @@ Rust function mul is re-mapped as ```multiply```
183
183
Argument can be skipped if it is marked as optional
184
184
```rust
185
185
#[node_bindgen]
186
-
fnsum(first:i32, second:Option<i32>) ->i32 {
186
+
fnsum(first:i32, second:Option<i32>) ->i32 {
187
187
first+second.unwrap_or(0)
188
188
}
189
189
```
@@ -293,7 +293,7 @@ There are more features in the examples folder.
293
293
## Windows + Electron Support
294
294
When using node-bindgen with electron on Windows, `nj-build` must
295
295
compile a C++ file, `win_delay_load_hook.cc`, and therefore it is required that the development
296
-
environment has a valid C/C++ compiler.
296
+
environment has a valid C/C++ compiler.
297
297
298
298
> If your machine does not have a valid C/C++ compiler, install [Microsoft VSCode](https://code.visualstudio.com/docs/cpp/config-mingw).
0 commit comments