Skip to content

Commit 79d46dc

Browse files
committed
Add doc for String and Symbol string_view constructors
1 parent 9deb2e2 commit 79d46dc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

doc/string.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Napi::String::New(napi_env env, const char* value);
6060
Napi::String::New(napi_env env, const char16_t* value);
6161
Napi::String::New(napi_env env, const char* value, size_t length);
6262
Napi::String::New(napi_env env, const char16_t* value, size_t length);
63+
Napi::String::New(napi_env env, std::string_view value);
6364
```
6465
6566
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Value` object.
@@ -68,6 +69,7 @@ Napi::String::New(napi_env env, const char16_t* value, size_t length);
6869
- `std::u16string&` - represents a UTF16-LE string.
6970
- `const char*` - represents a UTF8 string.
7071
- `const char16_t*` - represents a UTF16-LE string.
72+
- `std::string_view` - represents a UTF8 string view.
7173
- `[in] length`: The length of the string (not necessarily null-terminated) in code units.
7274
7375
Returns a new `Napi::String` that represents the passed in C++ string.

doc/symbol.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Returns a new empty `Napi::Symbol`.
1818
```cpp
1919
Napi::Symbol::New(napi_env env, const std::string& description);
2020
Napi::Symbol::New(napi_env env, const char* description);
21+
Napi::Symbol::New(napi_env env, std::string_view description);
2122
Napi::Symbol::New(napi_env env, Napi::String description);
2223
Napi::Symbol::New(napi_env env, napi_value description);
2324
```
@@ -27,6 +28,7 @@ Napi::Symbol::New(napi_env env, napi_value description);
2728
`description` may be any of:
2829
- `std::string&` - UTF8 string description.
2930
- `const char*` - represents a UTF8 string description.
31+
- `std::string_view` - represents a UTF8 string view.
3032
- `String` - Node addon API String description.
3133
- `napi_value` - Node-API `napi_value` description.
3234
@@ -58,4 +60,4 @@ static Napi::Symbol Napi::Symbol::For(napi_env env, napi_value description);
5860
5961
Searches in the global registry for existing symbol with the given name. If the symbol already exist it will be returned, otherwise a new symbol will be created in the registry. It's equivalent to Symbol.for() called from JavaScript.
6062
61-
[`Napi::Name`]: ./name.md
63+
[`Napi::Name`]: ./name.md

0 commit comments

Comments
 (0)