eliza-core
Version:
A rendition of ELIZA program engine by Weizenbaum sharable for all javascript environments
24 lines (23 loc) • 692 B
JavaScript
import flattenDepth from 'lodash/flattenDepth';
export function cartesian(a, b) {
const oneProd = a.map(d => b.map(e => [d, e]));
return flattenDepth(oneProd, 1);
}
export function notEmpty(value) {
return value !== null && value !== undefined;
}
export function getAssembledReply(ctx, defaultMsg) {
if (ctx && ctx.assembled && ctx.assembled.reassembled) {
return ctx.assembled.reassembled;
}
return defaultMsg || null;
}
export function getAssembledContext(ctx) {
if (ctx && ctx.assembled) {
return {
reassembled: ctx.assembled.reassembled,
annotations: ctx.assembled.annotations || {},
};
}
return null;
}