Skip to content

tiny and fast napi bindings for zig

License

Notifications You must be signed in to change notification settings

evanwashere/napi.zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

napi.zig

tiny and fast node-api bindings for zig

Features

  • 🚀 async functions run in parallel
  • ⛓️ expose c and zig functions to js
  • 🔨 does not require node-gyp to build
  • [WIP] ✨ seamless serde between js and zig types
  • 🎯 compile to any architecture with zig cross-compilation

Examples

more examples in examples/ folder

const std = @import("std");
const napi = @import("./src/napi.zig");
const allocator = std.heap.c_allocator;

comptime {
  napi.register(init);
}

fn init(env: napi.env, exports: napi.object) !void {
  try exports.set(env, "add", try napi.bind.function(env, add, "add", allocator));
}

fn add(a: u32, b: u32) u32 {
  return a + b;
}

License

MIT © Evan