@configura/web-utilities 3.0.0-alpha.1 → 3.0.0-alpha.3
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/dist/PromiseCache.js +9 -23
- package/dist/cmMips.js +1 -1
- package/dist/utilitiesFile.js +16 -27
- package/dist/utilitiesImage.js +6 -17
- package/dist/utilitiesUnits.js +2 -2
- package/package.json +2 -2
package/dist/PromiseCache.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { GenericCache } from "./GenericCache.js";
|
|
11
2
|
export class PromiseCache extends GenericCache {
|
|
12
|
-
get(key, createMissing) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.delete(key);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return item;
|
|
25
|
-
});
|
|
3
|
+
async get(key, createMissing) {
|
|
4
|
+
return super.get(key, () => {
|
|
5
|
+
const item = createMissing();
|
|
6
|
+
if (item !== undefined) {
|
|
7
|
+
item.catch(() => {
|
|
8
|
+
this.delete(key);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return item;
|
|
26
12
|
});
|
|
27
13
|
}
|
|
28
14
|
}
|
package/dist/cmMips.js
CHANGED
|
@@ -20,7 +20,7 @@ const CMMIPS_VERBOSE = false;
|
|
|
20
20
|
export function extractCmMips(bytes, logger, maxRes) {
|
|
21
21
|
try {
|
|
22
22
|
if (bytes === undefined || bytes.length < 6) {
|
|
23
|
-
logger.error("(CmMips) Input array undefined or much too short", bytes
|
|
23
|
+
logger.error("(CmMips) Input array undefined or much too short", bytes?.length);
|
|
24
24
|
return undefined;
|
|
25
25
|
}
|
|
26
26
|
const stream = new CmMipsStream(bytes);
|
package/dist/utilitiesFile.js
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (target === null) {
|
|
17
|
-
reject(new Error("No target"));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const result = target.result;
|
|
21
|
-
if (!(result instanceof ArrayBuffer)) {
|
|
22
|
-
reject(new Error("No ArrayBuffer"));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
resolve({ buffer: result, fileName: fileReference.name });
|
|
26
|
-
});
|
|
27
|
-
reader.readAsArrayBuffer(fileReference);
|
|
1
|
+
export async function readFileToArrayBuffer(fileReference) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const reader = new FileReader();
|
|
4
|
+
reader.addEventListener("load", (e) => {
|
|
5
|
+
const target = e.target;
|
|
6
|
+
if (target === null) {
|
|
7
|
+
reject(new Error("No target"));
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const result = target.result;
|
|
11
|
+
if (!(result instanceof ArrayBuffer)) {
|
|
12
|
+
reject(new Error("No ArrayBuffer"));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
resolve({ buffer: result, fileName: fileReference.name });
|
|
28
16
|
});
|
|
17
|
+
reader.readAsArrayBuffer(fileReference);
|
|
29
18
|
});
|
|
30
19
|
}
|
|
31
20
|
export function getFileExtension(filename) {
|
package/dist/utilitiesImage.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export function loadImage(url) {
|
|
11
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
const image = new Image();
|
|
14
|
-
image.onload = () => resolve(image);
|
|
15
|
-
image.onerror = () => reject(Error(`Failed to load image ${url}`));
|
|
16
|
-
image.src = url;
|
|
17
|
-
});
|
|
1
|
+
export async function loadImage(url) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const image = new Image();
|
|
4
|
+
image.onload = () => resolve(image);
|
|
5
|
+
image.onerror = () => reject(Error(`Failed to load image ${url}`));
|
|
6
|
+
image.src = url;
|
|
18
7
|
});
|
|
19
8
|
}
|
package/dist/utilitiesUnits.js
CHANGED
|
@@ -10,7 +10,7 @@ export const isEqualLength = (l, r) => l.length === convertLength(r.length, r.un
|
|
|
10
10
|
*/
|
|
11
11
|
export function toLengthUnit(unit) {
|
|
12
12
|
// The list below must EXACTLY match isLengthUnit(string)
|
|
13
|
-
unit = unit
|
|
13
|
+
unit = unit?.toLowerCase();
|
|
14
14
|
if (unit === "inch") {
|
|
15
15
|
unit = "in";
|
|
16
16
|
}
|
|
@@ -29,7 +29,7 @@ export function toLengthUnit(unit) {
|
|
|
29
29
|
*/
|
|
30
30
|
export function isLengthUnit(unit) {
|
|
31
31
|
// The list below must EXACTLY match toLengthUnit(string)
|
|
32
|
-
unit = unit
|
|
32
|
+
unit = unit?.toLowerCase();
|
|
33
33
|
return (unit === "inch" ||
|
|
34
34
|
unit === "in" ||
|
|
35
35
|
unit === "ft" ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-utilities",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "4332ed866e78584bfa40bf2d6a3258108dc4093c"
|
|
26
26
|
}
|