namirasoft-core 1.4.118 → 1.4.120
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,4 +1,18 @@
|
|
|
1
|
+
export declare enum EncodingOperationPartType {
|
|
2
|
+
Text = "text",
|
|
3
|
+
Key = "key"
|
|
4
|
+
}
|
|
5
|
+
export type EncodingOperationPart = {
|
|
6
|
+
type: EncodingOperationPartType.Text;
|
|
7
|
+
text: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: EncodingOperationPartType.Key;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
1
13
|
export declare class EncodingOperation {
|
|
2
14
|
static Base64Encode(message: string): string;
|
|
3
15
|
static Base64Decode(message: string): string;
|
|
16
|
+
static VariableToStringEncode(key: string, value: string): string;
|
|
17
|
+
static VariableToStringDecode(key: string, text: string): EncodingOperationPart[];
|
|
4
18
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EncodingOperation = void 0;
|
|
3
|
+
exports.EncodingOperation = exports.EncodingOperationPartType = void 0;
|
|
4
|
+
var EncodingOperationPartType;
|
|
5
|
+
(function (EncodingOperationPartType) {
|
|
6
|
+
EncodingOperationPartType["Text"] = "text";
|
|
7
|
+
EncodingOperationPartType["Key"] = "key";
|
|
8
|
+
})(EncodingOperationPartType || (exports.EncodingOperationPartType = EncodingOperationPartType = {}));
|
|
4
9
|
class EncodingOperation {
|
|
5
10
|
static Base64Encode(message) {
|
|
6
11
|
const bytes = new TextEncoder().encode(message);
|
|
@@ -13,6 +18,24 @@ class EncodingOperation {
|
|
|
13
18
|
const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
|
|
14
19
|
return new TextDecoder().decode(bytes);
|
|
15
20
|
}
|
|
21
|
+
static VariableToStringEncode(key, value) {
|
|
22
|
+
return `\${${key}:${value}}`;
|
|
23
|
+
}
|
|
24
|
+
static VariableToStringDecode(key, text) {
|
|
25
|
+
let parts = [];
|
|
26
|
+
let regex = new RegExp(`\\\$\\{${key}:([^}]+)\\}`, "g");
|
|
27
|
+
let last = 0;
|
|
28
|
+
let match;
|
|
29
|
+
while ((match = regex.exec(text)) !== null) {
|
|
30
|
+
if (match.index > last)
|
|
31
|
+
parts.push({ type: EncodingOperationPartType.Text, text: text.substring(last, match.index) });
|
|
32
|
+
parts.push({ type: EncodingOperationPartType.Key, key, value: match[1] });
|
|
33
|
+
last = match.index + match[0].length;
|
|
34
|
+
}
|
|
35
|
+
if (last < text.length)
|
|
36
|
+
parts.push({ type: EncodingOperationPartType.Text, text: text.substring(last) });
|
|
37
|
+
return parts;
|
|
38
|
+
}
|
|
16
39
|
}
|
|
17
40
|
exports.EncodingOperation = EncodingOperation;
|
|
18
41
|
//# sourceMappingURL=EncodingOperation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncodingOperation.js","sourceRoot":"","sources":["../src/EncodingOperation.ts"],"names":[],"mappings":";;;AAAA,MAAa,iBAAiB;IAE1B,MAAM,CAAC,YAAY,CAAC,OAAe;QAE/B,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAChD,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,MAAM,CAAC,YAAY,CAAC,OAAe;QAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CA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,CAAC;QACxD,IAAI,IAAI,GAAG,CAAC,CAAC;QACb,IAAI,KAA6B,CAAC;QAClC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAC1C,CAAC;YACG,IAAI,KAAK,CAAC,KAAK,GAAG,IAAI;gBAClB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAClG,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAC1E,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM;YAClB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrF,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AApCD,8CAoCC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"framework": "npm",
|
|
9
9
|
"application": "package",
|
|
10
10
|
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
11
|
+
"version": "1.4.120",
|
|
12
12
|
"author": "Amir Abolhasani",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": ""
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@types/node": "^26.0.
|
|
20
|
+
"@types/node": "^26.0.1",
|
|
21
21
|
"async-mutex": "^0.5.0",
|
|
22
22
|
"axios": "^1.18.1",
|
|
23
23
|
"moment": "^2.30.1",
|
package/src/EncodingOperation.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export enum EncodingOperationPartType
|
|
2
|
+
{
|
|
3
|
+
Text = "text",
|
|
4
|
+
Key = "key",
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type EncodingOperationPart =
|
|
8
|
+
| { type: EncodingOperationPartType.Text; text: string }
|
|
9
|
+
| { type: EncodingOperationPartType.Key; key: string; value: string };
|
|
10
|
+
|
|
1
11
|
export class EncodingOperation
|
|
2
12
|
{
|
|
3
13
|
static Base64Encode(message: string): string
|
|
@@ -13,4 +23,25 @@ export class EncodingOperation
|
|
|
13
23
|
const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
|
|
14
24
|
return new TextDecoder().decode(bytes);
|
|
15
25
|
}
|
|
26
|
+
static VariableToStringEncode(key: string, value: string): string
|
|
27
|
+
{
|
|
28
|
+
return `\${${key}:${value}}`;
|
|
29
|
+
}
|
|
30
|
+
static VariableToStringDecode(key: string, text: string): EncodingOperationPart[]
|
|
31
|
+
{
|
|
32
|
+
let parts: EncodingOperationPart[] = [];
|
|
33
|
+
let regex = new RegExp(`\\\$\\{${key}:([^}]+)\\}`, "g");
|
|
34
|
+
let last = 0;
|
|
35
|
+
let match: RegExpExecArray | null;
|
|
36
|
+
while ((match = regex.exec(text)) !== null)
|
|
37
|
+
{
|
|
38
|
+
if (match.index > last)
|
|
39
|
+
parts.push({ type: EncodingOperationPartType.Text, text: text.substring(last, match.index) });
|
|
40
|
+
parts.push({ type: EncodingOperationPartType.Key, key, value: match[1] });
|
|
41
|
+
last = match.index + match[0].length;
|
|
42
|
+
}
|
|
43
|
+
if (last < text.length)
|
|
44
|
+
parts.push({ type: EncodingOperationPartType.Text, text: text.substring(last) });
|
|
45
|
+
return parts;
|
|
46
|
+
}
|
|
16
47
|
}
|