@agoric/internal 0.3.3-dev-f9d9d51.0.f9d9d51 → 0.3.3-dev-1c76ea7.0.1c76ea7
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/package.json +4 -4
- package/src/hex.d.ts.map +1 -1
- package/src/hex.js +14 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/internal",
|
|
3
|
-
"version": "0.3.3-dev-
|
|
3
|
+
"version": "0.3.3-dev-1c76ea7.0.1c76ea7",
|
|
4
4
|
"description": "Externally unsupported utilities internal to agoric-sdk",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint:types": "yarn run -T tsgo --tsBuildInfoFile tsconfig.tsgo.tsbuildinfo"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
27
|
+
"@agoric/base-zone": "0.1.1-dev-1c76ea7.0.1c76ea7",
|
|
28
28
|
"@endo/cache-map": "^1.1.0",
|
|
29
29
|
"@endo/common": "^1.4.0",
|
|
30
30
|
"@endo/compartment-mapper": "^2.3.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"jessie.js": "^0.3.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
45
|
+
"@agoric/cosmic-proto": "0.4.1-dev-1c76ea7.0.1c76ea7",
|
|
46
46
|
"@endo/exo": "^1.7.0",
|
|
47
47
|
"@endo/init": "^1.1.13",
|
|
48
48
|
"@endo/ses-ava": "^1.4.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"typeCoverage": {
|
|
71
71
|
"atLeast": 95.63
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "1c76ea7d31a3bfad7bcdf526a7f24b72e6b793b2"
|
|
74
74
|
}
|
package/src/hex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["hex.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["hex.js"],"names":[],"mappings":"AAmCO,wCAFM,QAAQ,CAyBpB;AAgBM,iDAJI,oBAAoB,GAElB,QAAQ,CAoBpB;8BA1FmB,UAAU,KAAK,MAAM;8BACrB,MAAM,KAAK,UAAU;;eAD3B,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM;eAC3B,CAAC,GAAG,EAAE,MAAM,KAAK,UAAU;;;;;mCA0D5B,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG;IACvD,SAAS,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC;CAClD"}
|
package/src/hex.js
CHANGED
|
@@ -18,18 +18,15 @@ const encodings = Array.from({ length: 256 }, (_, b) =>
|
|
|
18
18
|
*
|
|
19
19
|
* @type {Map<string, number>}
|
|
20
20
|
*/
|
|
21
|
-
const decodings = new Map(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
];
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
21
|
+
const decodings = new Map();
|
|
22
|
+
for (const [b, hexdigits] of encodings.entries()) {
|
|
23
|
+
const lo = hexdigits.toLowerCase();
|
|
24
|
+
const UP = hexdigits.toUpperCase();
|
|
25
|
+
decodings.set(lo, b);
|
|
26
|
+
decodings.set(`${lo[0]}${UP[1]}`, b);
|
|
27
|
+
decodings.set(`${UP[0]}${lo[1]}`, b);
|
|
28
|
+
decodings.set(UP, b);
|
|
29
|
+
}
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
32
|
* Create a hex codec that is portable across standard JS environments.
|
|
@@ -83,12 +80,12 @@ export const makeBufferishHexCodec = Bufferish => {
|
|
|
83
80
|
decodeHex: hex => {
|
|
84
81
|
const buf = Bufferish.from(hex, 'hex');
|
|
85
82
|
|
|
83
|
+
if (buf.byteLength * 2 !== hex.length) {
|
|
84
|
+
throw new Error(`Invalid hex string: ${hex}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
86
87
|
// Coerce to Uint8Array to avoid leaking the abstraction.
|
|
87
|
-
const u8a = new Uint8Array(
|
|
88
|
-
buf.buffer,
|
|
89
|
-
buf.byteOffset,
|
|
90
|
-
buf.byteLength / Uint8Array.BYTES_PER_ELEMENT,
|
|
91
|
-
);
|
|
88
|
+
const u8a = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
92
89
|
return u8a;
|
|
93
90
|
},
|
|
94
91
|
};
|