Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Botmock/utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

utils

this package is unstable and likely to undergo major API changes

This module exposes utilities for handling data from the Botmock API.

It uses TypeScript and is installable by running:

npm i @botmock-api/utils@latest

API

All of the following functions are accessible via import * as utils from "@botmock-api/utils".

utils.createIntentMap(messages: Message[], intents: Intent[]): IntentMap

Returns a map of message ids and any intents connected to them.

utils.createMessageCollector(map: IntentMap, getMessage: (id: string) => Message): () => string[]

Returns a function that collects all messages not connected by an intent.

utils.topoSort(messages: Message[]): Message[]

Creates linear order of messages such that if (m1, m2) is a connection in the board, m1 appears before m2 in the linear order.