Skip to content

Add Env wrapper APIs#44

Open
richerfu wants to merge 1 commit into
mainfrom
codex/env-wrapper-api
Open

Add Env wrapper APIs#44
richerfu wants to merge 1 commit into
mainfrom
codex/env-wrapper-api

Conversation

@richerfu
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown

zig-napi ArkVM benchmark

  • Generated: 2026-05-28T02:22:15Z
  • Status: ZIG_NAPI_BENCHMARK_RESULT status=ok
module api content iterations native C N-API avg (us) zig-napi avg (us) diff (us) ratio
global function void(*)() 100000 0.104 0.109 0.005 1.047x
primitive i32(i32, i32) 100000 0.136 0.141 0.005 1.037x
primitive bool(bool) 100000 0.128 0.131 0.003 1.025x
string len(string) 100000 0.157 0.156 -0.001 0.991x
object read properties 100000 0.324 0.33 0.006 1.017x
array sum(number[]) 100000 0.645 0.617 -0.028 0.957x
function call callback 100000 0.276 0.285 0.009 1.031x
class constructor 20000 0.966 4.455 3.489 4.611x
class getter 100000 0.227 0.222 -0.006 0.975x
class setter 100000 0.43 0.416 -0.013 0.969x
class method 100000 0.245 0.241 -0.004 0.983x
ArrayBuffer constructor 20000 0.317 0.373 0.056 1.177x
ArrayBuffer byteLength 100000 0.158 0.161 0.003 1.018x
Buffer constructor 20000 0.902 0.763 -0.139 0.846x
Buffer length 100000 0.16 0.163 0.003 1.019x
TypedArray Uint8Array constructor 20000 0.699 0.867 0.168 1.24x
TypedArray Uint8Array sum 100000 0.194 0.22 0.026 1.136x
DataView constructor 20000 0.423 0.446 0.023 1.055x
DataView byteLength 100000 0.156 0.194 0.037 1.239x

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds higher-level Env wrapper methods for common N-API utilities (version, global, symbol, date, exception handling) and exposes the existing NapiValue type as a public API, wiring it through the value-conversion utilities so it can be used as a function argument/return type.

Changes:

  • Adds getNapiVersion, getGlobal, createSymbol, createDate (v5-gated), isExceptionPending, and getAndClearLastException methods on Env.
  • Exports NapiValue from the public napi module.
  • Teaches Napi.valueMatchesType, from_napi_value, to_napi_value, and the no-deinit list about NapiValue.NapiValue.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/napi/env.zig New Env wrapper methods for version, global, symbol, date, and exception helpers.
src/napi.zig Re-exports NapiValue from the public API.
src/napi/util/napi.zig Adds NapiValue handling to type matching, deinit no-op list, and from/to napi conversion paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants