This repository was archived by the owner on Aug 24, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 33'use strict'
44
55exports . names = Object . freeze ( {
6- 'id' : 0x0 ,
6+ 'identity' : 0x0 ,
77 'sha1' : 0x11 ,
88 'sha2-256' : 0x12 ,
99 'sha2-512' : 0x13 ,
@@ -343,6 +343,8 @@ exports.names = Object.freeze({
343343} )
344344
345345exports . codes = Object . freeze ( {
346+ 0x0 : 'identity' ,
347+
346348 0x11 : 'sha1' ,
347349 0x12 : 'sha2-256' ,
348350 0x13 : 'sha2-512' ,
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ exports.decode = function decode (buf) {
118118 * @returns {Buffer }
119119 */
120120exports . encode = function encode ( digest , code , length ) {
121- if ( ! digest || ! code ) {
121+ if ( ! digest || code == undefined ) {
122122 throw new Error ( 'multihash encode requires at least two args: digest, code' )
123123 }
124124
@@ -154,7 +154,7 @@ exports.coerceCode = function coerceCode (name) {
154154 let code = name
155155
156156 if ( typeof name === 'string' ) {
157- if ( ! cs . names [ name ] ) {
157+ if ( cs . names [ name ] === undefined ) {
158158 throw new Error ( `Unrecognized hash function named: ${ name } ` )
159159 }
160160 code = cs . names [ name ]
@@ -164,7 +164,7 @@ exports.coerceCode = function coerceCode (name) {
164164 throw new Error ( `Hash function code should be a number. Got: ${ code } ` )
165165 }
166166
167- if ( ! cs . codes [ code ] && ! exports . isAppCode ( code ) ) {
167+ if ( cs . codes [ code ] === undefined && ! exports . isAppCode ( code ) ) {
168168 throw new Error ( `Unrecognized function code: ${ code } ` )
169169 }
170170
Original file line number Diff line number Diff line change @@ -28,4 +28,11 @@ module.exports = [{
2828 } ,
2929 hex : '2c26b46b' ,
3030 size : 4
31+ } , {
32+ encoding : {
33+ code : 0x0 ,
34+ name : 'identity'
35+ } ,
36+ hex : '7465737420737472696e6720f09f918d' ,
37+ size : 16
3138} ]
You can’t perform that action at this time.
0 commit comments