qlcodes 1.0.0 → 1.0.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/README.md +45 -14
- package/package.json +6 -3
- package/qlCodes.json +7601 -1
- package/src/index.mjs +12 -5
- package/types/index.d.ts +5 -0
package/src/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import data from "../qlCodes.json" with { type : "json" };
|
|
2
2
|
export const lens = (code) => {
|
|
3
3
|
let error = {
|
|
4
|
-
code
|
|
4
|
+
code,
|
|
5
5
|
keys: [],
|
|
6
|
+
qlcs: "",
|
|
6
7
|
use: [],
|
|
7
8
|
reason: `The code '${code}' does not match any entries in qlcodes. This may be a qlcode issue only to provide you with the correct information`,
|
|
8
9
|
};
|
|
@@ -21,11 +22,17 @@ export const lens = (code) => {
|
|
|
21
22
|
throw "qlcodes_no_class_found";
|
|
22
23
|
}
|
|
23
24
|
const [_, foundClass] = search;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
let result;
|
|
26
|
+
if (
|
|
27
|
+
foundClass &&
|
|
28
|
+
(result = foundClass.errorSet.find((x) => x.code == paddedCode))
|
|
29
|
+
) {
|
|
30
|
+
error = result;
|
|
31
|
+
console.log(error);
|
|
32
|
+
error.qlcs = "qlcodes_sucess";
|
|
33
|
+
} else throw "qlcodes_no_code_found";
|
|
27
34
|
} catch (err) {
|
|
28
|
-
error.
|
|
35
|
+
error.qlcs = typeof err == "string" ? err : "qlcodes_unexpected_error";
|
|
29
36
|
}
|
|
30
37
|
return error;
|
|
31
38
|
};
|