bkper-js 2.12.1 → 2.12.2
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.
- package/lib/model/Transaction.js +8 -1
- package/lib/utils.js +14 -0
- package/package.json +2 -2
package/lib/model/Transaction.js
CHANGED
|
@@ -155,7 +155,14 @@ export class Transaction extends Resource {
|
|
|
155
155
|
* @returns All #hashtags used on the transaction
|
|
156
156
|
*/
|
|
157
157
|
getTags() {
|
|
158
|
-
|
|
158
|
+
if (this.payload.tags && this.payload.tags.length > 0) {
|
|
159
|
+
return this.payload.tags;
|
|
160
|
+
}
|
|
161
|
+
const description = this.getDescription();
|
|
162
|
+
if (description && description.includes('#')) {
|
|
163
|
+
return Utils.extractTagsFromText(description);
|
|
164
|
+
}
|
|
165
|
+
return [];
|
|
159
166
|
}
|
|
160
167
|
/**
|
|
161
168
|
* Gets all URLs associated with the transaction.
|
package/lib/utils.js
CHANGED
|
@@ -20,6 +20,20 @@ export function repeatString(text, times) {
|
|
|
20
20
|
return text + repeatString(text, times - 1);
|
|
21
21
|
;
|
|
22
22
|
}
|
|
23
|
+
export function extractTagsFromText(text) {
|
|
24
|
+
if (!text || typeof text !== 'string') {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const tagRegex = /#([a-zA-Z0-9_]+)/g;
|
|
28
|
+
const tagsSet = new Set();
|
|
29
|
+
let match;
|
|
30
|
+
while ((match = tagRegex.exec(text)) !== null) {
|
|
31
|
+
if (match[1]) {
|
|
32
|
+
tagsSet.add(match[1]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return Array.from(tagsSet);
|
|
36
|
+
}
|
|
23
37
|
//SAME AS bkper-app
|
|
24
38
|
var diacriticsMap_ = null;
|
|
25
39
|
export function round(number, fractionDigits) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bkper-js",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.2",
|
|
4
4
|
"description": "Javascript client for Bkper REST API",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"license": "Apache-2.0",
|
|
16
16
|
"private": false,
|
|
17
17
|
"scripts": {
|
|
18
|
-
"test": "env TS_NODE_COMPILER_OPTIONS='{\"rootDir\": \".\" }' mocha -r ts-node/register 'test/**/*.ts'",
|
|
18
|
+
"test": "env TS_NODE_COMPILER_OPTIONS='{\"rootDir\": \".\", \"lib\": [\"es2020\", \"dom\"] }' mocha -r ts-node/register 'test/**/*.ts'",
|
|
19
19
|
"clean": "rm -rf ./lib & rm -rf ./node_modules & wait",
|
|
20
20
|
"prebuild": "bun install",
|
|
21
21
|
"build": "run-s build:*",
|