This repository was archived by the owner on Sep 3, 2021. It is now read-only.
Commit 4027108
committed
fix: remove direct access to codec lookup table
Use `getCodeVarint()` instead of directly accessing the lookup
table of the multicodec module. This leads to nicer error messages
if the given codec is not found.
Prior to this commit:
buffer.js:183
throw new TypeError(kFromErrorMsg);
^
TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at Function.Buffer.from (buffer.js:183:11)
at CID.get buffer [as buffer] (/home/vmx/src/pl/js-cid/src/index.js:123:18)
at CID.toBaseEncodedString (/home/vmx/src/pl/js-cid/src/index.js:184:44)
at Object.<anonymous> (/home/vmx/src/pl/js-cid/keccak.js:16:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
With this commit:
/home/vmx/src/pl/js-multicodec/src/index.js:73
throw new Error('Codec `' + codecName + '` not found')
^
Error: Codec `mycodec` not found
at Object.exports.getCodeVarint (/home/vmx/src/pl/js-multicodec/src/index.js:73:11)
at CID.get buffer [as buffer] (/home/vmx/src/pl/js-cid/src/index.js:121:38)
at CID.toBaseEncodedString (/home/vmx/src/pl/js-cid/src/index.js:186:44)
at Object.<anonymous> (/home/vmx/src/pl/js-cid/keccak.js:16:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)1 parent 4d7bcf8 commit 4027108
3 files changed
+11
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
120 | 119 | | |
121 | 120 | | |
122 | 121 | | |
123 | | - | |
| 122 | + | |
124 | 123 | | |
125 | 124 | | |
126 | 125 | | |
| |||
137 | 136 | | |
138 | 137 | | |
139 | 138 | | |
140 | | - | |
| 139 | + | |
141 | 140 | | |
142 | 141 | | |
143 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
160 | 168 | | |
161 | 169 | | |
162 | 170 | | |
| |||
0 commit comments