@botmock-api/utils
Advanced tools
+16
-1
| // Return a map associating message id and array of intent ids connected to it | ||
| exports.createIntentMap = function createIntentMap(messages = []) { | ||
| exports.createIntentMap = (messages = []) => { | ||
| return new Map( | ||
@@ -38,1 +38,16 @@ messages.reduce( | ||
| }; | ||
| // Given an intent map and message-getting function, returns a function that finds | ||
| // reachable nodes that do not emanate intents | ||
| exports.getIntermediateNodes = (map, getMessage) => | ||
| function f(next, collected = []) { | ||
| for (const { message_id } of next) { | ||
| // If the provided intent map does not have this message id, recur with | ||
| // this id appended to `collected` | ||
| if (!map.has(message_id)) { | ||
| const { next_message_ids } = getMessage(message_id); | ||
| return f(next_message_ids, [...collected, message_id]); | ||
| } | ||
| } | ||
| return collected; | ||
| }; |
+1
-1
| { | ||
| "name": "@botmock-api/utils", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "description": "utilities for handling data from the Botmock API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+1
-1
| # utils | ||
| ```console | ||
| npm i @botmock/utils | ||
| npm i @botmock-api/utils | ||
| ``` | ||
| utilities for handling data from the Botmock API |
9775
6.11%55
34.15%