From 4c8fd412f74a0989c87c161da231245e82a10227 Mon Sep 17 00:00:00 2001 From: Mason Date: Mon, 29 Oct 2018 16:32:43 -0400 Subject: [PATCH 1/3] Fix some small typos (#267) --- benchmark/README.md | 4 ++-- docs/api/module.md | 2 +- docs/api/store.md | 2 +- examples/modules/plus-number/README.md | 2 +- examples/tutorial/napa-runner/README.md | 8 ++++---- scripts/embedded.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index 02d07edb..84d30a2d 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -11,7 +11,7 @@ We got this report on environment below: | Name | Value | |-------------------|---------------------------------------------------------------------------------------| -|**Processor** |Intel(R) Xeon(R) CPU L5640 @ 2.27GHz, 8 virtual procesors | +|**Processor** |Intel(R) Xeon(R) CPU L5640 @ 2.27GHz, 8 virtual processors | |**System Type** |x64-based PC | |**Physical Memory**|16.0 GB | |**OS version** |Microsoft Windows Server 2012 R2 | @@ -90,7 +90,7 @@ Average overhead is around 0.06ms to 0.12ms for `zone.execute`. ## Transport overhead The overhead of `transport.marshall` includes -1. overhead of needing replacer callback during JSON.stringify. (even empty callback will slowdown JSON.stringfiy significantly) +1. overhead of needing replacer callback during JSON.stringify. (even an empty callback will slow down JSON.stringify significantly) 2. traverse every value during JSON.stringify, to check value type and get `cid` to put into payload. - a. If value doesn't need special care. - b. If value is a transportable object that needs special care. diff --git a/docs/api/module.md b/docs/api/module.md index e5944a08..3fa3dfba 100644 --- a/docs/api/module.md +++ b/docs/api/module.md @@ -27,7 +27,7 @@ Napa.js follows [Node.js' convention](https://nodejs.org/api/modules.html) to su 4) API of creating C++ modules (addons) are similar. Napa.JS introduced macros that the same source code can be compiled to produce both Napa.js addon and Node.js addon. But there are also differences: -1) C++ module that is designed/implemented for Napa.js can run on Node.JS (need different compile flags to produce '.napa' and '.node'). But not vice versal. +1) C++ module that is designed/implemented for Napa.js can run on Node.JS (need different compile flags to produce '.napa' and '.node'). But not vice versa. 2) Napa.js doesn't support all Node.js API. Node API are supported [incrementally](./node-api.md) on the motivation of adding Node.js built-ins and core modules that are needed for computation heavy tasks. You can access full capabilities of Node exposed via [Node zone](./zone.md#node-zone). 3) Napa.js doesn't provide `uv` functionalities, thus built-ins and core modules have its own implementation. To write async function in addon, methods `DoAsyncWork`/`PostAsyncWork` are introduced to work for both Napa.js and Node.js. 4) Napa.js supports embed mode. C++ modules need separate compilation between Node mode and embed mode. diff --git a/docs/api/store.md b/docs/api/store.md index a4d7ee21..9c68e410 100644 --- a/docs/api/store.md +++ b/docs/api/store.md @@ -23,7 +23,7 @@ Though very convenient, it's not recommended to use store to pass values within Following APIs are exposed to create, get and operate upon stores. ### create(id: string): Store -It creates a store by a string identifer that can be used to get the store later. When all references to the store from all JavaScript VMs are cleared, the store will be destroyed. Thus always keep a reference at global or module scope is usually a good practice using `Store`. Error will be thrown if the id already exists. +It creates a store by a string identifier that can be used to get the store later. When all references to the store from all JavaScript VMs are cleared, the store will be destroyed. Thus always keep a reference at global or module scope is usually a good practice using `Store`. Error will be thrown if the id already exists. Example: ```js diff --git a/examples/modules/plus-number/README.md b/examples/modules/plus-number/README.md index f9a340d0..89d5fa5d 100644 --- a/examples/modules/plus-number/README.md +++ b/examples/modules/plus-number/README.md @@ -11,7 +11,7 @@ var obj = addon.createPlusNumber(); ## Wrapped class -*plus-number.h* declares ths class with one constructor and one method, *Add()*. +*plus-number.h* declares the class with one constructor and one method, *Add()*. ```h namespace napa { diff --git a/examples/tutorial/napa-runner/README.md b/examples/tutorial/napa-runner/README.md index 031ee408..0164e14e 100644 --- a/examples/tutorial/napa-runner/README.md +++ b/examples/tutorial/napa-runner/README.md @@ -2,15 +2,15 @@ Napa runner is an example to embed Napa.JS into a C++ program. It simply runs JavaScript with all Napa capability without Node dependency from command line. ## How to build -1. Go to napajs root directory, run "node build.js embed" to build napa library for embeded mode. +1. Go to napajs root directory, run "node build.js embed" to build napa library for embedded mode. -**NOTE**: This step may take about 30 mins, because it will build V8 libray from Node. We are using node v6.10.3, a stable version can build as a library. It is specified in [embedded.js](https://github.com/Microsoft/napajs/blob/master/scripts/embedded.js) and [napa-runner CMakeLists.txt](https://github.com/Microsoft/napajs/blob/master/examples/tutorial/napa-runner/CMakeLists.txt). Please update both of them if you want to use a different version of Node/V8. +**NOTE**: This step may take about 30 mins, because it will build V8 library from Node. We are using node v6.10.3, a stable version can build as a library. It is specified in [embedded.js](https://github.com/Microsoft/napajs/blob/master/scripts/embedded.js) and [napa-runner CMakeLists.txt](https://github.com/Microsoft/napajs/blob/master/examples/tutorial/napa-runner/CMakeLists.txt). Please update both of them if you want to use a different version of Node/V8. 2. Go to directory of "examples/tutorial/napa-runner", and run "cmake-js build" to build napa runner **NOTE**: Build solution of napa-runner is provided only for linux system so far. Windows / Mac OS support will come in near future. ## How to use -1. Run "npm install" to intall required npm modules -2. Run "./bin/napa-runner emstimate-PI.js" +1. Run "npm install" to install required npm modules +2. Run "./bin/napa-runner estimate-PI.js" diff --git a/scripts/embedded.js b/scripts/embedded.js index bba1f875..5c7f139c 100644 --- a/scripts/embedded.js +++ b/scripts/embedded.js @@ -47,7 +47,7 @@ exports.build = function (buildType) { } else { // TODO (asib): support other platforms - console.log("\x1b[1m\x1b[32m", "Napa build solution for embeded mode is not provided for ", os.platform(),'\x1b[0m'); + console.log("\x1b[1m\x1b[32m", "Napa build solution for embedded mode is not provided for ", os.platform(),'\x1b[0m'); return; } From 1546003223ecbc59e5d8a2884abf95b454827bfc Mon Sep 17 00:00:00 2001 From: Algram Date: Mon, 29 Oct 2018 21:33:26 +0100 Subject: [PATCH 2/3] Change var to const in the README.md (#268) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 64b6b57f..011151f0 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Other options can be found in [Build Napa.js](https://github.com/Microsoft/napaj ## Quick Start ```js -var napa = require('napajs'); -var zone1 = napa.zone.create('zone1', { workers: 4 }); +const napa = require('napajs'); +const zone1 = napa.zone.create('zone1', { workers: 4 }); // Broadcast code to all 4 workers in 'zone1'. zone1.broadcast('console.log("hello world");'); From 3e472ac55590ad7e92ca7de4f72c14658b611558 Mon Sep 17 00:00:00 2001 From: hemirt Date: Mon, 29 Oct 2018 21:34:56 +0100 Subject: [PATCH 3/3] Fix small typos (#269) * Fix typos * Fix typos * Fix typos * Fix typos * Fix typos * Fix typo * Fix typo --- examples/modules/README.md | 2 +- examples/modules/async-number/README.md | 12 ++++++------ examples/modules/async-number/napa/addon.cpp | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/modules/README.md b/examples/modules/README.md index 5ed3a76e..96d6fa1a 100644 --- a/examples/modules/README.md +++ b/examples/modules/README.md @@ -27,7 +27,7 @@ The source codes can be organized as the structure below. ## How to build and test ? For the module examples, node-gyp or cmake-js build solution is provided for your reference. -Please make sure [node-gyp](https://github.com/nodejs/node-gyp#installation) or [cmake-js](https://github.com/cmake-js/cmake-js#installation) has been set up correctly at your client, then you could follow the below steps to build and test the module examples. +Please make sure [node-gyp](https://github.com/nodejs/node-gyp#installation) or [cmake-js](https://github.com/cmake-js/cmake-js#installation) has been set up correctly at your client, then you could follow the steps below to build and test the module examples. ``` 1. go to the directory of a module example 2. run "npm install" to build the module diff --git a/examples/modules/async-number/README.md b/examples/modules/async-number/README.md index 6f6b6482..c9327ef1 100644 --- a/examples/modules/async-number/README.md +++ b/examples/modules/async-number/README.md @@ -69,7 +69,7 @@ namespace { std::atomic _now(0); } -/// It increases a number by a given parameter asynchronously and run a callback at the next execution loop. +/// It increases a number by a given parameter asynchronously and runs a callback at the next execution loop. void Increase(const FunctionCallbackInfo& args) { auto isolate = args.GetIsolate(); @@ -81,12 +81,12 @@ void Increase(const FunctionCallbackInfo& args) { napa::module::PostAsyncWork(Local::Cast(args[1]), [value]() { - // This runs at the separate thread. + // This runs in a separate thread. _now += value; return reinterpret_cast(static_cast(_now.load())); }, [](auto jsCallback, void* result) { - // This runs at the same thread as one Increase() is called. + // This runs in the same thread as the one Increase() is called in. auto isolate = Isolate::GetCurrent(); int32_t argc = 1; @@ -98,7 +98,7 @@ void Increase(const FunctionCallbackInfo& args) { ); } -/// It increases a number by a given parameter synchronously and run a callback at the next execution loop. +/// It increases a number by a given parameter synchronously and runs a callback at the next execution loop. void IncreaseSync(const FunctionCallbackInfo& args) { auto isolate = args.GetIsolate(); @@ -110,12 +110,12 @@ void IncreaseSync(const FunctionCallbackInfo& args) { napa::module::DoAsyncWork(Local::Cast(args[1]), [value](auto complete) { - // This runs at the same thread. + // This runs in the same thread. _now += value; complete(reinterpret_cast(static_cast(_now.load()))); }, [](auto jsCallback, void* result) { - // This runs at the same thread as one IncreaseSync() is called. + // This runs in the same thread as the one IncreaseSync() is called in. auto isolate = Isolate::GetCurrent(); int32_t argc = 1; diff --git a/examples/modules/async-number/napa/addon.cpp b/examples/modules/async-number/napa/addon.cpp index 06904e55..ead2f330 100644 --- a/examples/modules/async-number/napa/addon.cpp +++ b/examples/modules/async-number/napa/addon.cpp @@ -16,7 +16,7 @@ namespace { std::atomic _now(0); } -/// It increases a number by a given parameter asynchronously and run a callback at the next execution loop. +/// It increases a number by a given parameter asynchronously and runs a callback at the next execution loop. void Increase(const FunctionCallbackInfo& args) { auto isolate = args.GetIsolate(); @@ -28,12 +28,12 @@ void Increase(const FunctionCallbackInfo& args) { napa::zone::PostAsyncWork(Local::Cast(args[1]), [value]() { - // This runs at the separate thread. + // This runs in a separate thread. _now += value; return reinterpret_cast(static_cast(_now.load())); }, [](auto jsCallback, void* result) { - // This runs at the same thread as one Increase() is called. + // This runs in the same thread as the one Increase() is called in. auto isolate = Isolate::GetCurrent(); int32_t argc = 1; @@ -45,7 +45,7 @@ void Increase(const FunctionCallbackInfo& args) { ); } -/// It increases a number by a given parameter synchronously and run a callback at the next execution loop. +/// It increases a number by a given parameter synchronously and runs a callback at the next execution loop. void IncreaseSync(const FunctionCallbackInfo& args) { auto isolate = args.GetIsolate(); @@ -57,12 +57,12 @@ void IncreaseSync(const FunctionCallbackInfo& args) { napa::zone::DoAsyncWork(Local::Cast(args[1]), [value](auto complete) { - // This runs at the same thread. + // This runs in the same thread. _now += value; complete(reinterpret_cast(static_cast(_now.load()))); }, [](auto jsCallback, void* result) { - // This runs at the same thread as one IncreaseSync() is called. + // This runs in the same thread as the one IncreaseSync() is called in. auto isolate = Isolate::GetCurrent(); int32_t argc = 1;