@indra.ai/deva 1.1.79 → 1.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +27 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -60,6 +60,7 @@ class Deva {
60
60
  this._message = config.message; // current state of agent.
61
61
  this._messages = {
62
62
  notext: 'NO TEXT WAS PROVIDED',
63
+ nopacket: 'NO PACKET WAS PROVIDED',
63
64
  }; // set the messages from config
64
65
 
65
66
  // then here we are going to loop the messages config to make sure custom values are set
@@ -717,7 +718,6 @@ class Deva {
717
718
  const isCmd = t_split[0].startsWith(this.cmdChr);
718
719
 
719
720
  // Format the packet for return on the request.
720
- const orig = TEXT; // set the TEXT to orig
721
721
  const data = DATA; // set the DATA to data
722
722
  const packet = { // create the base q/a packet
723
723
  id, // set the id into packet
@@ -760,11 +760,10 @@ class Deva {
760
760
  client: this.client() || false, // set the client
761
761
  meta: { // build the meta container
762
762
  key, // set the key variable
763
- orig, // set orig text to track chances
764
763
  method, // set method to track function use
765
764
  params, // set any params that are associated
766
765
  },
767
- text, // set the text after it has been modified form orig
766
+ text, // set the text for the packet.
768
767
  data, // set the data object
769
768
  created: Date.now(), // timestamp the question
770
769
  }
@@ -1784,6 +1783,31 @@ class Deva {
1784
1783
  return parseFloat(n).toFixed(dec) + '%';
1785
1784
  }
1786
1785
 
1786
+ /**************
1787
+ func: trimText
1788
+ params:
1789
+ - text: The text to trim.
1790
+ - maxwords: The number of words to max.
1791
+ describe:
1792
+ A utility function to trimText intput to a specific word count.
1793
+ ***************/
1794
+ trimWords(text, maxwords) {
1795
+ const splitter = text.split(' ');
1796
+ if (splitter < maxwords) return text;
1797
+ return splitter.slice(0, maxwords).join(' ');
1798
+ },
1799
+
1800
+ dupes(dupers) {
1801
+ if (!Array.isArray(dupers)) return dupers;
1802
+ const check = [];
1803
+ return dupers.filter(dupe => {
1804
+ if (!check.includes(dupe)) {
1805
+ check.push(dupe);
1806
+ return dupe;
1807
+ }
1808
+ });
1809
+ },
1810
+
1787
1811
  /**************
1788
1812
  func: error
1789
1813
  params:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.79",
3
+ "version": "1.1.81",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {