diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 431d46d8..00000000 --- a/.coveralls.yml +++ /dev/null @@ -1,2 +0,0 @@ -iservice_name: travis-pro -repo_token: $repo_token \ No newline at end of file diff --git a/.npmignore b/.npmignore deleted file mode 100644 index f6c52f55..00000000 --- a/.npmignore +++ /dev/null @@ -1,35 +0,0 @@ -**/node_modules/ -**/*.log -test/repo-tests* - -# Logs -logs -*.log - -coverage - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# node-waf configuration -.lock-wscript - -build - -# Dependency directory -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git -node_modules - -test -docs \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5102ee5f..3df7565a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,41 @@ -# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. -sudo: false language: node_js +cache: npm +stages: + - check + - test + - cov -matrix: - include: - - node_js: 6 - env: CXX=g++-4.8 - - node_js: 8 - env: CXX=g++-4.8 - # - node_js: stable - # env: CXX=g++-4.8 +node_js: + - '10' + - '12' + +os: + - linux + - osx + - windows -script: - - npm run lint - - npm run test - - npm run coverage +script: npx nyc -s npm run test:node -- --bail +after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov + +jobs: + include: + - stage: check + script: + - npx aegir commitlint --travis + - npx aegir dep-check + - npm run lint -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start + - stage: test + name: chrome + addons: + chrome: stable + script: npx aegir test -t browser -t webworker -after_success: - - npm run coverage-publish + - stage: test + name: firefox + addons: + firefox: latest + script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless -addons: - firefox: 'latest' - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 +notifications: + email: false diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 046bf910..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. -version: "{build}" - -environment: - matrix: - - nodejs_version: "6" - - nodejs_version: "8" - -matrix: - fast_finish: true - -install: - # Install Node.js - - ps: Install-Product node $env:nodejs_version - - # Upgrade npm - - npm install -g npm - - # Output our current versions for debugging - - node --version - - npm --version - - # Install our package dependencies - - npm install - -test_script: - - npm run test:node - -build: off diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 00096937..00000000 --- a/circle.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories. -machine: - node: - version: stable - -dependencies: - pre: - - google-chrome --version - - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - - sudo dpkg -i google-chrome.deb || true - - sudo apt-get update - - sudo apt-get install -f - - sudo apt-get install --only-upgrade lsb-base - - sudo dpkg -i google-chrome.deb - - google-chrome --version diff --git a/example.js b/example.js index 21f5513e..de3bb944 100644 --- a/example.js +++ b/example.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ 'use strict' const multihash = require('multihashes') diff --git a/package.json b/package.json index ce480cc7..9989cdd9 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,10 @@ "coverage": "aegir coverage", "coverage-publish": "aegir coverage --provider coveralls" }, + "files": [ + "src", + "dist" + ], "repository": { "type": "git", "url": "git://github.com/multiformats/js-multihash.git" @@ -30,10 +34,12 @@ }, "dependencies": { "bs58": "^4.0.1", + "buffer": "^5.5.0", + "multibase": "^0.6.0", "varint": "^5.0.0" }, "devDependencies": { - "aegir": "^15.1.0", + "aegir": "^21.3.0", "buffer-equal": "1.0.0", "chai": "^4.1.2", "dirty-chai": "^2.0.1", diff --git a/src/index.js b/src/index.js index db77fb3a..e9280050 100644 --- a/src/index.js +++ b/src/index.js @@ -5,16 +5,15 @@ */ 'use strict' -const bs58 = require('bs58') - +const { Buffer } = require('buffer') +const multibase = require('multibase') +const varint = require('varint') const cs = require('./constants') exports.names = cs.names exports.codes = cs.codes exports.defaultLengths = cs.defaultLengths -const varint = require('varint') - /** * Convert the given multihash to a hex encoded string. * @@ -50,7 +49,7 @@ exports.toB58String = function toB58String (hash) { throw new Error('must be passed a buffer') } - return bs58.encode(hash) + return multibase.encode('base58btc', hash).toString().slice(1) } /** @@ -65,7 +64,7 @@ exports.fromB58String = function fromB58String (hash) { encoded = hash.toString() } - return Buffer.from(bs58.decode(encoded)) + return multibase.decode('z' + encoded) } /**