Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Commit

Permalink
fix: multihashes does not export default lengths any more
Browse files Browse the repository at this point in the history
Since multiformats/js-multihash#76 was released
the `multihashes` module does not export default hash lengths any more.

For reasons that are unclear it went out as a patch release which means
`ipld-git` is currently broken.

This PR hard codes the hash length as it is known, and also removes
the `multihashes` dep as we can use the one exported from `multihashing-async`
and updates other deps.

Ref: multiformats/js-multihash#76 (comment)
  • Loading branch information
achingbrain authored and vmx committed Jun 19, 2020
1 parent e5f2209 commit 4f85c53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@
},
"homepage": "https://github.com/ipld/js-ipld-git",
"dependencies": {
"cids": "~0.8.0",
"multicodec": "^1.0.0",
"multihashes": "~0.4.14",
"multihashing-async": "~0.8.0",
"smart-buffer": "^4.0.2",
"strftime": "~0.10.0"
"cids": "^0.8.2",
"multicodec": "^1.0.2",
"multihashing-async": "^0.8.1",
"smart-buffer": "^4.1.0",
"strftime": "^0.10.0"
},
"devDependencies": {
"aegir": "^22.0.0",
"aegir": "^23.0.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"dirty-chai": "^2.0.1"
Expand Down
5 changes: 2 additions & 3 deletions src/util/util.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
'use strict'

const multihashes = require('multihashes/src/constants')
const multihash = require('multihashes')
const multihash = require('multihashing-async').multihash
const CID = require('cids')
const strftime = require('strftime')

exports = module.exports

exports.SHA1_LENGTH = multihashes.defaultLengths[multihashes.names.sha1]
exports.SHA1_LENGTH = 20

exports.find = (buf, byte) => {
for (let i = 0; i < buf.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ chai.use(chaiAsProised)
chai.use(dirtyChai)
const ipldGit = require('../src')
const multicodec = require('multicodec')
const multihash = require('multihashes')
const multihash = require('multihashing-async').multihash
const CID = require('cids')

describe('IPLD format util', () => {
Expand Down

0 comments on commit 4f85c53

Please sign in to comment.