@hawksightco/hawk-sdk
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -26,5 +26,7 @@ import { Token } from "../types"; | ||
* @param {string} keyword - The keyword to search for. | ||
* @param {number} limit - Number of results to show. | ||
* @param {boolean} noLimit - disable limit | ||
* @returns {Token[]} An array of tokens that match the given keyword. | ||
*/ | ||
token(keyword: string): Token[]; | ||
token(keyword: string, limit?: number, noLimit?: boolean): Token[]; | ||
/** | ||
@@ -31,0 +33,0 @@ * Loads the token indices and tokens. |
@@ -40,5 +40,9 @@ "use strict"; | ||
* @param {string} keyword - The keyword to search for. | ||
* @param {number} limit - Number of results to show. | ||
* @param {boolean} noLimit - disable limit | ||
* @returns {Token[]} An array of tokens that match the given keyword. | ||
*/ | ||
token(keyword) { | ||
token(keyword, limit = 100, noLimit = false) { | ||
const result = []; | ||
keyword = keyword.trim(); | ||
if (this.tokenIndices === undefined || this.tokens === undefined) { | ||
@@ -49,5 +53,8 @@ console.warn("Token list still loading..."); | ||
const indices = this.tokenIndices.indices[keyword.toLowerCase()]; | ||
const result = []; | ||
let count = 0; | ||
for (const index in indices) { | ||
count++; | ||
result.push(this.tokens[index]); | ||
if (!noLimit && count >= limit) | ||
break; | ||
} | ||
@@ -70,3 +77,3 @@ return result; | ||
yield this.getTokenIndices(); | ||
setTimeout(update, 60 * 1000); | ||
setTimeout(update, 5 * 1000); | ||
}); | ||
@@ -73,0 +80,0 @@ yield update(); |
{ | ||
"name": "@hawksightco/hawk-sdk", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"description": "Hawksight v2 SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130897
2377