From b2961654899ebee28a373f3a4d2e65fa05e7f962 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 27 Aug 2022 14:10:29 +0200 Subject: [PATCH] Add Flatbuffers support to NodeJS bindings --- docs/nodejs/api.md | 16 +++++++++------- src/nodejs/node_osrm.cpp | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index 422068ca2..076e5025d 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -334,13 +334,15 @@ specific behaviours. - `plugin_config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Object literal containing parameters for the trip query. - `plugin_config.format` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The format of the result object to various API calls. - Valid options are `object` (default if `options.format` is `json`), which returns a - standard Javascript object, as described above, and `buffer`(default if `options.format` is `flatbuffers`), which will return a NodeJS - **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string or Flatbuffers object. The latter has - the advantage that it can be immediately serialized to disk/sent over the network, and the - generation of the string is performed outside the main NodeJS event loop. This option is ignored - by the `tile` plugin. Also note that `options.format` set to `flatbuffers` cannot be used with `plugin_config.format` set to `object`. - `json_buffer` is deprecated alias for `buffer`. + Valid options are `object` (default if `options.format` is + `json`), which returns a standard Javascript object, as described above, and `buffer`(default if + `options.format` is `flatbuffers`), which will return a NodeJS + **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string or Flatbuffers + object. The latter has the advantage that it can be immediately serialized to disk/sent over the + network, and the generation of the string is performed outside the main NodeJS event loop. This + option is ignored by the `tile` plugin. Also note that `options.format` set to `flatbuffers` + cannot be used with `plugin_config.format` set to `object`. `json_buffer` is deprecated alias for + `buffer`. **Examples** diff --git a/src/nodejs/node_osrm.cpp b/src/nodejs/node_osrm.cpp index b08a5f4b7..01ee2a451 100644 --- a/src/nodejs/node_osrm.cpp +++ b/src/nodejs/node_osrm.cpp @@ -627,13 +627,15 @@ NAN_METHOD(Engine::trip) // * @name Configuration * @param {Object} [plugin_config] - Object literal containing parameters for the trip query. * @param {String} [plugin_config.format] The format of the result object to various API calls. - * Valid options are `object` (default if `options.format` is `json`), which returns a - * standard Javascript object, as described above, and `buffer`(default if `options.format` is `flatbuffers`), which will return a NodeJS - * **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string or Flatbuffers object. The latter has - * the advantage that it can be immediately serialized to disk/sent over the network, and the - * generation of the string is performed outside the main NodeJS event loop. This option is ignored - * by the `tile` plugin. Also note that `options.format` set to `flatbuffers` cannot be used with `plugin_config.format` set to `object`. - * `json_buffer` is deprecated alias for `buffer`. + * Valid options are `object` (default if `options.format` is + * `json`), which returns a standard Javascript object, as described above, and `buffer`(default if + * `options.format` is `flatbuffers`), which will return a NodeJS + * **[Buffer](https://nodejs.org/api/buffer.html)** object, containing a JSON string or Flatbuffers + * object. The latter has the advantage that it can be immediately serialized to disk/sent over the + * network, and the generation of the string is performed outside the main NodeJS event loop. This + * option is ignored by the `tile` plugin. Also note that `options.format` set to `flatbuffers` + * cannot be used with `plugin_config.format` set to `object`. `json_buffer` is deprecated alias for + * `buffer`. * * @example * var osrm = new OSRM('network.osrm');