flamerest 1.0.90 → 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.
- package/REST.d.ts +9 -1
- package/REST.js +7 -2
- package/package.json +1 -1
package/REST.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface IREST {
|
|
|
45
45
|
* @param {string} responseType Тип ответа: json или blob
|
|
46
46
|
* @param {Object} customHeaders объект с доп заголовками, которые надо включить в запрос
|
|
47
47
|
*/
|
|
48
|
-
request(url: string, params: object | string, type?: string, responseType?: 'json' | 'blob', isNeedToken?: boolean, customHeaders?: object): object
|
|
48
|
+
request(url: string, params: object | string, type?: string, responseType?: 'json' | 'blob', isNeedToken?: boolean, customHeaders?: object): Promise<object>,
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* Получить выборку из таблицы через REST
|
|
@@ -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
|
-
|
|
674
|
+
if (readAs === 'data')
|
|
675
|
+
reader.readAsDataURL(file);
|
|
676
|
+
if (readAs === 'text')
|
|
677
|
+
reader.readAsText(file);
|
|
678
|
+
|
|
674
679
|
})
|
|
675
680
|
}
|
|
676
681
|
|