@hawksightco/hawk-sdk 0.0.29 → 0.0.31
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;GAQG;AACH,qBAAa,OAAO;IA2BhB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IA1BhC,iEAAiE;IACjE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,6GAA6G;IAC7G,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,+BAA+B;IAC/B,SAAgB,cAAc,EAAE,cAAc,CAAC;IAE/C,0FAA0F;IAC1F,SAAgB,IAAI,EAAE,IAAI,CAAC;IAE3B,mFAAmF;IACnF,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC,kGAAkG;IAClG,SAAgB,qBAAqB,EAAE,sBAAsB,CAAC;IAE9D,mDAAmD;IACnD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B;;;OAGG;gBAEkB,GAAG,GAAE,MAAoC;
|
|
1
|
+
{"version":3,"file":"HawkAPI.d.ts","sourceRoot":"","sources":["../../../src/classes/HawkAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;;;;;GAQG;AACH,qBAAa,OAAO;IA2BhB,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IA1BhC,iEAAiE;IACjE,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,6GAA6G;IAC7G,SAAgB,OAAO,EAAE,OAAO,CAAC;IAEjC,+BAA+B;IAC/B,SAAgB,cAAc,EAAE,cAAc,CAAC;IAE/C,0FAA0F;IAC1F,SAAgB,IAAI,EAAE,IAAI,CAAC;IAE3B,mFAAmF;IACnF,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC,kGAAkG;IAClG,SAAgB,qBAAqB,EAAE,sBAAsB,CAAC;IAE9D,mDAAmD;IACnD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B;;;OAGG;gBAEkB,GAAG,GAAE,MAAoC;CAa/D"}
|
|
@@ -33,6 +33,8 @@ class HawkAPI {
|
|
|
33
33
|
this.txGenerator = new TxGenerator_1.TxGenerator(client, this.generalUtility);
|
|
34
34
|
this.txGeneratorAutomation = new TxGeneratorAutomations_1.TxGeneratorAutomations(client, this.generalUtility);
|
|
35
35
|
this.search = new Search_1.Search(url);
|
|
36
|
+
// Load search module
|
|
37
|
+
this.search.load();
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
exports.HawkAPI = HawkAPI;
|
|
@@ -23,9 +23,11 @@ export declare class Search {
|
|
|
23
23
|
* If the token indices or tokens are not yet loaded, it logs a warning and returns an empty array.
|
|
24
24
|
*
|
|
25
25
|
* @param {string} keyword - The keyword to search for.
|
|
26
|
+
* @param {number} limit - Number of results to show.
|
|
27
|
+
* @param {boolean} noLimit - disable limit
|
|
26
28
|
* @returns {Token[]} An array of tokens that match the given keyword.
|
|
27
29
|
*/
|
|
28
|
-
token(keyword: string): Token[];
|
|
30
|
+
token(keyword: string, limit?: number, noLimit?: boolean): Token[];
|
|
29
31
|
/**
|
|
30
32
|
* Loads the token indices and tokens.
|
|
31
33
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../src/classes/Search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,MAAM;IAmBf,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IAjBhC,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAAwB;IAE7C;;;;OAIG;gBAEkB,GAAG,EAAE,MAAM;IAGhC
|
|
1
|
+
{"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../src/classes/Search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,MAAM;IAmBf,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IAjBhC,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAAwB;IAE7C;;;;OAIG;gBAEkB,GAAG,EAAE,MAAM;IAGhC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,EAAE,OAAO,GAAE,OAAe,GAAG,KAAK,EAAE;IAiB9E;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B;;;;;;;;;;OAUG;YACW,eAAe;IAgB7B;;;;;;;OAOG;YACW,YAAY;IAI1B;;;;;;;;;;OAUG;YACW,gBAAgB;CAO/B"}
|
|
@@ -37,17 +37,24 @@ class Search {
|
|
|
37
37
|
* If the token indices or tokens are not yet loaded, it logs a warning and returns an empty array.
|
|
38
38
|
*
|
|
39
39
|
* @param {string} keyword - The keyword to search for.
|
|
40
|
+
* @param {number} limit - Number of results to show.
|
|
41
|
+
* @param {boolean} noLimit - disable limit
|
|
40
42
|
* @returns {Token[]} An array of tokens that match the given keyword.
|
|
41
43
|
*/
|
|
42
|
-
token(keyword) {
|
|
44
|
+
token(keyword, limit = 100, noLimit = false) {
|
|
45
|
+
const result = [];
|
|
46
|
+
keyword = keyword.trim();
|
|
43
47
|
if (this.tokenIndices === undefined || this.tokens === undefined) {
|
|
44
48
|
console.warn("Token list still loading...");
|
|
45
49
|
return [];
|
|
46
50
|
}
|
|
47
51
|
const indices = this.tokenIndices.indices[keyword.toLowerCase()];
|
|
48
|
-
|
|
52
|
+
let count = 0;
|
|
49
53
|
for (const index in indices) {
|
|
54
|
+
count++;
|
|
50
55
|
result.push(this.tokens[index]);
|
|
56
|
+
if (!noLimit && count >= limit)
|
|
57
|
+
break;
|
|
51
58
|
}
|
|
52
59
|
return result;
|
|
53
60
|
}
|
|
@@ -65,7 +72,7 @@ class Search {
|
|
|
65
72
|
this._loaded = true;
|
|
66
73
|
const update = () => __awaiter(this, void 0, void 0, function* () {
|
|
67
74
|
yield this.getTokenIndices();
|
|
68
|
-
setTimeout(update,
|
|
75
|
+
setTimeout(update, 5 * 1000);
|
|
69
76
|
});
|
|
70
77
|
yield update();
|
|
71
78
|
}
|