@smithy/core 3.9.0 → 3.9.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.
@@ -653,11 +653,11 @@ var NumericValue = class _NumericValue {
653
653
  return false;
654
654
  }
655
655
  const _nv = object;
656
- const prototypeMatch = _NumericValue.prototype.isPrototypeOf(object.constructor?.prototype);
656
+ const prototypeMatch = _NumericValue.prototype.isPrototypeOf(object);
657
657
  if (prototypeMatch) {
658
658
  return prototypeMatch;
659
659
  }
660
- if (typeof _nv.string === "string" && typeof _nv.type === "string" && _nv.constructor?.name === "NumericValue") {
660
+ if (typeof _nv.string === "string" && typeof _nv.type === "string" && _nv.constructor?.name?.endsWith("NumericValue")) {
661
661
  return true;
662
662
  }
663
663
  return prototypeMatch;
@@ -1,3 +1,37 @@
1
1
  export function printBytes(bytes) {
2
- return [...bytes].map((n) => ("0".repeat(8) + n.toString(2)).slice(-8) + ` (${n})`);
2
+ return [...bytes].map((n) => {
3
+ const pad = (num) => ("0".repeat(8) + num.toString(2)).slice(-8);
4
+ const b = pad(n);
5
+ const [maj, min] = [b.slice(0, 3), b.slice(3)];
6
+ let dmaj = "";
7
+ switch (maj) {
8
+ case "000":
9
+ dmaj = "0 - Uint64";
10
+ break;
11
+ case "001":
12
+ dmaj = "1 - Neg Uint64";
13
+ break;
14
+ case "010":
15
+ dmaj = "2 - unstructured bytestring";
16
+ break;
17
+ case "011":
18
+ dmaj = "3 - utf8 string";
19
+ break;
20
+ case "100":
21
+ dmaj = "4 - list";
22
+ break;
23
+ case "101":
24
+ dmaj = "5 - map";
25
+ break;
26
+ case "110":
27
+ dmaj = "6 - tag";
28
+ break;
29
+ case "111":
30
+ dmaj = "7 - special";
31
+ break;
32
+ default:
33
+ dmaj = String(parseInt(maj, 2));
34
+ }
35
+ return `${maj}_${min} (${dmaj}, ${parseInt(min, 2)})`;
36
+ });
3
37
  }
@@ -28,11 +28,13 @@ export class NumericValue {
28
28
  return false;
29
29
  }
30
30
  const _nv = object;
31
- const prototypeMatch = NumericValue.prototype.isPrototypeOf(object.constructor?.prototype);
31
+ const prototypeMatch = NumericValue.prototype.isPrototypeOf(object);
32
32
  if (prototypeMatch) {
33
33
  return prototypeMatch;
34
34
  }
35
- if (typeof _nv.string === "string" && typeof _nv.type === "string" && _nv.constructor?.name === "NumericValue") {
35
+ if (typeof _nv.string === "string" &&
36
+ typeof _nv.type === "string" &&
37
+ _nv.constructor?.name?.endsWith("NumericValue")) {
36
38
  return true;
37
39
  }
38
40
  return prototypeMatch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.9.0",
3
+ "version": "3.9.1",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",