diff --git a/doc/object.md b/doc/object.md index 8aa872dc3..677ff5532 100644 --- a/doc/object.md +++ b/doc/object.md @@ -288,6 +288,34 @@ Napi::Value Napi::Object::operator[] (uint32_t index) const; Returns an indexed property or array element as a [`Napi::Value`](value.md). +### begin() + +```cpp +Napi::Object::iterator Napi::Object::begin() const; +``` + +Returns a constant iterator to the beginning of the object. + +```cpp +Napi::Object::iterator Napi::Object::begin(); +``` + +Returns a non constant iterator to the beginning of the object. + +### end() + +```cpp +Napi::Object::iterator Napi::Object::end() const; +``` + +Returns a constant iterator to the end of the object. + +```cpp +Napi::Object::iterator Napi::Object::end(); +``` + +Returns a non constant iterator to the end of the object. + ## Iterator Iterators expose an `std::pair<...>`, where the `first` property is a @@ -300,6 +328,41 @@ exceptions are enabled (by defining `NAPI_CPP_EXCEPTIONS` during the build). In constant iterators, the iterated values are immutable. +#### operator++() + +```cpp +inline Napi::Object::const_iterator& Napi::Object::const_iterator::operator++(); +``` + +Moves the iterator one step forward. + +#### operator== + +```cpp +inline bool Napi::Object::const_iterator::operator==(const Napi::Object::const_iterator& other) const; +``` +- `[in] other`: Another iterator to compare the current iterator to. + +Returns whether both iterators are at the same index. + +#### operator!= + +```cpp +inline bool Napi::Object::const_iterator::operator!=(const Napi::Object::const_iterator& other) const; +``` +- `[in] other`: Another iterator to compare the current iterator to. + +Returns whether both iterators are at different indices. + +#### operator*() + +```cpp +inline const std::pair> Napi::Object::const_iterator::operator*() const; +``` + +Returns the currently iterated key and value. + +#### Example ```cpp Value Sum(const CallbackInfo& info) { Object object = info[0].As(); @@ -317,6 +380,41 @@ Value Sum(const CallbackInfo& info) { In non constant iterators, the iterated values are mutable. +#### operator++() + +```cpp +inline Napi::Object::iterator& Napi::Object::iterator::operator++(); +``` + +Moves the iterator one step forward. + +#### operator== + +```cpp +inline bool Napi::Object::iterator::operator==(const Napi::Object::iterator& other) const; +``` +- `[in] other`: Another iterator to compare the current iterator to. + +Returns whether both iterators are at the same index. + +#### operator!= + +```cpp +inline bool Napi::Object::iterator::operator!=(const Napi::Object::iterator& other) const; +``` +- `[in] other`: Another iterator to compare the current iterator to. + +Returns whether both iterators are at different indices. + +#### operator*() + +```cpp +inline std::pair> Napi::Object::iterator::operator*(); +``` + +Returns the currently iterated key and value. + +#### Example ```cpp void Increment(const CallbackInfo& info) { Env env = info.Env();