@j2inn/fin5-ui-utils 6.0.4 → 6.0.5
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/dist/fantomProps/readFantomPropsFile.d.ts +1 -1
- package/dist/fantomProps/readFantomPropsFile.js +17 -13
- package/dist/fantomProps/readFantomPropsFile.js.map +1 -1
- package/dist_es/fantomProps/readFantomPropsFile.d.ts +1 -1
- package/dist_es/fantomProps/readFantomPropsFile.js +17 -13
- package/dist_es/fantomProps/readFantomPropsFile.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Props } from './fantomPropsToObject';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Synchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
|
|
4
4
|
*/
|
|
5
5
|
export default function readFantomPropsFile(path: string): Promise<Props>;
|
|
@@ -29,17 +29,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const fs = __importStar(require("fs"));
|
|
30
30
|
const fantomPropsToObject_1 = require("./fantomPropsToObject");
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* Synchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
|
|
33
33
|
*/
|
|
34
34
|
function readFantomPropsFile(path) {
|
|
35
35
|
return new Promise((resolve, reject) => {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
fs.readFile(path, (err, fileBuffer) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
return reject(err);
|
|
39
|
+
}
|
|
40
|
+
let bufferIndex = 0;
|
|
41
|
+
const bufferLength = fileBuffer.length;
|
|
42
|
+
const unreadBuffer = []; // Stack to handle unreadChar operations
|
|
38
43
|
const readChar = () => {
|
|
39
|
-
|
|
44
|
+
if (unreadBuffer.length > 0) {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
46
|
+
return unreadBuffer.pop();
|
|
47
|
+
}
|
|
48
|
+
if (bufferIndex < bufferLength) {
|
|
49
|
+
return fileBuffer[bufferIndex++];
|
|
50
|
+
}
|
|
51
|
+
return -1;
|
|
40
52
|
};
|
|
41
53
|
const unreadChar = (char) => {
|
|
42
|
-
|
|
54
|
+
unreadBuffer.push(char);
|
|
43
55
|
};
|
|
44
56
|
try {
|
|
45
57
|
resolve((0, fantomPropsToObject_1.parseFantomProps)(readChar, unreadChar));
|
|
@@ -47,14 +59,6 @@ function readFantomPropsFile(path) {
|
|
|
47
59
|
catch (error) {
|
|
48
60
|
reject(error);
|
|
49
61
|
}
|
|
50
|
-
finally {
|
|
51
|
-
try {
|
|
52
|
-
fileStream.close();
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
console.error(err);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
62
|
});
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/readFantomPropsFile.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAwB;AACxB,+DAA+D;AAE/D;;GAEG;AACH,SAAwB,mBAAmB,CAAC,IAAY;IACvD,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,
|
|
1
|
+
{"version":3,"file":"readFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/readFantomPropsFile.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAwB;AACxB,+DAA+D;AAE/D;;GAEG;AACH,SAAwB,mBAAmB,CAAC,IAAY;IACvD,OAAO,IAAI,OAAO,CAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;YACrC,IAAI,GAAG,EAAE;gBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;aAClB;YAED,IAAI,WAAW,GAAG,CAAC,CAAA;YACnB,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CAAA;YACtC,MAAM,YAAY,GAAa,EAAE,CAAA,CAAC,wCAAwC;YAE1E,MAAM,QAAQ,GAAG,GAAW,EAAE;gBAC7B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;oBAC5B,oEAAoE;oBACpE,OAAO,YAAY,CAAC,GAAG,EAAG,CAAA;iBAC1B;gBACD,IAAI,WAAW,GAAG,YAAY,EAAE;oBAC/B,OAAO,UAAU,CAAC,WAAW,EAAE,CAAC,CAAA;iBAChC;gBACD,OAAO,CAAC,CAAC,CAAA;YACV,CAAC,CAAA;YAED,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE;gBACnC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACxB,CAAC,CAAA;YAED,IAAI;gBACH,OAAO,CAAC,IAAA,sCAAgB,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;aAC/C;YAAC,OAAO,KAAK,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAA;aACb;QACF,CAAC,CAAC,CAAA;IACH,CAAC,CAAC,CAAA;AACH,CAAC;AAjCD,sCAiCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Props } from './fantomPropsToObject';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Synchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
|
|
4
4
|
*/
|
|
5
5
|
export default function readFantomPropsFile(path: string): Promise<Props>;
|
|
@@ -4,17 +4,29 @@
|
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import { parseFantomProps } from './fantomPropsToObject';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Synchronously read the given Fantom props file to JS object (@see https://fantom.org/doc/sys/InStream#readProps)
|
|
8
8
|
*/
|
|
9
9
|
export default function readFantomPropsFile(path) {
|
|
10
10
|
return new Promise((resolve, reject) => {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
fs.readFile(path, (err, fileBuffer) => {
|
|
12
|
+
if (err) {
|
|
13
|
+
return reject(err);
|
|
14
|
+
}
|
|
15
|
+
let bufferIndex = 0;
|
|
16
|
+
const bufferLength = fileBuffer.length;
|
|
17
|
+
const unreadBuffer = []; // Stack to handle unreadChar operations
|
|
13
18
|
const readChar = () => {
|
|
14
|
-
|
|
19
|
+
if (unreadBuffer.length > 0) {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
|
+
return unreadBuffer.pop();
|
|
22
|
+
}
|
|
23
|
+
if (bufferIndex < bufferLength) {
|
|
24
|
+
return fileBuffer[bufferIndex++];
|
|
25
|
+
}
|
|
26
|
+
return -1;
|
|
15
27
|
};
|
|
16
28
|
const unreadChar = (char) => {
|
|
17
|
-
|
|
29
|
+
unreadBuffer.push(char);
|
|
18
30
|
};
|
|
19
31
|
try {
|
|
20
32
|
resolve(parseFantomProps(readChar, unreadChar));
|
|
@@ -22,14 +34,6 @@ export default function readFantomPropsFile(path) {
|
|
|
22
34
|
catch (error) {
|
|
23
35
|
reject(error);
|
|
24
36
|
}
|
|
25
|
-
finally {
|
|
26
|
-
try {
|
|
27
|
-
fileStream.close();
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
console.error(err);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
37
|
});
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readFantomPropsFile.js","sourceRoot":"","sources":["../../src/fantomProps/readFantomPropsFile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,gBAAgB,EAAS,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