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/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: "-1",
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
- if (foundClass)
25
- error = foundClass.errorSet.find((x) => (x.code = paddedCode));
26
- else throw "qlcodes_no_code_found";
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.keys = [typeof err == "string" ? err : "qlcodes_unexpected_error"];
35
+ error.qlcs = typeof err == "string" ? err : "qlcodes_unexpected_error";
29
36
  }
30
37
  return error;
31
38
  };
package/types/index.d.ts CHANGED
@@ -20,6 +20,11 @@ export interface QLLens {
20
20
  * Human-readable explanation of the error.
21
21
  */
22
22
  reason: string;
23
+
24
+ /**
25
+ * Status of the lens method call
26
+ */
27
+ qlcs: string;
23
28
  }
24
29
 
25
30
  /**