Socket
Socket
Sign inDemoInstall

@botmock-api/utils

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botmock-api/utils - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

main.js

51

index.js

@@ -1,50 +0,1 @@

// Return a map associating message id and array of intent ids connected to it
exports.createIntentMap = (messages = []) => {
return new Map(
messages.reduce(
(acc, { next_message_ids }) => [
...acc,
...next_message_ids
.filter(({ intent }) => intent.value)
// Group this message with this intent and others like it (in that they
// also are incident on this message)
.map(message => [
message.message_id,
[
message.intent.value,
...messages.reduce(
(acc, { next_message_ids }) => [
...acc,
// Must have an intent, must not be the one we already have,
// and must be incident on this message
...next_message_ids
.filter(
({ intent, message_id }) =>
intent.value &&
intent.value !== message.intent.value &&
message_id === message.message_id
)
.map(m => m.intent.value)
],
[]
)
]
])
],
[]
)
);
};
exports.createNodeCollector = (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;
};
export { createIntentMap, createNodeCollector } from './src';
{
"name": "@botmock-api/utils",
"version": "0.3.0",
"version": "0.4.0",
"description": "utilities for handling data from the Botmock API",
"main": "index.js",
"module": "index.js",
"module": "main.js",
"scripts": {

@@ -23,3 +23,5 @@ "test": "jest"

"license": "MIT",
"dependencies": {},
"dependencies": {
"esm": "3.2.22"
},
"devDependencies": {

@@ -26,0 +28,0 @@ "jest": "24.7.1"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc