@indra.ai/deva 1.1.100 → 1.1.102

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 +8 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1012,11 +1012,6 @@ class Deva {
1012
1012
  delete data.hash;
1013
1013
  data.hash = this.hash(data);
1014
1014
 
1015
- if (this.info) {
1016
- const _info = this.info(data.id);
1017
- this.prompt(_info);
1018
- }
1019
-
1020
1015
  this.action(data.value);
1021
1016
  const hasOnStart = this.onStart && typeof this.onStart === 'function' ? true : false;
1022
1017
  return hasOnStart ? this.onStart(data) : this.enter(data)
@@ -1063,7 +1058,7 @@ class Deva {
1063
1058
  data.hash = this.hash(data);
1064
1059
  this.action(data.value)
1065
1060
  const hasOnDone = this.onDone && typeof this.onDone === 'function' ? true : false;
1066
- return hasOnDone ? this.onDone(data) : Promise.resolve(data);
1061
+ return hasOnDone ? this.onDone(data) : this.finish(data);
1067
1062
  }
1068
1063
 
1069
1064
  /**************
@@ -1081,7 +1076,11 @@ class Deva {
1081
1076
  if (!this._active) return Promise.resolve(this._messages.states.offline);
1082
1077
  this.state('finish');
1083
1078
  this.action('finish');
1084
- return resolve(packet);
1079
+ const hasOnFinish = this.onFinish && typeof this.onFinish === 'function' ? true : false;
1080
+ if (hasOnFinish) return this.onFinish(packet, resolve);
1081
+ else if (resolve) return resolve(packet);
1082
+ else return Promise.resolve(packet)
1083
+ return resolve ? resolve(packet) : Promise.resolve(packet);
1085
1084
  }
1086
1085
 
1087
1086
  /**************
@@ -1546,19 +1545,8 @@ class Deva {
1546
1545
  This function will enable fast loading of Deva into a system.
1547
1546
  ***************/
1548
1547
  load(key, client) {
1549
- return new Promise((resolve, reject) => {
1550
- this.state('load');
1551
- this.devas[key].init(client).then(loaded => {
1552
- this.talk(config.events.load, {
1553
- id:this.uid(true),
1554
- key,
1555
- created: Date.now(),
1556
- });
1557
- return this.finish(this._messages.states.load, resolve);
1558
- }).catch(err => {
1559
- return this.error(err, deva, reject);
1560
- })
1561
- });
1548
+ this.state('load');
1549
+ return this.devas[key].init(client);
1562
1550
  }
1563
1551
 
1564
1552
  /**************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indra.ai/deva",
3
- "version": "1.1.100",
3
+ "version": "1.1.102",
4
4
  "description": "The Deva Core",
5
5
  "main": "index.js",
6
6
  "scripts": {