Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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 1.0.7 to 1.1.0

15

__tests__/index.ts

@@ -1,3 +0,14 @@

// import { createIntentMap } from "../src";
import { createIntentMap, createMessageCollector } from "../src";
test.todo("..");
describe("intent map creation", () => {
test("returns a map", () => {
expect(createIntentMap([], []) instanceof Map).toBe(true);
});
});
describe("node collector creation", () => {
test("returns a function", () => {
const fn = createMessageCollector(createIntentMap([], []), () => {});
expect(fn instanceof Function).toBe(true);
});
});

@@ -51,1 +51,29 @@ "use strict";

};
/**
* Returns a function that collects all messages not connected by an intent.
*
* @remarks
* This function is importable as {import { createMessageCollector } from "@botmock-api/utils"}.
*
* @param map - Map relating message ids and array of intents connected to them
* @param getMessage - Function that takes message id and returns message from board
* @returns IntentMap
*
* @beta
*/
exports.createMessageCollector = function (map, getMessage) {
return function f(next, collected) {
if (collected === void 0) { collected = []; }
var localCollected = collected;
// iterate of all next messages; if message not found in intent map,
// explore this message's next messages
for (var _i = 0, next_1 = next; _i < next_1.length; _i++) {
var message_id = next_1[_i].message_id;
if (!map.has(message_id)) {
var next_message_ids = getMessage(message_id).next_message_ids;
localCollected = f(next_message_ids, collected.concat([message_id]));
}
}
return localCollected;
};
};

2

package.json
{
"name": "@botmock-api/utils",
"version": "1.0.7",
"version": "1.1.0",
"description": "utilities for handling data from the Botmock API",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

# utils
> this package is unstable and likely to undergo major API changes
This module exposes utilities for handling data from the [Botmock API](https://docs.botmock.com/#introduction).

@@ -4,0 +6,0 @@

@@ -73,1 +73,27 @@ type Utterance = {

};
/**
* Returns a function that collects all messages not connected by an intent.
*
* @remarks
* This function is importable as {import { createMessageCollector } from "@botmock-api/utils"}.
*
* @param map - Map relating message ids and array of intents connected to them
* @param getMessage - Function that takes message id and returns message from board
* @returns IntentMap
*
* @beta
*/
export const createMessageCollector = <A, B>(map: IntentMap, getMessage: any) =>
function f(next: NextMessage[], collected: string[] = []) {
let localCollected = collected;
// iterate of all next messages; if message not found in intent map,
// explore this message's next messages
for (const { message_id } of next) {
if (!map.has(message_id)) {
const { next_message_ids } = getMessage(message_id);
localCollected = f(next_message_ids, [...collected, message_id]);
}
}
return localCollected;
};
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es2017",
"incremental": true,
"sourceMap": true,
"esModuleInterop": true,
"outDir": "dist",

@@ -8,4 +13,2 @@ "declaration": true,

"allowUnreachableCode": false,
"baseUrl": ".",
"checkJs": true,
"lib": ["esnext"],

@@ -17,13 +20,5 @@ "module": "esnext",

"noUnusedLocals": true,
"esModuleInterop": true,
"preserveConstEnums": true,
"pretty": true,
"removeComments": true,
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"types": []
"removeComments": true
},
"exclude": ["node_modules", "dist"]
}
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