@botmock-api/utils
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,5 +0,12 @@ | ||
const { createIntentMap } = require('../'); | ||
const { createIntentMap, createNodeCollector } = require('../'); | ||
test('returns a Map', () => { | ||
test('`createIntentMap` returns a map', () => { | ||
expect(createIntentMap()).toEqual(new Map()); | ||
}); | ||
test('`createNodeCollector` returns a function', () => { | ||
expect(() => { | ||
createNodeCollector(); | ||
}).not.toThrow(); | ||
expect(createNodeCollector() instanceof Function).toBeTruthy(); | ||
}); |
@@ -39,5 +39,3 @@ // Return a map associating message id and array of intent ids connected to it | ||
// Given an intent map and message-getting function, returns a function that finds | ||
// reachable nodes that do not emanate intents | ||
exports.getIntermediateNodes = (map, getMessage) => | ||
exports.createNodeCollector = (map, getMessage) => | ||
function f(next, collected = []) { | ||
@@ -44,0 +42,0 @@ for (const { message_id } of next) { |
{ | ||
"name": "@botmock-api/utils", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "utilities for handling data from the Botmock API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# utils | ||
```console | ||
``` | ||
npm i @botmock-api/utils | ||
@@ -8,1 +8,17 @@ ``` | ||
utilities for handling data from the Botmock API | ||
### API | ||
``` | ||
import * as utils from '@botmock-api/utils'; | ||
``` | ||
#### `utils.createIntentMap(messages: []): Map<messageId: string, intentIds: string[]>` | ||
Function that returns a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) | ||
which associates message ids with the list of intent ids connected to them | ||
#### `utils.createNodeCollector(map: Map, getter: (id: string) => Object): (next: string[]) => string[]` | ||
Creates function that turns `next_messages` into a collection of _all_ reachable | ||
messages that are not connected by an intent |
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
10445
59
24