@stemy/ngx-utils 19.8.4 → 19.8.6
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.
|
@@ -1671,6 +1671,18 @@ class FileUtils {
|
|
|
1671
1671
|
// @dynamic
|
|
1672
1672
|
reader => reader.readAsText(file));
|
|
1673
1673
|
}
|
|
1674
|
+
static async readFileAsBinaryString(file) {
|
|
1675
|
+
const arrayBuffer = await FileUtils.readFile(
|
|
1676
|
+
// @dynamic
|
|
1677
|
+
reader => reader.readAsArrayBuffer(file));
|
|
1678
|
+
const bytes = new Uint8Array(arrayBuffer);
|
|
1679
|
+
let binary = "";
|
|
1680
|
+
// Convert ArrayBuffer to binary string
|
|
1681
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1682
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1683
|
+
}
|
|
1684
|
+
return binary;
|
|
1685
|
+
}
|
|
1674
1686
|
static readFileAsDataURL(file) {
|
|
1675
1687
|
return FileUtils.readFile(
|
|
1676
1688
|
// @dynamic
|
|
@@ -1756,7 +1768,7 @@ class FileUtils {
|
|
|
1756
1768
|
// @dynamic
|
|
1757
1769
|
(resolve, reject) => {
|
|
1758
1770
|
const reader = new FileReader();
|
|
1759
|
-
reader.onload = (
|
|
1771
|
+
reader.onload = () => resolve(reader.result);
|
|
1760
1772
|
reader.onerror = reject;
|
|
1761
1773
|
callback(reader);
|
|
1762
1774
|
});
|