node-datalith 0.1.0 → 0.1.1
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/lib/lib.d.ts +6 -4
- package/lib/lib.js +12 -3
- package/package.json +1 -1
package/lib/lib.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export interface ImagePutOptions extends WithBodyTimeoutOptions {
|
|
|
134
134
|
idleTimeout?: number | null;
|
|
135
135
|
}
|
|
136
136
|
export type ResourceGetOptions = WithBodyTimeoutOptions;
|
|
137
|
+
export type Resolution = `${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}x` | "original";
|
|
137
138
|
export interface ImageGetOptions extends WithBodyTimeoutOptions {
|
|
138
139
|
/**
|
|
139
140
|
* The desired resolution of the image.
|
|
@@ -144,7 +145,7 @@ export interface ImageGetOptions extends WithBodyTimeoutOptions {
|
|
|
144
145
|
*
|
|
145
146
|
* @default undefined (Datalith defaults to `"1x"`)
|
|
146
147
|
*/
|
|
147
|
-
resolution?:
|
|
148
|
+
resolution?: Resolution;
|
|
148
149
|
/**
|
|
149
150
|
* Whether to use a fallback image (in PNG/JPEG format instead of WebP).
|
|
150
151
|
*
|
|
@@ -237,8 +238,9 @@ export declare class Datalith {
|
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
240
|
* Validates if the input string is a valid center crop string (in the format of `"<float>:<float>"`).
|
|
240
|
-
*
|
|
241
|
-
* @param {string}
|
|
242
|
-
* @returns {boolean}
|
|
243
241
|
*/
|
|
244
242
|
export declare const validateCenterCrop: (centerCrop?: string) => boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Validates if the given resolution is either `undefined`, `"original"`, or follows the format of `"<positive integer>x"`.
|
|
245
|
+
*/
|
|
246
|
+
export declare const validateResolution: (resolution?: string) => resolution is Resolution;
|
package/lib/lib.js
CHANGED
|
@@ -341,9 +341,6 @@ export class Datalith {
|
|
|
341
341
|
}
|
|
342
342
|
/**
|
|
343
343
|
* Validates if the input string is a valid center crop string (in the format of `"<float>:<float>"`).
|
|
344
|
-
*
|
|
345
|
-
* @param {string}
|
|
346
|
-
* @returns {boolean}
|
|
347
344
|
*/
|
|
348
345
|
export const validateCenterCrop = (centerCrop) => {
|
|
349
346
|
if (typeof centerCrop === "undefined") {
|
|
@@ -351,3 +348,15 @@ export const validateCenterCrop = (centerCrop) => {
|
|
|
351
348
|
}
|
|
352
349
|
return (/^-?\d+\.?\d*:-?\d+\.?\d*$/).test(centerCrop);
|
|
353
350
|
};
|
|
351
|
+
/**
|
|
352
|
+
* Validates if the given resolution is either `undefined`, `"original"`, or follows the format of `"<positive integer>x"`.
|
|
353
|
+
*/
|
|
354
|
+
export const validateResolution = (resolution) => {
|
|
355
|
+
if (typeof resolution === "undefined") {
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
if (resolution === "original") {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
return (/^[1-9][0-9]*x$/).test(resolution);
|
|
362
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-datalith",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Datalith is a file management system powered by SQLite for metadata storage and the file system for file storage. This library can help you conmunicate with Datalith in Node.js.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/lib.js",
|