Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
toyobayashi committed Jun 16, 2021
1 parent 214e2d6 commit e3cff10
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ Module.onRuntimeInitialized = function () {

Alternatively, you can also use [`node-addon-api`](https://github.com/nodejs/node-addon-api) which is official Node-API C++ wrapper, already shipped in this package but without Node.js specific API such as `ThreadSafeFunction`, `AsyncWorker`, etc.

**Note: C++ wrapper can only be used to target Node.js v14.6.0+ and modern browsers those support `FinalizationRegistry` and `WeakRef` ([v8 engine v8.4+](https://v8.dev/blog/v8-release-84))!**

Create `hello.cpp`.

```cpp
Expand Down Expand Up @@ -240,7 +242,7 @@ These APIs always return `napi_generic_failure`.

### Limited

* These APIs require [FinalizationRegistry](https://www.caniuse.com/?search=FinalizationRegistry) [WeakRef](https://www.caniuse.com/?search=WeakRef)
* These APIs require [FinalizationRegistry](https://www.caniuse.com/?search=FinalizationRegistry) and [WeakRef](https://www.caniuse.com/?search=WeakRef) (v8 engine v8.4+ / Node.js v14.6.0+)

- [x] ***napi_wrap***
- [x] ***napi_unwrap***
Expand All @@ -254,21 +256,22 @@ These APIs always return `napi_generic_failure`.
- [x] ***napi_get_reference_value***
- [x] ***napi_add_finalizer***

* These APIs always return `NULL` data pointer

- [x] ***napi_create_arraybuffer***
- [x] ***napi_get_arraybuffer_info***
- [x] ***napi_get_typedarray_info***
- [x] ***napi_get_dataview_info***

* These APIs require [BigInt](https://www.caniuse.com/?search=BigInt)
* These APIs require [BigInt](https://www.caniuse.com/?search=BigInt) (v8 engine v6.7+ / Node.js v10.4.0+)

- [x] ***napi_create_bigint_int64***
- [x] ***napi_create_bigint_uint64***
- [x] ***napi_create_bigint_words***
- [x] ***napi_get_value_bigint_int64***
- [x] ***napi_get_value_bigint_uint64***
- [x] ***napi_get_value_bigint_words***

* These APIs always return `NULL` data pointer (No way to implement in JS)

- [x] ***napi_create_arraybuffer***
- [x] ***napi_get_arraybuffer_info***
- [x] ***napi_get_typedarray_info***
- [x] ***napi_get_dataview_info***

### Stable

- [x] napi_get_last_error_info
Expand Down
20 changes: 11 additions & 9 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Module.onRuntimeInitialized = function () {

也可以用官方的 C++ wrapper [`node-addon-api`](https://github.com/nodejs/node-addon-api),它已被集成在这个包里,但不可使用 Node.js 环境特定的 API,如 `ThreadSafeFunction`, `AsyncWorker` 等等。

**特别注意: C++ wrapper 只能用于 Node.js v14.6.0+ 和支持 `FinalizationRegistry``WeakRef` 的现代浏览器([v8 引擎 v8.4+](https://v8.dev/blog/v8-release-84))!**

创建 `hello.cpp`

```cpp
Expand Down Expand Up @@ -236,7 +238,7 @@ npm test

### 能力受限的 API

* 需要 [FinalizationRegistry](https://www.caniuse.com/?search=FinalizationRegistry)[WeakRef](https://www.caniuse.com/?search=WeakRef) 的 API:
* 需要 [FinalizationRegistry](https://www.caniuse.com/?search=FinalizationRegistry)[WeakRef](https://www.caniuse.com/?search=WeakRef) 的 API:(v8 引擎 v8.4+ / Node.js v14.6.0+)

- [x] ***napi_wrap***
- [x] ***napi_unwrap***
Expand All @@ -250,14 +252,7 @@ npm test
- [x] ***napi_get_reference_value***
- [x] ***napi_add_finalizer***

* `data` 指针返回值永远为 `NULL` 的 API:

- [x] ***napi_create_arraybuffer***
- [x] ***napi_get_arraybuffer_info***
- [x] ***napi_get_typedarray_info***
- [x] ***napi_get_dataview_info***

* 需要 [BigInt](https://www.caniuse.com/?search=BigInt) 的 API:
* 需要 [BigInt](https://www.caniuse.com/?search=BigInt) 的 API:(v8 引擎 v6.7+ / Node.js v10.4.0+)

- [x] ***napi_create_bigint_int64***
- [x] ***napi_create_bigint_uint64***
Expand All @@ -266,6 +261,13 @@ npm test
- [x] ***napi_get_value_bigint_uint64***
- [x] ***napi_get_value_bigint_words***

* `data` 指针返回值永远为 `NULL` 的 API:(JS 无法实现)

- [x] ***napi_create_arraybuffer***
- [x] ***napi_get_arraybuffer_info***
- [x] ***napi_get_typedarray_info***
- [x] ***napi_get_dataview_info***

### 稳定的 API

- [x] napi_get_last_error_info
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tybys/emnapi",
"version": "0.1.0",
"version": "0.1.1",
"description": "Node-API implementation for Emscripten",
"main": "index.js",
"typings": "index.d.ts",
Expand Down

0 comments on commit e3cff10

Please sign in to comment.