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
+49-26Lines changed: 49 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,39 @@
1
-
2
1
The `node-api` Zig package provides [Node-API](https://nodejs.org/api/n-api.html) bindings for writing idiomatic Zig addons for V8-based runtimes like Node.JS or Bun.
3
2
Thanks to its conventions-based approach it bridges the gap seamlessly, with almost no Node-API specific code!
Struct types, functions, fields, parameters and return values are all converted by convention.
65
92
Unsupported types result in compile errors.
66
93
67
-
|Native type|Node type|Remarks|
68
-
|-|-|-|
69
-
|`type`|`Class` or `Function`|Returning or passing a struct `type` to JS, turns it into a class.<br>Returning or passing a `fn`, turns it into a JS-callable, well, function. |
70
-
|`i32`,`i64`,`u32`|`number`||
71
-
|`u64`|`BigInt`||
72
-
|`[]const u8`, `[]u8`|`string`|UTF-8|
73
-
|`[]const T`, `[]T`|`array`||
74
-
|`*T`|`Object`|Passing struct pointers to JS will wrap & track them.|
75
-
|`NodeValue`|`any`|NodeValue can be used to access JS values by reference.|
|`type`|`Class` or `Function`|Returning or passing a struct `type` to JS, turns it into a class.<br>Returning or passing a `fn`, turns it into a JS-callable, well, function. |
97
+
|`i32`,`i64`,`u32`|`number`||
98
+
|`u64`|`BigInt`||
99
+
|`[]const u8`, `[]u8`|`string`|UTF-8|
100
+
|`[]const T`, `[]T`|`array`||
101
+
|`*T`|`Object`|Passing struct pointers to JS will wrap & track them.|
102
+
|`NodeValue`|`any`|NodeValue can be used to access JS values by reference.|
76
103
77
104
Function parameters and return types can be
105
+
78
106
- native Zig types (unsupported types will result in compile time errors)
79
107
- one of the NodeValue types to access values by reference.
80
108
81
109
Native values and NodeValue instance can be converted using `Convert`:
0 commit comments