@botmock-api/utils
Advanced tools
Comparing version 0.1.0 to 0.2.0
17
index.js
// 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; | ||
}; |
{ | ||
"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", |
# utils | ||
```console | ||
npm i @botmock/utils | ||
npm i @botmock-api/utils | ||
``` | ||
utilities for handling data from the Botmock API |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9775
55