flamerest 1.0.91 → 1.0.92

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.
Files changed (3) hide show
  1. package/REST.d.ts +8 -0
  2. package/REST.js +7 -2
  3. package/package.json +1 -1
package/REST.d.ts CHANGED
@@ -172,6 +172,14 @@ interface IREST {
172
172
  */
173
173
  fillObject<T>(object: T, values: any): T,
174
174
 
175
+ /**
176
+ * Прочесть файл асинхронно
177
+ * @param {File} file
178
+ * @param {'data' | 'text'} readAs
179
+ * @returns {Promise<string>}
180
+ */
181
+ readFileAsync(file: File, readAs: 'data' | 'text'): Promise<string>
182
+
175
183
  }
176
184
 
177
185
 
package/REST.js CHANGED
@@ -658,9 +658,10 @@ class FLAMEREST {
658
658
  /**
659
659
  * Прочесть файл асинхронно
660
660
  * @param {File} file
661
+ * @param {'data' | 'text'} readAs
661
662
  * @returns {Promise<string>}
662
663
  */
663
- readFileAsync(file) {
664
+ readFileAsync(file, readAs = 'data') {
664
665
  return new Promise((resolve, reject) => {
665
666
  let reader = new FileReader();
666
667
 
@@ -670,7 +671,11 @@ class FLAMEREST {
670
671
 
671
672
  reader.onerror = reject;
672
673
 
673
- reader.readAsDataURL(file);
674
+ if (readAs === 'data')
675
+ reader.readAsDataURL(file);
676
+ if (readAs === 'text')
677
+ reader.readAsText(file);
678
+
674
679
  })
675
680
  }
676
681
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flamerest",
3
- "version": "1.0.91",
3
+ "version": "1.0.92",
4
4
  "description": "",
5
5
  "main": "REST.js",
6
6
  "typings": "./REST.d.ts",