[Pkg-javascript-commits] [node-nan] 01/01: New upstream version 2.8.0
Jérémy Lal
kapouer at moszumanska.debian.org
Wed Nov 22 21:40:08 UTC 2017
This is an automated email from the git hooks/post-receive script.
kapouer pushed a commit to annotated tag upstream/2.8.0
in repository node-nan.
commit 95eb717dab48a2475161a4ee9ff72ba0d1e4c3f0
Author: Jérémy Lal <kapouer at melix.org>
Date: Wed Nov 22 22:36:18 2017 +0100
New upstream version 2.8.0
---
.travis.yml | 4 +-
CHANGELOG.md | 14 +-
Makefile | 2 +
README.md | 13 +-
appveyor.yml | 2 +
doc/asyncworker.md | 37 +++-
doc/errors.md | 12 +-
doc/maybe_types.md | 94 ++++----
doc/methods.md | 8 +-
doc/new.md | 8 +-
doc/persistent.md | 12 +-
doc/scopes.md | 2 +-
doc/script.md | 2 +-
doc/v8_internals.md | 30 +--
doc/v8_misc.md | 8 +-
examples/async_pi_estimate/async.cc | 2 +-
nan.h | 243 ++++++++++++++++-----
nan_json.h | 6 +-
nan_maybe_43_inl.h | 20 +-
nan_maybe_pre_43_inl.h | 15 +-
package.json | 9 +-
test/binding.gyp | 8 +
...ressworker.cpp => asyncprogressqueueworker.cpp} | 35 ++-
...ream.cpp => asyncprogressqueueworkerstream.cpp} | 36 ++-
test/cpp/asyncprogressworker.cpp | 9 +-
test/cpp/asyncprogressworkersignal.cpp | 9 +-
test/cpp/asyncprogressworkerstream.cpp | 9 +-
test/cpp/asyncworker.cpp | 2 +-
test/cpp/asyncworkererror.cpp | 2 +-
test/cpp/bufferworkerpersistent.cpp | 4 +-
test/cpp/json-stringify.cpp | 2 +-
test/cpp/nancallback.cpp | 20 +-
test/cpp/persistent.cpp | 6 +-
test/cpp/private.cpp | 2 +-
test/cpp/returnvalue.cpp | 2 +-
test/cpp/weak.cpp | 4 +-
test/cpp/weak2.cpp | 2 +-
...er-test.js => asyncprogressqueueworker-test.js} | 9 +-
test/js/asyncprogressqueueworkerstream-test.js | 54 +++++
test/js/asyncprogressworker-test.js | 1 +
40 files changed, 532 insertions(+), 227 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 2b734ae..49312e5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,9 +20,7 @@ env:
- TRAVIS_NODE_VERSION="6"
- TRAVIS_NODE_VERSION="7"
- TRAVIS_NODE_VERSION="8"
-notifications:
- email:
- - rod at vagg.org
+ - TRAVIS_NODE_VERSION="9"
install:
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea3b70f..4e04975 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,19 @@
# NAN ChangeLog
-**Version 2.7.0: current Node 8.4.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1**
+**Version 2.8.0: current Node 9.2.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1**
+
+### 2.8.0 Nov 15 2017
+
+ - Deprecation: Deprecate `Nan::ForceSet` in favor of `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
+ - Feature: Add `Nan::AsyncProgressQueueWorker` a976636ecc2ef617d1b061ce4a6edf39923691cb
+ - Feature: Add `Nan::DefineOwnProperty()` 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
+ - Bugfix: Fix compiling on io.js 1 & 2 82705a64503ce60c62e98df5bd02972bba090900
+ - Bugfix: Use DefineOwnProperty instead of ForceSet 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
### 2.7.0 Aug 30 2017
- - Feature: Add Nan::To<v8::Function>() overload. b93280670c9f6da42ed4cf6cbf085ffdd87bd65b
- - Bugfix: Fix ternary in Nan::MaybeLocal<T>::FromMaybe<S>(). 79a26f7d362e756a9524e672a82c3d603b542867
+ - Feature: Add `Nan::To<v8::Function>()` overload. b93280670c9f6da42ed4cf6cbf085ffdd87bd65b
+ - Bugfix: Fix ternary in `Nan::MaybeLocal<T>::FromMaybe<S>()`. 79a26f7d362e756a9524e672a82c3d603b542867
### 2.6.2 Apr 12 2017
diff --git a/Makefile b/Makefile
index a1e40e2..fc164f8 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,8 @@ LINT_SOURCES = \
test/cpp/asyncprogressworker.cpp \
test/cpp/asyncprogressworkerstream.cpp \
test/cpp/asyncprogressworkersignal.cpp \
+ test/cpp/asyncprogressqueueworker.cpp \
+ test/cpp/asyncprogressqueueworkerstream.cpp \
test/cpp/asyncworkererror.cpp \
test/cpp/buffer.cpp \
test/cpp/bufferworkerpersistent.cpp \
diff --git a/README.md b/README.md
index 2a9bea4..a93d391 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
Native Abstractions for Node.js
===============================
-**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 7 and 8.**
+**A header file filled with macro and utility goodness for making add-on development for Node.js easier across versions 0.8, 0.10, 0.12, 1, 2, 3, 4, 5, 6, 7, 8 and 9.**
-***Current version: 2.7.0***
+***Current version: 2.8.0***
*(See [CHANGELOG.md](https://github.com/nodejs/nan/blob/master/CHANGELOG.md) for complete ChangeLog)*
@@ -76,7 +76,7 @@ Additional to the NAN documentation below, please consult:
### JavaScript-accessible methods
-A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://developers.google.com/v8/embed#templates) for further information.
+A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
@@ -174,7 +174,8 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="doc/maybe_types.md#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_set"><b><code>Nan::Set()</code></b></a>
- - <a href="doc/maybe_types.md#api_nan_force_set"><b><code>Nan::ForceSet()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
+ - <a href="doc/maybe_types.md#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
- <a href="doc/maybe_types.md#api_nan_get"><b><code>Nan::Get()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
- <a href="doc/maybe_types.md#api_nan_has"><b><code>Nan::Has()</code></b></a>
@@ -258,10 +259,11 @@ NAN's `node::Buffer` helpers exist as the API has changed across supported Node
### Asynchronous work helpers
-`Nan::AsyncWorker` and `Nan::AsyncProgressWorker` are helper classes that make working with asynchronous code easier.
+`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
- <a href="doc/asyncworker.md#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
- <a href="doc/asyncworker.md#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker</code></b></a>
+ - <a href="doc/asyncworker.md#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
- <a href="doc/asyncworker.md#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
### Strings & Bytes
@@ -415,6 +417,7 @@ By making a contribution to this project, I certify that:
<tr><th align="left">Brett Lawson</th><td><a href="https://github.com/brett19">GitHub/brett19</a></td><td><a href="http://twitter.com/brett19x">Twitter/@brett19x</a></td></tr>
<tr><th align="left">Ben Noordhuis</th><td><a href="https://github.com/bnoordhuis">GitHub/bnoordhuis</a></td><td><a href="http://twitter.com/bnoordhuis">Twitter/@bnoordhuis</a></td></tr>
<tr><th align="left">David Siegel</th><td><a href="https://github.com/agnat">GitHub/agnat</a></td><td><a href="http://twitter.com/agnat">Twitter/@agnat</a></td></tr>
+<tr><th align="left">Michael Ira Krufky</th><td><a href="https://github.com/mkrufky">GitHub/mkrufky</a></td><td><a href="http://twitter.com/mkrufky">Twitter/@mkrufky</a></td></tr>
</tbody></table>
## Licence & copyright
diff --git a/appveyor.yml b/appveyor.yml
index 40d95d4..5484aa8 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -12,12 +12,14 @@ environment:
- nodejs_version: "6"
- nodejs_version: "7"
- nodejs_version: "8"
+ - nodejs_version: "9"
# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node 0.STABLE.latest
- ps: Install-Product node $env:nodejs_version
- IF %nodejs_version% LSS 4 npm -g install npm at 2
+ - IF %nodejs_version% EQU 5 npm -g install npm at 3
- set PATH=%APPDATA%\npm;%PATH%
# Typical npm stuff.
- npm install
diff --git a/doc/asyncworker.md b/doc/asyncworker.md
index 86a023f..b75cb4b 100644
--- a/doc/asyncworker.md
+++ b/doc/asyncworker.md
@@ -1,9 +1,10 @@
## Asynchronous work helpers
-`Nan::AsyncWorker` and `Nan::AsyncProgressWorker` are helper classes that make working with asynchronous code easier.
+`Nan::AsyncWorker`, `Nan::AsyncProgressWorker` and `Nan::AsyncProgressQueueWorker` are helper classes that make working with asynchronous code easier.
- <a href="#api_nan_async_worker"><b><code>Nan::AsyncWorker</code></b></a>
- <a href="#api_nan_async_progress_worker"><b><code>Nan::AsyncProgressWorkerBase & Nan::AsyncProgressWorker</code></b></a>
+ - <a href="#api_nan_async_progress_queue_worker"><b><code>Nan::AsyncProgressQueueWorker</code></b></a>
- <a href="#api_nan_async_queue_worker"><b><code>Nan::AsyncQueueWorker</code></b></a>
<a name="api_nan_async_worker"></a>
@@ -64,6 +65,8 @@ class AsyncWorker {
Previously the definiton of `Nan::AsyncProgressWorker` only allowed sending `const char` data. Now extending `Nan::AsyncProgressWorker` will yield an instance of the implicit `Nan::AsyncProgressWorkerBase` template with type `<char>` for compatibility.
+`Nan::AsyncProgressWorkerBase` & `Nan::AsyncProgressWorker` is intended for best-effort delivery of nonessential progress messages, e.g. a progress bar. The last event sent before the main thread is woken will be delivered.
+
Definition:
```c++
@@ -92,6 +95,38 @@ class AsyncProgressWorkerBase<T> : public AsyncWorker {
typedef AsyncProgressWorkerBase<T> AsyncProgressWorker;
```
+<a name="api_nan_async_progress_queue_worker"></a>
+### Nan::AsyncProgressQueueWorker
+
+`Nan::AsyncProgressQueueWorker` is an _abstract_ class template that extends `Nan::AsyncWorker` and adds additional progress reporting callbacks that can be used during the asynchronous work execution to provide progress data back to JavaScript.
+
+`Nan::AsyncProgressQueueWorker` behaves exactly the same as `Nan::AsyncProgressWorker`, except all events are queued and delivered to the main thread.
+
+Definition:
+
+```c++
+template<class T>
+class AsyncProgressQueueWorker<T> : public AsyncWorker {
+ public:
+ explicit AsyncProgressQueueWorker(Callback *callback_);
+
+ virtual ~AsyncProgressQueueWorker();
+
+ void WorkProgress();
+
+ class ExecutionProgress {
+ public:
+ void Send(const T* data, size_t count) const;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+
+ virtual void HandleProgressCallback(const T *data, size_t count) = 0;
+
+ virtual void Destroy();
+};
+```
+
<a name="api_nan_async_queue_worker"></a>
### Nan::AsyncQueueWorker
diff --git a/doc/errors.md b/doc/errors.md
index aac6e08..b93b353 100644
--- a/doc/errors.md
+++ b/doc/errors.md
@@ -24,7 +24,7 @@ Also consult the V8 Embedders Guide section on [Exceptions](https://developers.g
<a name="api_nan_error"></a>
### Nan::Error()
-Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.0/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+Create a new Error object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an Error object is simply a specialized form of `v8::Value`.
@@ -39,7 +39,7 @@ v8::Local<v8::Value> Nan::Error(v8::Local<v8::String> msg);
<a name="api_nan_range_error"></a>
### Nan::RangeError()
-Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.0/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+Create a new RangeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an RangeError object is simply a specialized form of `v8::Value`.
@@ -54,7 +54,7 @@ v8::Local<v8::Value> Nan::RangeError(v8::Local<v8::String> msg);
<a name="api_nan_reference_error"></a>
### Nan::ReferenceError()
-Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.0/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+Create a new ReferenceError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an ReferenceError object is simply a specialized form of `v8::Value`.
@@ -69,7 +69,7 @@ v8::Local<v8::Value> Nan::ReferenceError(v8::Local<v8::String> msg);
<a name="api_nan_syntax_error"></a>
### Nan::SyntaxError()
-Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.0/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+Create a new SyntaxError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an SyntaxError object is simply a specialized form of `v8::Value`.
@@ -84,7 +84,7 @@ v8::Local<v8::Value> Nan::SyntaxError(v8::Local<v8::String> msg);
<a name="api_nan_type_error"></a>
### Nan::TypeError()
-Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.0/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
+Create a new TypeError object using the [v8::Exception](https://v8docs.nodesource.com/io.js-3.3/da/d6a/classv8_1_1_exception.html) class in a way that is compatible across the supported versions of V8.
Note that an TypeError object is simply a specialized form of `v8::Value`.
@@ -194,7 +194,7 @@ v8::Local<v8::Value> Nan::ErrnoException(int errorno,
<a name="api_nan_try_catch"></a>
### Nan::TryCatch
-A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/io.js-3.0/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
+A simple wrapper around [`v8::TryCatch`](https://v8docs.nodesource.com/io.js-3.3/d4/dc6/classv8_1_1_try_catch.html) compatible with all supported versions of V8. Can be used as a direct replacement in most cases. See also [`Nan::FatalException()`](#api_nan_fatal_exception) for an internal use compatible with `node::FatalException`.
Signature:
diff --git a/doc/maybe_types.md b/doc/maybe_types.md
index 818861d..5baa2cf 100644
--- a/doc/maybe_types.md
+++ b/doc/maybe_types.md
@@ -15,7 +15,8 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
- <a href="#api_nan_new_instance"><b><code>Nan::NewInstance()</code></b></a>
- <a href="#api_nan_get_function"><b><code>Nan::GetFunction()</code></b></a>
- <a href="#api_nan_set"><b><code>Nan::Set()</code></b></a>
- - <a href="#api_nan_force_set"><b><code>Nan::ForceSet()</code></b></a>
+ - <a href="#api_nan_define_own_property"><b><code>Nan::DefineOwnProperty()</code></b></a>
+ - <a href="#api_nan_force_set"><del><b><code>Nan::ForceSet()</code></b></del></a>
- <a href="#api_nan_get"><b><code>Nan::Get()</code></b></a>
- <a href="#api_nan_get_property_attribute"><b><code>Nan::GetPropertyAttributes()</code></b></a>
- <a href="#api_nan_has"><b><code>Nan::Has()</code></b></a>
@@ -46,7 +47,7 @@ The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Lo
<a name="api_nan_maybe_local"></a>
### Nan::MaybeLocal
-A `Nan::MaybeLocal<T>` is a wrapper around [`v8::Local<T>`](https://v8docs.nodesource.com/io.js-3.0/de/deb/classv8_1_1_local.html) that enforces a check that determines whether the `v8::Local<T>` is empty before it can be used.
+A `Nan::MaybeLocal<T>` is a wrapper around [`v8::Local<T>`](https://v8docs.nodesource.com/io.js-3.3/de/deb/classv8_1_1_local.html) that enforces a check that determines whether the `v8::Local<T>` is empty before it can be used.
If an API method returns a `Nan::MaybeLocal`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, an empty `Nan::MaybeLocal` is returned.
@@ -70,7 +71,7 @@ template<typename T> class Nan::MaybeLocal {
};
```
-See the documentation for [`v8::MaybeLocal`](https://v8docs.nodesource.com/io.js-3.0/d8/d7d/classv8_1_1_maybe_local.html) for further details.
+See the documentation for [`v8::MaybeLocal`](https://v8docs.nodesource.com/io.js-3.3/d8/d7d/classv8_1_1_maybe_local.html) for further details.
<a name="api_nan_maybe"></a>
### Nan::Maybe
@@ -98,7 +99,7 @@ template<typename T> class Nan::Maybe {
};
```
-See the documentation for [`v8::Maybe`](https://v8docs.nodesource.com/io.js-3.0/d9/d4b/classv8_1_1_maybe.html) for further details.
+See the documentation for [`v8::Maybe`](https://v8docs.nodesource.com/io.js-3.3/d9/d4b/classv8_1_1_maybe.html) for further details.
<a name="api_nan_nothing"></a>
### Nan::Nothing
@@ -121,7 +122,7 @@ template<typename T> Nan::Maybe<T> Nan::Just(const T &t);
<a name="api_nan_call"></a>
### Nan::Call()
-A helper method for calling [`v8::Function#Call()`](https://v8docs.nodesource.com/io.js-3.0/d5/d54/classv8_1_1_function.html#a468a89f737af0612db10132799c827c0) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Function#Call()`](https://v8docs.nodesource.com/io.js-3.3/d5/d54/classv8_1_1_function.html#a468a89f737af0612db10132799c827c0) in a way compatible across supported versions of V8.
Signature:
@@ -133,7 +134,7 @@ Nan::MaybeLocal<v8::Value> Nan::Call(v8::Local<v8::Function> fun, v8::Local<v8::
<a name="api_nan_to_detail_string"></a>
### Nan::ToDetailString()
-A helper method for calling [`v8::Value#ToDetailString()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Value#ToDetailString()`](https://v8docs.nodesource.com/io.js-3.3/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5) in a way compatible across supported versions of V8.
Signature:
@@ -145,7 +146,7 @@ Nan::MaybeLocal<v8::String> Nan::ToDetailString(v8::Local<v8::Value> val);
<a name="api_nan_to_array_index"></a>
### Nan::ToArrayIndex()
-A helper method for calling [`v8::Value#ToArrayIndex()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#acc5bbef3c805ec458470c0fcd6f13493) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Value#ToArrayIndex()`](https://v8docs.nodesource.com/io.js-3.3/dc/d0a/classv8_1_1_value.html#acc5bbef3c805ec458470c0fcd6f13493) in a way compatible across supported versions of V8.
Signature:
@@ -157,7 +158,7 @@ Nan::MaybeLocal<v8::Uint32> Nan::ToArrayIndex(v8::Local<v8::Value> val);
<a name="api_nan_equals"></a>
### Nan::Equals()
-A helper method for calling [`v8::Value#Equals()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#a0d9616ab2de899d4e3047c30a10c9285) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Value#Equals()`](https://v8docs.nodesource.com/io.js-3.3/dc/d0a/classv8_1_1_value.html#a0d9616ab2de899d4e3047c30a10c9285) in a way compatible across supported versions of V8.
Signature:
@@ -169,7 +170,7 @@ Nan::Maybe<bool> Nan::Equals(v8::Local<v8::Value> a, v8::Local<v8::Value>(b));
<a name="api_nan_new_instance"></a>
### Nan::NewInstance()
-A helper method for calling [`v8::Function#NewInstance()`](https://v8docs.nodesource.com/io.js-3.0/d5/d54/classv8_1_1_function.html#a691b13f7a553069732cbacf5ac8c62ec) and [`v8::ObjectTemplate#NewInstance()`](https://v8docs.nodesource.com/io.js-3.0/db/d5f/classv8_1_1_object_template.html#ad605a7543cfbc5dab54cdb0883d14ae4) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Function#NewInstance()`](https://v8docs.nodesource.com/io.js-3.3/d5/d54/classv8_1_1_function.html#a691b13f7a553069732cbacf5ac8c62ec) and [`v8::ObjectTemplate#NewInstance()`](https://v8docs.nodesource.com/io.js-3.3/db/d5f/classv8_1_1_object_template.html#ad605a7543cfbc5dab54cdb0883d14ae4) in a way compatible across supported versions of V8.
Signature:
@@ -183,7 +184,7 @@ Nan::MaybeLocal<v8::Object> Nan::NewInstance(v8::Local<v8::ObjectTemplate> h);
<a name="api_nan_get_function"></a>
### Nan::GetFunction()
-A helper method for calling [`v8::FunctionTemplate#GetFunction()`](https://v8docs.nodesource.com/io.js-3.0/d8/d83/classv8_1_1_function_template.html#a56d904662a86eca78da37d9bb0ed3705) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::FunctionTemplate#GetFunction()`](https://v8docs.nodesource.com/io.js-3.3/d8/d83/classv8_1_1_function_template.html#a56d904662a86eca78da37d9bb0ed3705) in a way compatible across supported versions of V8.
Signature:
@@ -195,7 +196,7 @@ Nan::MaybeLocal<v8::Function> Nan::GetFunction(v8::Local<v8::FunctionTemplate> t
<a name="api_nan_set"></a>
### Nan::Set()
-A helper method for calling [`v8::Object#Set()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a67604ea3734f170c66026064ea808f20) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#Set()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a67604ea3734f170c66026064ea808f20) in a way compatible across supported versions of V8.
Signature:
@@ -209,25 +210,42 @@ Nan::Maybe<bool> Nan::Set(v8::Local<v8::Object> obj,
```
+<a name="api_nan_define_own_property"></a>
+### Nan::DefineOwnProperty()
+
+A helper method for calling [`v8::Object#DefineOwnProperty()`](https://v8docs.nodesource.com/node-4.8/db/d85/classv8_1_1_object.html#a6f76b2ed605cb8f9185b92de0033a820) in a way compatible across supported versions of V8.
+
+Signature:
+
+```c++
+Nan::Maybe<bool> Nan::DefineOwnProperty(v8::Local<v8::Object> obj,
+ v8::Local<v8::String> key,
+ v8::Local<v8::Value> value,
+ v8::PropertyAttribute attribs = v8::None);
+```
+
+
<a name="api_nan_force_set"></a>
-### Nan::ForceSet()
+### <del>Nan::ForceSet()</del>
+
+Deprecated, use <a href="#api_nan_define_own_property"><code>Nan::DefineOwnProperty()</code></a>.
-A helper method for calling [`v8::Object#ForceSet()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a796b7b682896fb64bf1872747734e836) in a way compatible across supported versions of V8.
+<del>A helper method for calling [`v8::Object#ForceSet()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a796b7b682896fb64bf1872747734e836) in a way compatible across supported versions of V8.</del>
Signature:
```c++
-Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object> obj,
- v8::Local<v8::Value> key,
- v8::Local<v8::Value> value,
- v8::PropertyAttribute attribs = v8::None);
+NAN_DEPRECATED Nan::Maybe<bool> Nan::ForceSet(v8::Local<v8::Object> obj,
+ v8::Local<v8::Value> key,
+ v8::Local<v8::Value> value,
+ v8::PropertyAttribute attribs = v8::None);
```
<a name="api_nan_get"></a>
### Nan::Get()
-A helper method for calling [`v8::Object#Get()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a2565f03e736694f6b1e1cf22a0b4eac2) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#Get()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a2565f03e736694f6b1e1cf22a0b4eac2) in a way compatible across supported versions of V8.
Signature:
@@ -241,7 +259,7 @@ Nan::MaybeLocal<v8::Value> Nan::Get(v8::Local<v8::Object> obj, uint32_t index);
<a name="api_nan_get_property_attribute"></a>
### Nan::GetPropertyAttributes()
-A helper method for calling [`v8::Object#GetPropertyAttributes()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a9b898894da3d1db2714fd9325a54fe57) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#GetPropertyAttributes()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a9b898894da3d1db2714fd9325a54fe57) in a way compatible across supported versions of V8.
Signature:
@@ -255,7 +273,7 @@ Nan::Maybe<v8::PropertyAttribute> Nan::GetPropertyAttributes(
<a name="api_nan_has"></a>
### Nan::Has()
-A helper method for calling [`v8::Object#Has()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab3c3d89ea7c2f9afd08965bd7299a41d) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#Has()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ab3c3d89ea7c2f9afd08965bd7299a41d) in a way compatible across supported versions of V8.
Signature:
@@ -268,7 +286,7 @@ Nan::Maybe<bool> Nan::Has(v8::Local<v8::Object> obj, uint32_t index);
<a name="api_nan_delete"></a>
### Nan::Delete()
-A helper method for calling [`v8::Object#Delete()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a2fa0f5a592582434ed1ceceff7d891ef) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#Delete()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a2fa0f5a592582434ed1ceceff7d891ef) in a way compatible across supported versions of V8.
Signature:
@@ -282,7 +300,7 @@ Nan::Maybe<bool> Nan::Delete(v8::Local<v8::Object> obj, uint32_t index);
<a name="api_nan_get_property_names"></a>
### Nan::GetPropertyNames()
-A helper method for calling [`v8::Object#GetPropertyNames()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#aced885270cfd2c956367b5eedc7fbfe8) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#GetPropertyNames()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#aced885270cfd2c956367b5eedc7fbfe8) in a way compatible across supported versions of V8.
Signature:
@@ -294,7 +312,7 @@ Nan::MaybeLocal<v8::Array> Nan::GetPropertyNames(v8::Local<v8::Object> obj);
<a name="api_nan_get_own_property_names"></a>
### Nan::GetOwnPropertyNames()
-A helper method for calling [`v8::Object#GetOwnPropertyNames()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a79a6e4d66049b9aa648ed4dfdb23e6eb) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#GetOwnPropertyNames()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a79a6e4d66049b9aa648ed4dfdb23e6eb) in a way compatible across supported versions of V8.
Signature:
@@ -306,7 +324,7 @@ Nan::MaybeLocal<v8::Array> Nan::GetOwnPropertyNames(v8::Local<v8::Object> obj);
<a name="api_nan_set_prototype"></a>
### Nan::SetPrototype()
-A helper method for calling [`v8::Object#SetPrototype()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a442706b22fceda6e6d1f632122a9a9f4) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#SetPrototype()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a442706b22fceda6e6d1f632122a9a9f4) in a way compatible across supported versions of V8.
Signature:
@@ -319,7 +337,7 @@ Nan::Maybe<bool> Nan::SetPrototype(v8::Local<v8::Object> obj,
<a name="api_nan_object_proto_to_string"></a>
### Nan::ObjectProtoToString()
-A helper method for calling [`v8::Object#ObjectProtoToString()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab7a92b4dcf822bef72f6c0ac6fea1f0b) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#ObjectProtoToString()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ab7a92b4dcf822bef72f6c0ac6fea1f0b) in a way compatible across supported versions of V8.
Signature:
@@ -331,7 +349,7 @@ Nan::MaybeLocal<v8::String> Nan::ObjectProtoToString(v8::Local<v8::Object> obj);
<a name="api_nan_has_own_property"></a>
### Nan::HasOwnProperty()
-A helper method for calling [`v8::Object#HasOwnProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab7b7245442ca6de1e1c145ea3fd653ff) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#HasOwnProperty()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ab7b7245442ca6de1e1c145ea3fd653ff) in a way compatible across supported versions of V8.
Signature:
@@ -344,7 +362,7 @@ Nan::Maybe<bool> Nan::HasOwnProperty(v8::Local<v8::Object> obj,
<a name="api_nan_has_real_named_property"></a>
### Nan::HasRealNamedProperty()
-A helper method for calling [`v8::Object#HasRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ad8b80a59c9eb3c1e6c3cd6c84571f767) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#HasRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ad8b80a59c9eb3c1e6c3cd6c84571f767) in a way compatible across supported versions of V8.
Signature:
@@ -357,7 +375,7 @@ Nan::Maybe<bool> Nan::HasRealNamedProperty(v8::Local<v8::Object> obj,
<a name="api_nan_has_real_indexed_property"></a>
### Nan::HasRealIndexedProperty()
-A helper method for calling [`v8::Object#HasRealIndexedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#af94fc1135a5e74a2193fb72c3a1b9855) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#HasRealIndexedProperty()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#af94fc1135a5e74a2193fb72c3a1b9855) in a way compatible across supported versions of V8.
Signature:
@@ -370,7 +388,7 @@ Nan::Maybe<bool> Nan::HasRealIndexedProperty(v8::Local<v8::Object> obj,
<a name="api_nan_has_real_named_callback_property"></a>
### Nan::HasRealNamedCallbackProperty()
-A helper method for calling [`v8::Object#HasRealNamedCallbackProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#af743b7ea132b89f84d34d164d0668811) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#HasRealNamedCallbackProperty()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#af743b7ea132b89f84d34d164d0668811) in a way compatible across supported versions of V8.
Signature:
@@ -384,7 +402,7 @@ Nan::Maybe<bool> Nan::HasRealNamedCallbackProperty(
<a name="api_nan_get_real_named_property_in_prototype_chain"></a>
### Nan::GetRealNamedPropertyInPrototypeChain()
-A helper method for calling [`v8::Object#GetRealNamedPropertyInPrototypeChain()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a8700b1862e6b4783716964ba4d5e6172) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#GetRealNamedPropertyInPrototypeChain()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a8700b1862e6b4783716964ba4d5e6172) in a way compatible across supported versions of V8.
Signature:
@@ -398,7 +416,7 @@ Nan::MaybeLocal<v8::Value> Nan::GetRealNamedPropertyInPrototypeChain(
<a name="api_nan_get_real_named_property"></a>
### Nan::GetRealNamedProperty()
-A helper method for calling [`v8::Object#GetRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a84471a824576a5994fdd0ffcbf99ccc0) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#GetRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a84471a824576a5994fdd0ffcbf99ccc0) in a way compatible across supported versions of V8.
Signature:
@@ -411,7 +429,7 @@ Nan::MaybeLocal<v8::Value> Nan::GetRealNamedProperty(v8::Local<v8::Object> obj,
<a name="api_nan_call_as_function"></a>
### Nan::CallAsFunction()
-A helper method for calling [`v8::Object#CallAsFunction()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a9ef18be634e79b4f0cdffa1667a29f58) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#CallAsFunction()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a9ef18be634e79b4f0cdffa1667a29f58) in a way compatible across supported versions of V8.
Signature:
@@ -426,7 +444,7 @@ Nan::MaybeLocal<v8::Value> Nan::CallAsFunction(v8::Local<v8::Object> obj,
<a name="api_nan_call_as_constructor"></a>
### Nan::CallAsConstructor()
-A helper method for calling [`v8::Object#CallAsConstructor()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a50d571de50d0b0dfb28795619d07a01b) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Object#CallAsConstructor()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#a50d571de50d0b0dfb28795619d07a01b) in a way compatible across supported versions of V8.
Signature:
@@ -440,7 +458,7 @@ Nan::MaybeLocal<v8::Value> Nan::CallAsConstructor(v8::Local<v8::Object> obj,
<a name="api_nan_get_source_line"></a>
### Nan::GetSourceLine()
-A helper method for calling [`v8::Message#GetSourceLine()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#a849f7a6c41549d83d8159825efccd23a) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Message#GetSourceLine()`](https://v8docs.nodesource.com/io.js-3.3/d9/d28/classv8_1_1_message.html#a849f7a6c41549d83d8159825efccd23a) in a way compatible across supported versions of V8.
Signature:
@@ -452,7 +470,7 @@ Nan::MaybeLocal<v8::String> Nan::GetSourceLine(v8::Local<v8::Message> msg);
<a name="api_nan_get_line_number"></a>
### Nan::GetLineNumber()
-A helper method for calling [`v8::Message#GetLineNumber()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#adbe46c10a88a6565f2732a2d2adf99b9) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Message#GetLineNumber()`](https://v8docs.nodesource.com/io.js-3.3/d9/d28/classv8_1_1_message.html#adbe46c10a88a6565f2732a2d2adf99b9) in a way compatible across supported versions of V8.
Signature:
@@ -464,7 +482,7 @@ Nan::Maybe<int> Nan::GetLineNumber(v8::Local<v8::Message> msg);
<a name="api_nan_get_start_column"></a>
### Nan::GetStartColumn()
-A helper method for calling [`v8::Message#GetStartColumn()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#a60ede616ba3822d712e44c7a74487ba6) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Message#GetStartColumn()`](https://v8docs.nodesource.com/io.js-3.3/d9/d28/classv8_1_1_message.html#a60ede616ba3822d712e44c7a74487ba6) in a way compatible across supported versions of V8.
Signature:
@@ -476,7 +494,7 @@ Nan::Maybe<int> Nan::GetStartColumn(v8::Local<v8::Message> msg);
<a name="api_nan_get_end_column"></a>
### Nan::GetEndColumn()
-A helper method for calling [`v8::Message#GetEndColumn()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#aaa004cf19e529da980bc19fcb76d93be) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Message#GetEndColumn()`](https://v8docs.nodesource.com/io.js-3.3/d9/d28/classv8_1_1_message.html#aaa004cf19e529da980bc19fcb76d93be) in a way compatible across supported versions of V8.
Signature:
@@ -488,7 +506,7 @@ Nan::Maybe<int> Nan::GetEndColumn(v8::Local<v8::Message> msg);
<a name="api_nan_clone_element_at"></a>
### Nan::CloneElementAt()
-A helper method for calling [`v8::Array#CloneElementAt()`](https://v8docs.nodesource.com/io.js-3.0/d3/d32/classv8_1_1_array.html#a1d3a878d4c1c7cae974dd50a1639245e) in a way compatible across supported versions of V8.
+A helper method for calling [`v8::Array#CloneElementAt()`](https://v8docs.nodesource.com/io.js-3.3/d3/d32/classv8_1_1_array.html#a1d3a878d4c1c7cae974dd50a1639245e) in a way compatible across supported versions of V8.
Signature:
diff --git a/doc/methods.md b/doc/methods.md
index dbe512d..bae46f2 100644
--- a/doc/methods.md
+++ b/doc/methods.md
@@ -1,6 +1,6 @@
## JavaScript-accessible methods
-A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://developers.google.com/v8/embed#templates) for further information.
+A _template_ is a blueprint for JavaScript functions and objects in a context. You can use a template to wrap C++ functions and data structures within JavaScript objects so that they can be manipulated from JavaScript. See the V8 Embedders Guide section on [Templates](https://github.com/v8/v8/wiki/Embedder%27s-Guide#templates) for further information.
In order to expose functionality to JavaScript via a template, you must provide it to V8 in a form that it understands. Across the versions of V8 supported by NAN, JavaScript-accessible method signatures vary widely, NAN fully abstracts method declaration and provides you with an interface that is similar to the most recent V8 API but is backward-compatible with older versions that still use the now-deceased `v8::Argument` type.
@@ -545,7 +545,7 @@ void SetNamedPropertyHandler(v8::Local<v8::ObjectTemplate> tpl,
v8::Local<v8::Value> data = v8::Local<v8::Value>())
```
-See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/io.js-3.0/db/d5f/classv8_1_1_object_template.html#a34d1cc45b642cd131706663801aadd76) for further information about how to use `Nan::SetNamedPropertyHandler()`.
+See the V8 [`ObjectTemplate#SetNamedPropertyHandler()`](https://v8docs.nodesource.com/io.js-3.3/db/d5f/classv8_1_1_object_template.html#a34d1cc45b642cd131706663801aadd76) for further information about how to use `Nan::SetNamedPropertyHandler()`.
<a name="api_nan_set_indexed_property_handler"></a>
### Nan::SetIndexedPropertyHandler()
@@ -608,7 +608,7 @@ void Nan::SetPrototypeTemplate(v8::Local<v8::FunctionTemplate> templ,
v8::PropertyAttribute attributes)
```
-Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.0/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
+Calls the `FunctionTemplate`'s _PrototypeTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.3/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
<a name="api_nan_set_instance_template"></a>
### Nan::SetInstanceTemplate()
@@ -627,7 +627,7 @@ void Nan::SetInstanceTemplate(v8::Local<v8::FunctionTemplate> templ,
v8::PropertyAttribute attributes)
```
-Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.0/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
+Calls the `FunctionTemplate`'s _InstanceTemplate's_ [`Set()`](https://v8docs.nodesource.com/io.js-3.3/db/df7/classv8_1_1_template.html#a2db6a56597bf23c59659c0659e564ddf).
<a name="api_nan_set_call_handler"></a>
### Nan::SetCallHandler()
diff --git a/doc/new.md b/doc/new.md
index c0734bd..0804b62 100644
--- a/doc/new.md
+++ b/doc/new.md
@@ -15,7 +15,7 @@ NAN provides a `Nan::New()` helper for the creation of new JavaScript objects in
`Nan::New()` should be used to instantiate new JavaScript objects.
-Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/io.js-3.0/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
+Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/io.js-3.3/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
Signatures:
@@ -75,7 +75,7 @@ v8::Local<v8::String> Nan::New<T>(Nan::ExternalOneByteStringResource * value);
v8::Local<v8::RegExp> Nan::New<T>(v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
```
-Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/io.js-3.0/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
+Note that `Nan::ExternalOneByteStringResource` maps to [`v8::String::ExternalOneByteStringResource`](https://v8docs.nodesource.com/io.js-3.3/d9/db3/classv8_1_1_string_1_1_external_one_byte_string_resource.html), and `v8::String::ExternalAsciiStringResource` in older versions of V8.
<a name="api_nan_undefined"></a>
@@ -125,7 +125,7 @@ v8::Local<v8::Boolean> Nan::False()
<a name="api_nan_empty_string"></a>
### Nan::EmptyString()
-Call [`v8::String::Empty`](https://v8docs.nodesource.com/io.js-3.0/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
+Call [`v8::String::Empty`](https://v8docs.nodesource.com/io.js-3.3/d2/db3/classv8_1_1_string.html#a7c1bc8886115d7ee46f1d571dd6ebc6d) to reference the empty string in a way that is compatible across all supported versions of V8.
Signature:
@@ -137,7 +137,7 @@ v8::Local<v8::String> Nan::EmptyString()
<a name="api_nan_new_one_byte_string"></a>
### Nan::NewOneByteString()
-An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/io.js-3.0/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
+An implementation of [`v8::String::NewFromOneByte()`](https://v8docs.nodesource.com/io.js-3.3/d2/db3/classv8_1_1_string.html#a5264d50b96d2c896ce525a734dc10f09) provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
Signature:
diff --git a/doc/persistent.md b/doc/persistent.md
index 743b44a..f6ebefa 100644
--- a/doc/persistent.md
+++ b/doc/persistent.md
@@ -93,7 +93,7 @@ template<typename T> class PersistentBase {
};
```
-See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/io.js-3.0/d4/dca/classv8_1_1_persistent_base.html) for further information.
+See the V8 documentation for [`PersistentBase`](https://v8docs.nodesource.com/io.js-3.3/d4/dca/classv8_1_1_persistent_base.html) for further information.
**Tip:** To get a `v8::Local` reference to the original object back from a `PersistentBase` or `Persistent` object:
@@ -125,7 +125,7 @@ template<typename T> class NonCopyablePersistentTraits {
};
```
-See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.0/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
+See the V8 documentation for [`NonCopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.3/de/d73/classv8_1_1_non_copyable_persistent_traits.html) for further information.
<a name="api_nan_copyable_persistent_traits"></a>
### Nan::CopyablePersistentTraits & v8::CopyablePersistentTraits
@@ -150,7 +150,7 @@ class CopyablePersistentTraits {
};
```
-See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.0/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
+See the V8 documentation for [`CopyablePersistentTraits`](https://v8docs.nodesource.com/io.js-3.3/da/d5c/structv8_1_1_copyable_persistent_traits.html) for further information.
<a name="api_nan_persistent"></a>
### Nan::Persistent
@@ -203,7 +203,7 @@ template<typename T, typename M> class Persistent : public PersistentBase<T> {
};
```
-See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/io.js-3.0/d2/d78/classv8_1_1_persistent.html) for further information.
+See the V8 documentation for [`Persistent`](https://v8docs.nodesource.com/io.js-3.3/d2/d78/classv8_1_1_persistent.html) for further information.
<a name="api_nan_global"></a>
### Nan::Global
@@ -237,7 +237,7 @@ template<typename T> class Global : public PersistentBase<T> {
};
```
-See the V8 documentation for [`Global`](https://v8docs.nodesource.com/io.js-3.0/d5/d40/classv8_1_1_global.html) for further information.
+See the V8 documentation for [`Global`](https://v8docs.nodesource.com/io.js-3.3/d5/d40/classv8_1_1_global.html) for further information.
<a name="api_nan_weak_callback_info"></a>
### Nan::WeakCallbackInfo
@@ -278,7 +278,7 @@ int *data = new int(0);
obj.SetWeak(data, callback, WeakCallbackType::kParameter);
```
-See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/io.js-3.0/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
+See the V8 documentation for [`WeakCallbackInfo`](https://v8docs.nodesource.com/io.js-3.3/d8/d06/classv8_1_1_weak_callback_info.html) for further information.
<a name="api_nan_weak_callback_type"></a>
### Nan::WeakCallbackType
diff --git a/doc/scopes.md b/doc/scopes.md
index 060c8e4..1dfb417 100644
--- a/doc/scopes.md
+++ b/doc/scopes.md
@@ -14,7 +14,7 @@ Also see the V8 Embedders Guide section on [Handles and Garbage Collection](http
<a name="api_nan_handle_scope"></a>
### Nan::HandleScope
-A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/io.js-3.0/d3/d95/classv8_1_1_handle_scope.html).
+A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/io.js-3.3/d3/d95/classv8_1_1_handle_scope.html).
Definition:
diff --git a/doc/script.md b/doc/script.md
index 1267b5e..e518505 100644
--- a/doc/script.md
+++ b/doc/script.md
@@ -9,7 +9,7 @@ NAN provides a `v8::Script` helpers as the API has changed over the supported ve
<a name="api_nan_compile_script"></a>
### Nan::CompileScript()
-A wrapper around [`v8::Script::Compile()`](https://v8docs.nodesource.com/io.js-3.0/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
+A wrapper around [`v8::Script::Compile()`](https://v8docs.nodesource.com/io.js-3.3/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
Note that `Nan::BoundScript` is an alias for `v8::Script`.
diff --git a/doc/v8_internals.md b/doc/v8_internals.md
index ce5f230..430c435 100644
--- a/doc/v8_internals.md
+++ b/doc/v8_internals.md
@@ -33,7 +33,7 @@ NAN_GC_CALLBACK(gcPrologueCallback) {
}
NAN_METHOD(Hook) {
- callback.Reset(args[0].As<Function>());
+ callback.Reset(To<Function>(args[0]).ToLocalChecked());
Nan::AddGCPrologueCallback(gcPrologueCallback);
info.GetReturnValue().Set(info.Holder());
}
@@ -48,7 +48,7 @@ Signature:
void Nan::AddGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback, v8::GCType gc_type_filter = v8::kGCTypeAll)
```
-Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a90d1860babc76059c62514b422f56960).
+Calls V8's [`AddGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a90d1860babc76059c62514b422f56960).
<a name="api_nan_remove_gc_epilogue_callback"></a>
### Nan::RemoveGCEpilogueCallback()
@@ -59,7 +59,7 @@ Signature:
void Nan::RemoveGCEpilogueCallback(v8::Isolate::GCEpilogueCallback callback)
```
-Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a05c60859fd4b8e96bfcd451281ed6c7c).
+Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a05c60859fd4b8e96bfcd451281ed6c7c).
<a name="api_nan_add_gc_prologue_callback"></a>
### Nan::AddGCPrologueCallback()
@@ -70,7 +70,7 @@ Signature:
void Nan::AddGCPrologueCallback(v8::Isolate::GCPrologueCallback, v8::GCType gc_type_filter callback)
```
-Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ab4b87b8f9f8e5bf95eba4009357e001f).
+Calls V8's [`AddGCPrologueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ab4b87b8f9f8e5bf95eba4009357e001f).
<a name="api_nan_remove_gc_prologue_callback"></a>
### Nan::RemoveGCPrologueCallback()
@@ -81,7 +81,7 @@ Signature:
void Nan::RemoveGCPrologueCallback(v8::Isolate::GCPrologueCallback callback)
```
-Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a9f6c51932811593f81ff30b949124186).
+Calls V8's [`RemoveGCEpilogueCallback()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a9f6c51932811593f81ff30b949124186).
<a name="api_nan_get_heap_statistics"></a>
### Nan::GetHeapStatistics()
@@ -92,7 +92,7 @@ Signature:
void Nan::GetHeapStatistics(v8::HeapStatistics *heap_statistics)
```
-Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
+Calls V8's [`GetHeapStatistics()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a5593ac74687b713095c38987e5950b34).
<a name="api_nan_set_counter_function"></a>
### Nan::SetCounterFunction()
@@ -103,7 +103,7 @@ Signature:
void Nan::SetCounterFunction(v8::CounterLookupCallback cb)
```
-Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
+Calls V8's [`SetCounterFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a045d7754e62fa0ec72ae6c259b29af94).
<a name="api_nan_set_create_histogram_function"></a>
### Nan::SetCreateHistogramFunction()
@@ -114,7 +114,7 @@ Signature:
void Nan::SetCreateHistogramFunction(v8::CreateHistogramCallback cb)
```
-Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
+Calls V8's [`SetCreateHistogramFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a542d67e85089cb3f92aadf032f99e732).
<a name="api_nan_set_add_histogram_sample_function"></a>
### Nan::SetAddHistogramSampleFunction()
@@ -125,7 +125,7 @@ Signature:
void Nan::SetAddHistogramSampleFunction(v8::AddHistogramSampleCallback cb)
```
-Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
+Calls V8's [`SetAddHistogramSampleFunction()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#aeb420b690bc2c216882d6fdd00ddd3ea).
<a name="api_nan_idle_notification"></a>
### Nan::IdleNotification()
@@ -136,7 +136,7 @@ Signature:
void Nan::IdleNotification(v8::HeapStatistics *heap_statistics)
```
-Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
+Calls V8's [`IdleNotification()` or `IdleNotificationDeadline()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad6a2a02657f5425ad460060652a5a118) depending on V8 version.
<a name="api_nan_low_memory_notification"></a>
### Nan::LowMemoryNotification()
@@ -147,7 +147,7 @@ Signature:
void Nan::LowMemoryNotification()
```
-Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
+Calls V8's [`LowMemoryNotification()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a24647f61d6b41f69668094bdcd6ea91f).
<a name="api_nan_context_disposed_notification"></a>
### Nan::ContextDisposedNotification()
@@ -158,7 +158,7 @@ Signature:
void Nan::ContextDisposedNotification()
```
-Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
+Calls V8's [`ContextDisposedNotification()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b).
<a name="api_nan_get_internal_field_pointer"></a>
### Nan::GetInternalFieldPointer()
@@ -171,7 +171,7 @@ Signature:
void* Nan::GetInternalFieldPointer(v8::Local<v8::Object> object, int index)
```
-Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
+Calls the Object's [`GetAlignedPointerFromInternalField()` or `GetPointerFromInternalField()`](https://v8docs.nodesource.com/io.js-3.3/db/d85/classv8_1_1_object.html#ab3c57184263cf29963ef0017bec82281) depending on the version of V8.
<a name="api_nan_set_internal_field_pointer"></a>
### Nan::SetInternalFieldPointer()
@@ -184,7 +184,7 @@ Signature:
void Nan::SetInternalFieldPointer(v8::Local<v8::Object> object, int index, void* value)
```
-Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b) depending on the version of V8.
+Calls the Object's [`SetAlignedPointerInInternalField()` or `SetPointerInInternalField()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ad7f5dc559866343fe6cd8db1f134d48b) depending on the version of V8.
<a name="api_nan_adjust_external_memory"></a>
### Nan::AdjustExternalMemory()
@@ -195,5 +195,5 @@ Signature:
int Nan::AdjustExternalMemory(int bytesChange)
```
-Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
+Calls V8's [`AdjustAmountOfExternalAllocatedMemory()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#ae1a59cac60409d3922582c4af675473e).
diff --git a/doc/v8_misc.md b/doc/v8_misc.md
index 64f736d..8aa6653 100644
--- a/doc/v8_misc.md
+++ b/doc/v8_misc.md
@@ -12,7 +12,7 @@
Converts an object to a UTF-8-encoded character array. If conversion to a string fails (e.g. due to an exception in the toString() method of the object) then the length() method returns 0 and the * operator returns NULL. The underlying memory used for this object is managed by the object.
-An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/io.js-3.0/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
+An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/io.js-3.3/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
Definition:
@@ -31,7 +31,7 @@ class Nan::Utf8String {
<a name="api_nan_get_current_context"></a>
### Nan::GetCurrentContext()
-A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
+A call to [`v8::Isolate::GetCurrent()->GetCurrentContext()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a81c7a1ed7001ae2a65e89107f75fd053) that works across all supported versions of V8.
Signature:
@@ -42,7 +42,7 @@ v8::Local<v8::Context> Nan::GetCurrentContext()
<a name="api_nan_set_isolate_data"></a>
### Nan::SetIsolateData()
-A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
+A helper to provide a consistent API to [`v8::Isolate#SetData()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#a7acadfe7965997e9c386a05f098fbe36).
Signature:
@@ -54,7 +54,7 @@ void Nan::SetIsolateData(v8::Isolate *isolate, T *data)
<a name="api_nan_get_isolate_data"></a>
### Nan::GetIsolateData()
-A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/io.js-3.0/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
+A helper to provide a consistent API to [`v8::Isolate#GetData()`](https://v8docs.nodesource.com/io.js-3.3/d5/dda/classv8_1_1_isolate.html#aabd223436bc1100a787dadaa024c6257).
Signature:
diff --git a/examples/async_pi_estimate/async.cc b/examples/async_pi_estimate/async.cc
index 709fc1f..c215af8 100644
--- a/examples/async_pi_estimate/async.cc
+++ b/examples/async_pi_estimate/async.cc
@@ -58,7 +58,7 @@ class PiWorker : public AsyncWorker {
// Asynchronous access to the `Estimate()` function
NAN_METHOD(CalculateAsync) {
int points = To<int>(info[0]).FromJust();
- Callback *callback = new Callback(info[1].As<Function>());
+ Callback *callback = new Callback(To<Function>(info[1]).ToLocalChecked());
AsyncQueueWorker(new PiWorker(callback, points));
}
diff --git a/nan.h b/nan.h
index ffbf960..7c7699f 100644
--- a/nan.h
+++ b/nan.h
@@ -13,7 +13,7 @@
*
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
*
- * Version 2.7.0: current Node 8.4.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1
+ * Version 2.8.0: current Node 9.2.0, Node 12: 0.12.18, Node 10: 0.10.48, iojs: 3.3.1
*
* See https://github.com/nodejs/nan for the latest update to this file
**********************************************************************************/
@@ -34,6 +34,8 @@
#define NODE_5_0_MODULE_VERSION 47
#define NODE_6_0_MODULE_VERSION 48
#define NODE_7_0_MODULE_VERSION 51
+#define NODE_8_0_MODULE_VERSION 57
+#define NODE_9_0_MODULE_VERSION 59
#ifdef _MSC_VER
# define NAN_HAS_CPLUSPLUS_11 (_MSC_VER >= 1800)
@@ -53,13 +55,16 @@
#include <cstring>
#include <climits>
#include <cstdlib>
+#include <utility>
#if defined(_MSC_VER)
# pragma warning( push )
# pragma warning( disable : 4530 )
+# include <queue>
# include <string>
# include <vector>
# pragma warning( pop )
#else
+# include <queue>
# include <string>
# include <vector>
#endif
@@ -1606,73 +1611,114 @@ class Callback {
char *errmsg_;
};
-
-template<class T>
-/* abstract */ class AsyncProgressWorkerBase : public AsyncWorker {
+/* abstract */ class AsyncBareProgressWorkerBase : public AsyncWorker {
public:
- explicit AsyncProgressWorkerBase(Callback *callback_)
- : AsyncWorker(callback_), asyncdata_(NULL), asyncsize_(0) {
- async = new uv_async_t;
+ explicit AsyncBareProgressWorkerBase(Callback *callback_)
+ : AsyncWorker(callback_) {
uv_async_init(
uv_default_loop()
- , async
+ , &async
, AsyncProgress_
);
- async->data = this;
+ async.data = this;
+ }
- uv_mutex_init(&async_lock);
+ virtual ~AsyncBareProgressWorkerBase() {
}
- virtual ~AsyncProgressWorkerBase() {
- uv_mutex_destroy(&async_lock);
+ virtual void WorkProgress() = 0;
- delete[] asyncdata_;
+ virtual void Destroy() {
+ uv_close(reinterpret_cast<uv_handle_t*>(&async), AsyncClose_);
}
- void WorkProgress() {
- uv_mutex_lock(&async_lock);
- T *data = asyncdata_;
- size_t size = asyncsize_;
- asyncdata_ = NULL;
- uv_mutex_unlock(&async_lock);
+ private:
+ inline static NAUV_WORK_CB(AsyncProgress_) {
+ AsyncBareProgressWorkerBase *worker =
+ static_cast<AsyncBareProgressWorkerBase*>(async->data);
+ worker->WorkProgress();
+ }
- // Don't send progress events after we've already completed.
- if (callback) {
- HandleProgressCallback(data, size);
- }
- delete[] data;
+ inline static void AsyncClose_(uv_handle_t* handle) {
+ AsyncBareProgressWorkerBase *worker =
+ static_cast<AsyncBareProgressWorkerBase*>(handle->data);
+ delete worker;
+ }
+
+ protected:
+ uv_async_t async;
+};
+
+template<class T>
+/* abstract */
+class AsyncBareProgressWorker : public AsyncBareProgressWorkerBase {
+ public:
+ explicit AsyncBareProgressWorker(Callback *callback_)
+ : AsyncBareProgressWorkerBase(callback_) {
+ }
+
+ virtual ~AsyncBareProgressWorker() {
}
class ExecutionProgress {
- friend class AsyncProgressWorkerBase;
+ friend class AsyncBareProgressWorker;
public:
void Signal() const {
- uv_async_send(that_->async);
+ uv_async_send(&that_->async);
}
void Send(const T* data, size_t count) const {
- that_->SendProgress_(data, count);
+ that_->SendProgress_(data, count);
}
private:
- explicit ExecutionProgress(AsyncProgressWorkerBase *that) : that_(that) {}
+ explicit ExecutionProgress(AsyncBareProgressWorker *that) : that_(that) {}
NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress)
- AsyncProgressWorkerBase* const that_;
+ AsyncBareProgressWorker* const that_;
};
virtual void Execute(const ExecutionProgress& progress) = 0;
virtual void HandleProgressCallback(const T *data, size_t size) = 0;
- virtual void Destroy() {
- uv_close(reinterpret_cast<uv_handle_t*>(async), AsyncClose_);
- }
-
private:
void Execute() /*final override*/ {
- ExecutionProgress progress(this);
- Execute(progress);
+ ExecutionProgress progress(this);
+ Execute(progress);
}
+ virtual void SendProgress_(const T *data, size_t count) = 0;
+};
+
+template<class T>
+/* abstract */
+class AsyncProgressWorkerBase : public AsyncBareProgressWorker<T> {
+ public:
+ explicit AsyncProgressWorkerBase(Callback *callback_)
+ : AsyncBareProgressWorker<T>(callback_), asyncdata_(NULL), asyncsize_(0) {
+ uv_mutex_init(&async_lock);
+ }
+
+ virtual ~AsyncProgressWorkerBase() {
+ uv_mutex_destroy(&async_lock);
+
+ delete[] asyncdata_;
+ }
+
+ void WorkProgress() {
+ uv_mutex_lock(&async_lock);
+ T *data = asyncdata_;
+ size_t size = asyncsize_;
+ asyncdata_ = NULL;
+ uv_mutex_unlock(&async_lock);
+
+ // Don't send progress events after we've already completed.
+ if (this->callback) {
+ this->HandleProgressCallback(data, size);
+ }
+ delete[] data;
+ }
+
+ private:
void SendProgress_(const T *data, size_t count) {
T *new_data = new T[count];
{
@@ -1687,23 +1733,9 @@ template<class T>
uv_mutex_unlock(&async_lock);
delete[] old_data;
- uv_async_send(async);
- }
-
- inline static NAUV_WORK_CB(AsyncProgress_) {
- AsyncProgressWorkerBase *worker =
- static_cast<AsyncProgressWorkerBase*>(async->data);
- worker->WorkProgress();
- }
-
- inline static void AsyncClose_(uv_handle_t* handle) {
- AsyncProgressWorkerBase *worker =
- static_cast<AsyncProgressWorkerBase*>(handle->data);
- delete reinterpret_cast<uv_async_t*>(handle);
- delete worker;
+ uv_async_send(&this->async);
}
- uv_async_t *async;
uv_mutex_t async_lock;
T *asyncdata_;
size_t asyncsize_;
@@ -1713,6 +1745,117 @@ template<class T>
// class definition.
typedef AsyncProgressWorkerBase<char> AsyncProgressWorker;
+template<class T>
+/* abstract */
+class AsyncBareProgressQueueWorker : public AsyncBareProgressWorkerBase {
+ public:
+ explicit AsyncBareProgressQueueWorker(Callback *callback_)
+ : AsyncBareProgressWorkerBase(callback_) {
+ }
+
+ virtual ~AsyncBareProgressQueueWorker() {
+ }
+
+ class ExecutionProgress {
+ friend class AsyncBareProgressQueueWorker;
+ public:
+ void Send(const T* data, size_t count) const {
+ that_->SendProgress_(data, count);
+ }
+
+ private:
+ explicit ExecutionProgress(AsyncBareProgressQueueWorker *that)
+ : that_(that) {}
+ NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress)
+ AsyncBareProgressQueueWorker* const that_;
+ };
+
+ virtual void Execute(const ExecutionProgress& progress) = 0;
+ virtual void HandleProgressCallback(const T *data, size_t size) = 0;
+
+ private:
+ void Execute() /*final override*/ {
+ ExecutionProgress progress(this);
+ Execute(progress);
+ }
+
+ virtual void SendProgress_(const T *data, size_t count) = 0;
+};
+
+template<class T>
+/* abstract */
+class AsyncProgressQueueWorker : public AsyncBareProgressQueueWorker<T> {
+ public:
+ explicit AsyncProgressQueueWorker(Callback *callback_)
+ : AsyncBareProgressQueueWorker<T>(callback_) {
+ uv_mutex_init(&async_lock);
+ }
+
+ virtual ~AsyncProgressQueueWorker() {
+ uv_mutex_lock(&async_lock);
+
+ while (!asyncdata_.empty()) {
+ std::pair<T*, size_t> &datapair = asyncdata_.front();
+ T *data = datapair.first;
+
+ asyncdata_.pop();
+
+ delete[] data;
+ }
+
+ uv_mutex_unlock(&async_lock);
+ uv_mutex_destroy(&async_lock);
+ }
+
+ void WorkComplete() {
+ WorkProgress();
+ AsyncWorker::WorkComplete();
+ }
+
+ void WorkProgress() {
+ uv_mutex_lock(&async_lock);
+
+ while (!asyncdata_.empty()) {
+ std::pair<T*, size_t> &datapair = asyncdata_.front();
+
+ T *data = datapair.first;
+ size_t size = datapair.second;
+
+ asyncdata_.pop();
+ uv_mutex_unlock(&async_lock);
+
+ // Don't send progress events after we've already completed.
+ if (this->callback) {
+ this->HandleProgressCallback(data, size);
+ }
+
+ delete[] data;
+
+ uv_mutex_lock(&async_lock);
+ }
+
+ uv_mutex_unlock(&async_lock);
+ }
+
+ private:
+ void SendProgress_(const T *data, size_t count) {
+ T *new_data = new T[count];
+ {
+ T *it = new_data;
+ std::copy(data, data + count, it);
+ }
+
+ uv_mutex_lock(&async_lock);
+ asyncdata_.push(std::pair<T*, size_t>(new_data, count));
+ uv_mutex_unlock(&async_lock);
+
+ uv_async_send(&this->async);
+ }
+
+ uv_mutex_t async_lock;
+ std::queue<std::pair<T*, size_t> > asyncdata_;
+};
+
inline void AsyncExecute (uv_work_t* req) {
AsyncWorker *worker = static_cast<AsyncWorker*>(req->data);
worker->Execute();
diff --git a/nan_json.h b/nan_json.h
index 465614b..1b1b38f 100644
--- a/nan_json.h
+++ b/nan_json.h
@@ -78,7 +78,8 @@ class JSON {
return scope.Escape(parse(json_string));
#else
Nan::MaybeLocal<v8::Value> result;
-#if NODE_MODULE_VERSION == NODE_0_12_MODULE_VERSION
+#if NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION && \
+ NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
result = v8::JSON::Parse(json_string);
#else
#if NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
@@ -87,7 +88,8 @@ class JSON {
v8::Isolate* context_or_isolate = v8::Isolate::GetCurrent();
#endif // NODE_MODULE_VERSION > NODE_6_0_MODULE_VERSION
result = v8::JSON::Parse(context_or_isolate, json_string);
-#endif // NODE_MODULE_VERSION == NODE_0_12_MODULE_VERSION
+#endif // NODE_MODULE_VERSION >= NODE_0_12_MODULE_VERSION &&
+ // NODE_MODULE_VERSION <= IOJS_2_0_MODULE_VERSION
if (result.IsEmpty()) return v8::Local<v8::Value>();
return scope.Escape(result.ToLocalChecked());
#endif // NAN_JSON_H_NEED_PARSE
diff --git a/nan_maybe_43_inl.h b/nan_maybe_43_inl.h
index 10eeb02..5bfac72 100644
--- a/nan_maybe_43_inl.h
+++ b/nan_maybe_43_inl.h
@@ -102,14 +102,32 @@ inline Maybe<bool> Set(
return obj->Set(isolate->GetCurrentContext(), index, value);
}
-inline Maybe<bool> ForceSet(
+inline Maybe<bool> DefineOwnProperty(
+ v8::Local<v8::Object> obj
+ , v8::Local<v8::String> key
+ , v8::Local<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ v8::Isolate *isolate = v8::Isolate::GetCurrent();
+ v8::HandleScope scope(isolate);
+ return obj->DefineOwnProperty(isolate->GetCurrentContext(), key, value,
+ attribs);
+}
+
+NAN_DEPRECATED inline Maybe<bool> ForceSet(
v8::Local<v8::Object> obj
, v8::Local<v8::Value> key
, v8::Local<v8::Value> value
, v8::PropertyAttribute attribs = v8::None) {
v8::Isolate *isolate = v8::Isolate::GetCurrent();
v8::HandleScope scope(isolate);
+#if NODE_MODULE_VERSION >= NODE_9_0_MODULE_VERSION
+ return key->IsName()
+ ? obj->DefineOwnProperty(isolate->GetCurrentContext(),
+ key.As<v8::Name>(), value, attribs)
+ : Nothing<bool>();
+#else
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
+#endif
}
inline MaybeLocal<v8::Value> Get(
diff --git a/nan_maybe_pre_43_inl.h b/nan_maybe_pre_43_inl.h
index f0248f9..8100125 100644
--- a/nan_maybe_pre_43_inl.h
+++ b/nan_maybe_pre_43_inl.h
@@ -148,7 +148,20 @@ inline Maybe<bool> Set(
return Just<bool>(obj->Set(index, value));
}
-inline Maybe<bool> ForceSet(
+inline Maybe<bool> DefineOwnProperty(
+ v8::Handle<v8::Object> obj
+ , v8::Handle<v8::String> key
+ , v8::Handle<v8::Value> value
+ , v8::PropertyAttribute attribs = v8::None) {
+ v8::PropertyAttribute current = obj->GetPropertyAttributes(key);
+ return !(current & v8::DontDelete) || // configurable OR
+ !(current & v8::ReadOnly) && // writable AND
+ !((attribs ^ current) & ~v8::ReadOnly) // same excluding RO
+ ? Just<bool>(obj->ForceSet(key, value, attribs))
+ : Nothing<bool>();
+}
+
+NAN_DEPRECATED inline Maybe<bool> ForceSet(
v8::Handle<v8::Object> obj
, v8::Handle<v8::Value> key
, v8::Handle<v8::Value> value
diff --git a/package.json b/package.json
index 9574bd1..db7c35f 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "nan",
- "version": "2.7.0",
- "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 8 compatibility",
+ "version": "2.8.0",
+ "description": "Native Abstractions for Node.js: C++ header for Node 0.8 -> 9 compatibility",
"main": "include_dirs.js",
"repository": {
"type": "git",
@@ -9,7 +9,7 @@
},
"scripts": {
"test": "tap --gc --stderr test/js/*-test.js",
- "rebuild-tests": "node-gyp rebuild --msvs_version=2013 --directory test",
+ "rebuild-tests": "node-gyp rebuild --msvs_version=2015 --directory test",
"docs": "doc/.build.sh"
},
"contributors": [
@@ -26,7 +26,8 @@
"bindings": "~1.2.1",
"commander": "^2.8.1",
"glob": "^5.0.14",
- "node-gyp": "~3.0.1",
+ "request": "=2.81.0",
+ "node-gyp": "~3.6.2",
"readable-stream": "^2.1.4",
"tap": "~0.7.1",
"xtend": "~4.0.0"
diff --git a/test/binding.gyp b/test/binding.gyp
index 0618981..2c70cb9 100644
--- a/test/binding.gyp
+++ b/test/binding.gyp
@@ -44,6 +44,14 @@
, "sources" : [ "cpp/returnemptystring.cpp" ]
}
, {
+ "target_name" : "asyncprogressqueueworker"
+ , "sources" : [ "cpp/asyncprogressqueueworker.cpp" ]
+ }
+ , {
+ "target_name" : "asyncprogressqueueworkerstream"
+ , "sources" : [ "cpp/asyncprogressqueueworkerstream.cpp" ]
+ }
+ , {
"target_name" : "asyncworker"
, "sources" : [ "cpp/asyncworker.cpp" ]
}
diff --git a/test/cpp/asyncprogressworker.cpp b/test/cpp/asyncprogressqueueworker.cpp
similarity index 57%
copy from test/cpp/asyncprogressworker.cpp
copy to test/cpp/asyncprogressqueueworker.cpp
index a9b8cce..f6b276e 100644
--- a/test/cpp/asyncprogressworker.cpp
+++ b/test/cpp/asyncprogressqueueworker.cpp
@@ -6,29 +6,26 @@
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
-#ifndef _WIN32
-#include <unistd.h>
-#define Sleep(x) usleep((x)*1000)
-#endif
#include <nan.h>
using namespace Nan; // NOLINT(build/namespaces)
-class ProgressWorker : public AsyncProgressWorker {
+class ProgressQueueWorker : public AsyncProgressQueueWorker<char> {
public:
- ProgressWorker(
+ ProgressQueueWorker(
Callback *callback
, Callback *progress
- , int milliseconds
, int iters)
- : AsyncProgressWorker(callback), progress(progress)
- , milliseconds(milliseconds), iters(iters) {}
- ~ProgressWorker() {}
+ : AsyncProgressQueueWorker(callback), progress(progress)
+ , iters(iters) {}
- void Execute (const AsyncProgressWorker::ExecutionProgress& progress) {
+ ~ProgressQueueWorker() {
+ delete progress;
+ }
+
+ void Execute (const AsyncProgressQueueWorker::ExecutionProgress& progress) {
for (int i = 0; i < iters; ++i) {
progress.Send(reinterpret_cast<const char*>(&i), sizeof(int));
- Sleep(milliseconds);
}
}
@@ -43,24 +40,22 @@ class ProgressWorker : public AsyncProgressWorker {
private:
Callback *progress;
- int milliseconds;
int iters;
};
NAN_METHOD(DoProgress) {
- Callback *progress = new Callback(info[2].As<v8::Function>());
- Callback *callback = new Callback(info[3].As<v8::Function>());
- AsyncQueueWorker(new ProgressWorker(
+ Callback *progress = new Callback(To<v8::Function>(info[1]).ToLocalChecked());
+ Callback *callback = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
+ AsyncQueueWorker(new ProgressQueueWorker(
callback
, progress
- , To<uint32_t>(info[0]).FromJust()
- , To<uint32_t>(info[1]).FromJust()));
+ , To<uint32_t>(info[0]).FromJust()));
}
NAN_MODULE_INIT(Init) {
Set(target
- , New<v8::String>("a").ToLocalChecked()
+ , New<v8::String>("doProgress").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
}
-NODE_MODULE(asyncprogressworker, Init)
+NODE_MODULE(asyncprogressqueueworker, Init)
diff --git a/test/cpp/asyncprogressworkerstream.cpp b/test/cpp/asyncprogressqueueworkerstream.cpp
similarity index 62%
copy from test/cpp/asyncprogressworkerstream.cpp
copy to test/cpp/asyncprogressqueueworkerstream.cpp
index 17099aa..b6f5745 100644
--- a/test/cpp/asyncprogressworkerstream.cpp
+++ b/test/cpp/asyncprogressqueueworkerstream.cpp
@@ -6,10 +6,6 @@
* MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
********************************************************************/
-#ifndef _WIN32
-#include <unistd.h>
-#define Sleep(x) usleep((x)*1000)
-#endif
#include <nan.h>
using namespace Nan; // NOLINT(build/namespaces)
@@ -21,27 +17,27 @@ struct data_t {
int data;
};
-// Unlike test/cpp/ayncprogressworker.cpp this test is explicitly templated.
template<typename T>
-class ProgressWorker : public AsyncProgressWorkerBase<T> {
+class ProgressQueueWorker : public AsyncProgressQueueWorker<T> {
public:
- ProgressWorker(
+ ProgressQueueWorker(
Callback *callback
, Callback *progress
- , int milliseconds
, int iters)
- : AsyncProgressWorkerBase<T>(callback), progress(progress)
- , milliseconds(milliseconds), iters(iters) {}
- ~ProgressWorker() {}
+ : AsyncProgressQueueWorker<T>(callback), progress(progress)
+ , iters(iters) {}
+
+ ~ProgressQueueWorker() {
+ delete progress;
+ }
void Execute (
- const typename AsyncProgressWorkerBase<T>::ExecutionProgress& progress) {
+ const typename AsyncProgressQueueWorker<T>::ExecutionProgress& progress) {
data_t data;
for (int i = 0; i < iters; ++i) {
data.index = i;
data.data = i * 2;
progress.Send(&data, 1);
- Sleep(milliseconds);
}
}
@@ -63,24 +59,22 @@ class ProgressWorker : public AsyncProgressWorkerBase<T> {
private:
Callback *progress;
- int milliseconds;
int iters;
};
NAN_METHOD(DoProgress) {
- Callback *progress = new Callback(info[2].As<v8::Function>());
- Callback *callback = new Callback(info[3].As<v8::Function>());
- AsyncQueueWorker(new ProgressWorker<data_t>(
+ Callback *progress = new Callback(To<v8::Function>(info[1]).ToLocalChecked());
+ Callback *callback = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
+ AsyncQueueWorker(new ProgressQueueWorker<data_t>(
callback
, progress
- , To<uint32_t>(info[0]).FromJust()
- , To<uint32_t>(info[1]).FromJust()));
+ , To<uint32_t>(info[0]).FromJust()));
}
NAN_MODULE_INIT(Init) {
Set(target
- , New<v8::String>("a").ToLocalChecked()
+ , New<v8::String>("doProgress").ToLocalChecked()
, New<v8::FunctionTemplate>(DoProgress)->GetFunction());
}
-NODE_MODULE(asyncprogressworkerstream, Init)
+NODE_MODULE(asyncprogressqueueworkerstream, Init)
diff --git a/test/cpp/asyncprogressworker.cpp b/test/cpp/asyncprogressworker.cpp
index a9b8cce..2e030b1 100644
--- a/test/cpp/asyncprogressworker.cpp
+++ b/test/cpp/asyncprogressworker.cpp
@@ -23,7 +23,10 @@ class ProgressWorker : public AsyncProgressWorker {
, int iters)
: AsyncProgressWorker(callback), progress(progress)
, milliseconds(milliseconds), iters(iters) {}
- ~ProgressWorker() {}
+
+ ~ProgressWorker() {
+ delete progress;
+ }
void Execute (const AsyncProgressWorker::ExecutionProgress& progress) {
for (int i = 0; i < iters; ++i) {
@@ -48,8 +51,8 @@ class ProgressWorker : public AsyncProgressWorker {
};
NAN_METHOD(DoProgress) {
- Callback *progress = new Callback(info[2].As<v8::Function>());
- Callback *callback = new Callback(info[3].As<v8::Function>());
+ Callback *progress = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
+ Callback *callback = new Callback(To<v8::Function>(info[3]).ToLocalChecked());
AsyncQueueWorker(new ProgressWorker(
callback
, progress
diff --git a/test/cpp/asyncprogressworkersignal.cpp b/test/cpp/asyncprogressworkersignal.cpp
index c59b4e0..6563128 100644
--- a/test/cpp/asyncprogressworkersignal.cpp
+++ b/test/cpp/asyncprogressworkersignal.cpp
@@ -23,7 +23,10 @@ class ProgressWorker : public AsyncProgressWorker {
, int iters)
: AsyncProgressWorker(callback), progress(progress)
, milliseconds(milliseconds), iters(iters) {}
- ~ProgressWorker() {}
+
+ ~ProgressWorker() {
+ delete progress;
+ }
void Execute (const AsyncProgressWorker::ExecutionProgress& progress) {
for (int i = 0; i < iters; ++i) {
@@ -46,8 +49,8 @@ class ProgressWorker : public AsyncProgressWorker {
};
NAN_METHOD(DoProgress) {
- Callback *progress = new Callback(info[2].As<v8::Function>());
- Callback *callback = new Callback(info[3].As<v8::Function>());
+ Callback *progress = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
+ Callback *callback = new Callback(To<v8::Function>(info[3]).ToLocalChecked());
AsyncQueueWorker(new ProgressWorker(
callback
, progress
diff --git a/test/cpp/asyncprogressworkerstream.cpp b/test/cpp/asyncprogressworkerstream.cpp
index 17099aa..d50459e 100644
--- a/test/cpp/asyncprogressworkerstream.cpp
+++ b/test/cpp/asyncprogressworkerstream.cpp
@@ -32,7 +32,10 @@ class ProgressWorker : public AsyncProgressWorkerBase<T> {
, int iters)
: AsyncProgressWorkerBase<T>(callback), progress(progress)
, milliseconds(milliseconds), iters(iters) {}
- ~ProgressWorker() {}
+
+ ~ProgressWorker() {
+ delete progress;
+ }
void Execute (
const typename AsyncProgressWorkerBase<T>::ExecutionProgress& progress) {
@@ -68,8 +71,8 @@ class ProgressWorker : public AsyncProgressWorkerBase<T> {
};
NAN_METHOD(DoProgress) {
- Callback *progress = new Callback(info[2].As<v8::Function>());
- Callback *callback = new Callback(info[3].As<v8::Function>());
+ Callback *progress = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
+ Callback *callback = new Callback(To<v8::Function>(info[3]).ToLocalChecked());
AsyncQueueWorker(new ProgressWorker<data_t>(
callback
, progress
diff --git a/test/cpp/asyncworker.cpp b/test/cpp/asyncworker.cpp
index 8ebf003..90a2b3d 100644
--- a/test/cpp/asyncworker.cpp
+++ b/test/cpp/asyncworker.cpp
@@ -29,7 +29,7 @@ class SleepWorker : public AsyncWorker {
};
NAN_METHOD(DoSleep) {
- Callback *callback = new Callback(info[1].As<v8::Function>());
+ Callback *callback = new Callback(To<v8::Function>(info[1]).ToLocalChecked());
AsyncQueueWorker(
new SleepWorker(callback, To<uint32_t>(info[0]).FromJust()));
}
diff --git a/test/cpp/asyncworkererror.cpp b/test/cpp/asyncworkererror.cpp
index 41993d2..21eb19b 100644
--- a/test/cpp/asyncworkererror.cpp
+++ b/test/cpp/asyncworkererror.cpp
@@ -21,7 +21,7 @@ class ErrorWorker : public AsyncWorker {
};
NAN_METHOD(Work) {
- Callback *callback = new Callback(info[0].As<v8::Function>());
+ Callback *callback = new Callback(To<v8::Function>(info[0]).ToLocalChecked());
AsyncQueueWorker(new ErrorWorker(callback));
info.GetReturnValue().SetUndefined();
}
diff --git a/test/cpp/bufferworkerpersistent.cpp b/test/cpp/bufferworkerpersistent.cpp
index b7394e4..a120055 100644
--- a/test/cpp/bufferworkerpersistent.cpp
+++ b/test/cpp/bufferworkerpersistent.cpp
@@ -51,8 +51,8 @@ class BufferWorker : public AsyncWorker {
};
NAN_METHOD(DoSleep) {
- v8::Local<v8::Object> bufferHandle = info[1].As<v8::Object>();
- Callback *callback = new Callback(info[2].As<v8::Function>());
+ v8::Local<v8::Object> bufferHandle = To<v8::Object>(info[1]).ToLocalChecked();
+ Callback *callback = new Callback(To<v8::Function>(info[2]).ToLocalChecked());
assert(!callback->IsEmpty() && "Callback shoud not be empty");
AsyncQueueWorker(new BufferWorker(
callback
diff --git a/test/cpp/json-stringify.cpp b/test/cpp/json-stringify.cpp
index 17aa73d..09209c8 100644
--- a/test/cpp/json-stringify.cpp
+++ b/test/cpp/json-stringify.cpp
@@ -18,7 +18,7 @@ NAN_METHOD(Stringify) {
if (3 == info.Length()) {
if (info[2]->IsNumber()) {
- int len = info[2]->IntegerValue();
+ int32_t len = Nan::To<int32_t>(info[2]).FromJust();
len = (len > 10) ? 10 : len;
len = (len < 0) ? 0 : len;
Nan::MaybeLocal<v8::String> maybe_gap =
diff --git a/test/cpp/nancallback.cpp b/test/cpp/nancallback.cpp
index 26e62a8..c6311cb 100644
--- a/test/cpp/nancallback.cpp
+++ b/test/cpp/nancallback.cpp
@@ -11,34 +11,34 @@
using namespace Nan; // NOLINT(build/namespaces)
NAN_METHOD(GlobalContext) {
- Callback(info[0].As<v8::Function>()).Call(0, NULL);
+ Callback(To<v8::Function>(info[0]).ToLocalChecked()).Call(0, NULL);
}
NAN_METHOD(SpecificContext) {
- Callback cb(info[0].As<v8::Function>());
+ Callback cb(To<v8::Function>(info[0]).ToLocalChecked());
cb.Call(GetCurrentContext()->Global(), 0, NULL);
}
NAN_METHOD(CustomReceiver) {
- Callback cb(info[0].As<v8::Function>());
- cb.Call(info[1].As<v8::Object>(), 0, NULL);
+ Callback cb(To<v8::Function>(info[0]).ToLocalChecked());
+ cb.Call(To<v8::Object>(info[1]).ToLocalChecked(), 0, NULL);
}
NAN_METHOD(CompareCallbacks) {
- Callback cb1(info[0].As<v8::Function>());
- Callback cb2(info[1].As<v8::Function>());
- Callback cb3(info[2].As<v8::Function>());
+ Callback cb1(To<v8::Function>(info[0]).ToLocalChecked());
+ Callback cb2(To<v8::Function>(info[1]).ToLocalChecked());
+ Callback cb3(To<v8::Function>(info[2]).ToLocalChecked());
info.GetReturnValue().Set(New<v8::Boolean>(cb1 == cb2 && cb1 != cb3));
}
NAN_METHOD(CallDirect) {
- Callback cb(info[0].As<v8::Function>());
+ Callback cb(To<v8::Function>(info[0]).ToLocalChecked());
(*cb)->Call(GetCurrentContext()->Global(), 0, NULL);
}
NAN_METHOD(CallAsFunction) {
- Callback(info[0].As<v8::Function>())();
+ Callback(To<v8::Function>(info[0]).ToLocalChecked())();
}
NAN_METHOD(ResetUnset) {
@@ -48,7 +48,7 @@ NAN_METHOD(ResetUnset) {
}
NAN_METHOD(ResetSet) {
- Callback callback(info[0].As<v8::Function>());
+ Callback callback(To<v8::Function>(info[0]).ToLocalChecked());
callback.Reset();
info.GetReturnValue().Set(callback.IsEmpty());
}
diff --git a/test/cpp/persistent.cpp b/test/cpp/persistent.cpp
index 3bdfe44..652e7fd 100644
--- a/test/cpp/persistent.cpp
+++ b/test/cpp/persistent.cpp
@@ -14,7 +14,7 @@ using namespace Nan; // NOLINT(build/namespaces)
static Persistent<v8::String> persistentTest1;
NAN_METHOD(Save1) {
- persistentTest1.Reset(info[0].As<v8::String>());
+ persistentTest1.Reset(To<v8::String>(info[0]).ToLocalChecked());
}
NAN_METHOD(Get1) {
@@ -26,7 +26,7 @@ NAN_METHOD(Dispose1) {
}
NAN_METHOD(ToPersistentAndBackAgain) {
- Persistent<v8::Object> persistent(info[0].As<v8::Object>());
+ Persistent<v8::Object> persistent(To<v8::Object>(info[0]).ToLocalChecked());
v8::Local<v8::Object> object = New(persistent);
persistent.Reset();
memset(&persistent, -1, sizeof(persistent)); // Clobber it good.
@@ -34,7 +34,7 @@ NAN_METHOD(ToPersistentAndBackAgain) {
}
NAN_METHOD(PersistentToPersistent) {
- Persistent<v8::String> persistent(info[0].As<v8::String>());
+ Persistent<v8::String> persistent(To<v8::String>(info[0]).ToLocalChecked());
persistentTest1.Reset(persistent);
persistent.Reset();
info.GetReturnValue().Set(New(persistentTest1));
diff --git a/test/cpp/private.cpp b/test/cpp/private.cpp
index 19fc10d..c918864 100644
--- a/test/cpp/private.cpp
+++ b/test/cpp/private.cpp
@@ -54,7 +54,7 @@ NAN_METHOD(NoConflict) {
SetPrivate(object, key, value);
Set(object, key, other_value);
v8::Local<v8::Value> got = GetPrivate(object, key).ToLocalChecked();
- bool v1 = got.As<v8::String>()->StrictEquals(value);
+ bool v1 = To<v8::String>(got).ToLocalChecked()->StrictEquals(value);
v8::Local<v8::Value> got_other = Get(object, key).ToLocalChecked();
bool v2 = got_other->StrictEquals(other_value);
DeletePrivate(object, key);
diff --git a/test/cpp/returnvalue.cpp b/test/cpp/returnvalue.cpp
index 5ceb680..a5537c6 100644
--- a/test/cpp/returnvalue.cpp
+++ b/test/cpp/returnvalue.cpp
@@ -16,7 +16,7 @@ NAN_METHOD(ReturnAValue) {
const FunctionCallbackInfo<v8::Value> &cbinfo = info;
ReturnValue<v8::Value> ret = cbinfo.GetReturnValue();
if (cbinfo.Length() == 1) {
- ret.Set(info[0].As<v8::String>());
+ ret.Set(To<v8::String>(info[0]).ToLocalChecked());
} else {
ret.Set(New("default").ToLocalChecked());
}
diff --git a/test/cpp/weak.cpp b/test/cpp/weak.cpp
index 795c7a8..dcb7420 100644
--- a/test/cpp/weak.cpp
+++ b/test/cpp/weak.cpp
@@ -31,8 +31,8 @@ v8::Local<v8::String> wrap(v8::Local<v8::Function> func) {
}
NAN_METHOD(Hustle) {
- cb.Reset(info[1].As<v8::Function>());
- info.GetReturnValue().Set(wrap(info[0].As<v8::Function>()));
+ cb.Reset(To<v8::Function>(info[1]).ToLocalChecked());
+ info.GetReturnValue().Set(wrap(To<v8::Function>(info[0]).ToLocalChecked()));
}
NAN_MODULE_INIT(Init) {
diff --git a/test/cpp/weak2.cpp b/test/cpp/weak2.cpp
index 9687eb2..6f35327 100644
--- a/test/cpp/weak2.cpp
+++ b/test/cpp/weak2.cpp
@@ -36,7 +36,7 @@ v8::Local<v8::String> wrap() {
}
NAN_METHOD(Hustle) {
- cb.Reset(info[0].As<v8::Function>());
+ cb.Reset(To<v8::Function>(info[0]).ToLocalChecked());
info.GetReturnValue().Set(wrap());
}
diff --git a/test/js/asyncprogressworker-test.js b/test/js/asyncprogressqueueworker-test.js
similarity index 79%
copy from test/js/asyncprogressworker-test.js
copy to test/js/asyncprogressqueueworker-test.js
index f2643c0..9d27177 100644
--- a/test/js/asyncprogressworker-test.js
+++ b/test/js/asyncprogressqueueworker-test.js
@@ -8,12 +8,13 @@
const test = require('tap').test
, testRoot = require('path').resolve(__dirname, '..')
- , bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressworker' });
+ , bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressqueueworker' });
-test('asyncprogressworker', function (t) {
- var worker = bindings.a
+test('asyncprogressqueueworker', function (t) {
+ // test with no sleep
+ var worker = bindings.doProgress
, progressed = 0
- worker(100, 5, function(i) {
+ worker(5, function(i) {
t.ok(i === progressed, 'got the progress updates #' + i);
progressed++;
}, function () {
diff --git a/test/js/asyncprogressqueueworkerstream-test.js b/test/js/asyncprogressqueueworkerstream-test.js
new file mode 100644
index 0000000..3386e58
--- /dev/null
+++ b/test/js/asyncprogressqueueworkerstream-test.js
@@ -0,0 +1,54 @@
+/*********************************************************************
+ * NAN - Native Abstractions for Node.js
+ *
+ * Copyright (c) 2017 NAN contributors
+ *
+ * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
+ ********************************************************************/
+
+const test = require('tap').test
+ , testRoot = require('path').resolve(__dirname, '..')
+ , bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressqueueworkerstream' })
+ , util = require('util');
+
+const nodeVersion = process.versions.node.split('.')
+var Readable
+if (nodeVersion[0] == 0 && nodeVersion[1] <= 8)
+ Readable = require('readable-stream')
+else
+ Readable = require('stream').Readable
+
+function StreamProgressWorker(t) {
+ Readable.call(this, {objectMode: true})
+ var self = this
+ // initialize stream from cpp on next tick
+ process.nextTick(function () {
+ var worker = bindings.doProgress
+ worker(5, function(i) {
+ self.push(i)
+ }, function () {
+ self.push(null)
+ })
+ })
+}
+util.inherits(StreamProgressWorker, Readable)
+
+StreamProgressWorker.prototype._read = function (data) {
+
+};
+
+
+test('asyncprogressqueueworker', function (t) {
+ var stream = new StreamProgressWorker(t)
+ var progressed = 0;
+
+ stream
+ .on('end', function() {
+ t.ok(progressed === 5, 'cpp should have sent 5 objects')
+ t.end()
+ })
+ .on('data', function(data) {
+ progressed++
+ console.log(data);
+ })
+})
diff --git a/test/js/asyncprogressworker-test.js b/test/js/asyncprogressworker-test.js
index f2643c0..8f157b0 100644
--- a/test/js/asyncprogressworker-test.js
+++ b/test/js/asyncprogressworker-test.js
@@ -11,6 +11,7 @@ const test = require('tap').test
, bindings = require('bindings')({ module_root: testRoot, bindings: 'asyncprogressworker' });
test('asyncprogressworker', function (t) {
+ // test with 100 ms sleep
var worker = bindings.a
, progressed = 0
worker(100, 5, function(i) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-nan.git
More information about the Pkg-javascript-commits
mailing list