pg-mvc-service 2.0.7 → 2.0.8
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.
|
@@ -17,7 +17,10 @@ const pdf_lib_1 = require("pdf-lib");
|
|
|
17
17
|
const sharp_1 = __importDefault(require("sharp"));
|
|
18
18
|
const type_utils_n_daira_1 = require("type-utils-n-daira");
|
|
19
19
|
class Base64Client {
|
|
20
|
-
constructor() {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.PREFIX_JPEG_DATA = '/9j/';
|
|
22
|
+
this.PREFIX_PNG_DATA = 'iVBORw0KGgo';
|
|
23
|
+
}
|
|
21
24
|
// public encode(text: string): string {
|
|
22
25
|
// return Buffer.from(text).toString('base64');
|
|
23
26
|
// }
|
|
@@ -151,7 +154,7 @@ class Base64Client {
|
|
|
151
154
|
return Buffer.from(pdfBytes);
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
|
-
|
|
157
|
+
isJpeg(value) {
|
|
155
158
|
if (type_utils_n_daira_1.ValidateStringUtil.isBase64(value) === false) {
|
|
156
159
|
return false;
|
|
157
160
|
}
|
|
@@ -167,7 +170,7 @@ class Base64Client {
|
|
|
167
170
|
}
|
|
168
171
|
return value.startsWith(this.PREFIX_JPEG_DATA);
|
|
169
172
|
}
|
|
170
|
-
|
|
173
|
+
isPng(value) {
|
|
171
174
|
if (type_utils_n_daira_1.ValidateStringUtil.isBase64(value) === false) {
|
|
172
175
|
return false;
|
|
173
176
|
}
|
|
@@ -183,7 +186,7 @@ class Base64Client {
|
|
|
183
186
|
}
|
|
184
187
|
return value.startsWith(this.PREFIX_PNG_DATA);
|
|
185
188
|
}
|
|
186
|
-
|
|
189
|
+
tryConvertToPng(base64Value) {
|
|
187
190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
188
191
|
if (type_utils_n_daira_1.ValidateStringUtil.isBase64(base64Value) === false) {
|
|
189
192
|
return false;
|
|
@@ -208,5 +211,3 @@ class Base64Client {
|
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
exports.Base64Client = Base64Client;
|
|
211
|
-
Base64Client.PREFIX_JPEG_DATA = '/9j/';
|
|
212
|
-
Base64Client.PREFIX_PNG_DATA = 'iVBORw0KGgo';
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@ export type TPdf = 'application/pdf';
|
|
|
11
11
|
export type TJson = 'application/json';
|
|
12
12
|
|
|
13
13
|
export class Base64Client {
|
|
14
|
-
public
|
|
15
|
-
public
|
|
14
|
+
public readonly PREFIX_JPEG_DATA = '/9j/';
|
|
15
|
+
public readonly PREFIX_PNG_DATA = 'iVBORw0KGgo';
|
|
16
16
|
|
|
17
17
|
constructor() { }
|
|
18
18
|
|
|
@@ -157,7 +157,7 @@ export class Base64Client {
|
|
|
157
157
|
return Buffer.from(pdfBytes);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
public
|
|
160
|
+
public isJpeg(value: any): value is string {
|
|
161
161
|
if (ValidateStringUtil.isBase64(value) === false) {
|
|
162
162
|
return false
|
|
163
163
|
}
|
|
@@ -178,7 +178,7 @@ export class Base64Client {
|
|
|
178
178
|
return value.startsWith(this.PREFIX_JPEG_DATA);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
public
|
|
181
|
+
public isPng(value: any): value is string {
|
|
182
182
|
if (ValidateStringUtil.isBase64(value) === false) {
|
|
183
183
|
return false
|
|
184
184
|
}
|
|
@@ -199,7 +199,7 @@ export class Base64Client {
|
|
|
199
199
|
return value.startsWith(this.PREFIX_PNG_DATA);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
public
|
|
202
|
+
public async tryConvertToPng(base64Value: any): Promise<string | false> {
|
|
203
203
|
if (ValidateStringUtil.isBase64(base64Value) === false) {
|
|
204
204
|
return false;
|
|
205
205
|
}
|