geonix 1.12.0 → 1.12.2
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/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/Stream.js +7 -3
- package/src/Util.js +2 -0
package/index.d.ts
CHANGED
|
@@ -132,10 +132,10 @@ export class Service {
|
|
|
132
132
|
*/
|
|
133
133
|
export function Stream(data: any, tag?: string): any;
|
|
134
134
|
export function isStream(object: any): any;
|
|
135
|
-
export function getReadable(object: any): Promise<any>;
|
|
135
|
+
export function getReadable(object: any, forceNats?: boolean): Promise<any>;
|
|
136
136
|
export function getReadableOverHTTP(object: any): Promise<any>;
|
|
137
137
|
export function getReadableOverNATS(object: any): Promise<any>;
|
|
138
|
-
export function streamToBuffer(object: any): Promise<any>;
|
|
138
|
+
export function streamToBuffer(object: any, forceNats?: boolean): Promise<any>;
|
|
139
139
|
export function streamToString(object: any): Promise<any>;
|
|
140
140
|
export const stats: {};
|
|
141
141
|
/**
|
package/package.json
CHANGED
package/src/Stream.js
CHANGED
|
@@ -103,10 +103,14 @@ export function isStream(object) {
|
|
|
103
103
|
return object && typeof object === 'object' && object.$ === 'stream'
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
export async function getReadable(object) {
|
|
106
|
+
export async function getReadable(object, forceNats = false) {
|
|
107
107
|
if (!isStream(object))
|
|
108
108
|
return object
|
|
109
109
|
|
|
110
|
+
if (forceNats) {
|
|
111
|
+
return getReadableOverNATS(object);
|
|
112
|
+
}
|
|
113
|
+
|
|
110
114
|
try {
|
|
111
115
|
return await getReadableOverHTTP(object);
|
|
112
116
|
} catch (e) {
|
|
@@ -167,10 +171,10 @@ export async function getReadableOverNATS(object) {
|
|
|
167
171
|
return readable
|
|
168
172
|
}
|
|
169
173
|
|
|
170
|
-
export async function streamToBuffer(object) {
|
|
174
|
+
export async function streamToBuffer(object, forceNats = false) {
|
|
171
175
|
let readable = object
|
|
172
176
|
if (isStream(readable))
|
|
173
|
-
readable = await getReadable(readable)
|
|
177
|
+
readable = await getReadable(readable, forceNats)
|
|
174
178
|
|
|
175
179
|
return Buffer.concat(await readable.toArray())
|
|
176
180
|
}
|