Skip to content

Commit cf9a68d

Browse files
committed
Revert "fix: update aegir and revert varint"
This reverts commit d0a413f.
1 parent 4e2b52f commit cf9a68d

File tree

10 files changed

+52
-87
lines changed

10 files changed

+52
-87
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15-
- run: npm install
16-
- run: npx aegir lint
17-
- uses: gozala/[email protected].8
18-
- run: npx aegir build
19-
- run: npx aegir dep-check
15+
- run: yarn
16+
- run: yarn lint
17+
- uses: gozala/[email protected].4
18+
- run: yarn build
19+
- run: yarn aegir dep-check
2020
- uses: ipfs/aegir/actions/bundle-size@master
21+
name: size
2122
with:
2223
github_token: ${{ secrets.GITHUB_TOKEN }}
2324
test-node:
@@ -33,45 +34,34 @@ jobs:
3334
- uses: actions/setup-node@v1
3435
with:
3536
node-version: ${{ matrix.node }}
36-
- run: npm install
37-
- run: npx aegir test -t node --bail --cov
37+
- run: yarn
38+
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
3839
- uses: codecov/codecov-action@v1
3940
test-chrome:
4041
needs: check
4142
runs-on: ubuntu-latest
4243
steps:
4344
- uses: actions/checkout@v2
44-
- uses: microsoft/playwright-github-action@v1
45-
- run: npm install
46-
- run: npx aegir test -t browser -t webworker --bail --cov
47-
- uses: codecov/codecov-action@v1
45+
- run: yarn
46+
- run: npx aegir test -t browser -t webworker --bail
4847
test-firefox:
4948
needs: check
5049
runs-on: ubuntu-latest
5150
steps:
5251
- uses: actions/checkout@v2
53-
- uses: microsoft/playwright-github-action@v1
54-
- run: npm install
55-
- run: npx aegir test -t browser -t webworker --bail -- --browser firefox
56-
test-webkit:
57-
needs: check
58-
runs-on: ubuntu-latest
59-
steps:
60-
- uses: actions/checkout@v2
61-
- uses: microsoft/playwright-github-action@v1
62-
- run: npm install
63-
- run: npx aegir test -t browser -t webworker --bail -- --browser webkit
52+
- run: yarn
53+
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
6454
test-electron-main:
6555
needs: check
6656
runs-on: ubuntu-latest
6757
steps:
6858
- uses: actions/checkout@v2
69-
- run: npm install
59+
- run: yarn
7060
- run: npx xvfb-maybe aegir test -t electron-main --bail
7161
test-electron-renderer:
7262
needs: check
7363
runs-on: ubuntu-latest
7464
steps:
7565
- uses: actions/checkout@v2
76-
- run: npm install
66+
- run: yarn
7767
- run: npx xvfb-maybe aegir test -t electron-renderer --bail

package.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"release": "aegir release",
2424
"release-minor": "aegir release --type minor",
2525
"release-major": "aegir release --type major",
26+
"coverage": "aegir coverage",
27+
"coverage-publish": "aegir coverage --provider coveralls",
2628
"update-table": "node tools/update-table.js"
2729
},
2830
"pre-push": [
@@ -48,23 +50,14 @@
4850
},
4951
"homepage": "https://github.com/multiformats/js-multicodec#readme",
5052
"dependencies": {
51-
"uint8arrays": "^2.1.3",
52-
"varint": "^5.0.2"
53+
"uint8arrays": "1.1.0",
54+
"varint": "^6.0.0"
5355
},
5456
"devDependencies": {
55-
"@types/varint": "^5.0.0",
56-
"aegir": "^31.0.1",
57+
"aegir": "^29.2.2",
5758
"bent": "^7.3.12",
5859
"pre-push": "~0.1.1"
5960
},
60-
"eslintConfig": {
61-
"extends": "ipfs"
62-
},
63-
"aegir": {
64-
"build": {
65-
"bundlesizeMax": "6.7kB"
66-
}
67-
},
6861
"contributors": [
6962
"Henrique Dias <[email protected]>",
7063
"David Dias <[email protected]>",

src/generated-table.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ const baseTable = Object.freeze({
104104
'udt': 0x012d,
105105
'utp': 0x012e,
106106
'unix': 0x0190,
107-
'thread': 0x0196,
108107
'p2p': 0x01a5,
109108
'ipfs': 0x01a5,
110109
'https': 0x01bb,

src/generated-types.d.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/generated-types.ts

Lines changed: 21 additions & 0 deletions
Large diffs are not rendered by default.

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function addPrefix (multicodecStrOrCode, data) {
4949
* @returns {Uint8Array}
5050
*/
5151
function rmPrefix (data) {
52-
varint.decode(/** @type {Buffer} */(data))
52+
varint.decode(data)
5353
return data.slice(varint.decode.bytes)
5454
}
5555

@@ -60,7 +60,7 @@ function rmPrefix (data) {
6060
* @returns {CodecName}
6161
*/
6262
function getNameFromData (prefixedData) {
63-
const code = /** @type {CodecCode} */(varint.decode(/** @type {Buffer} */(prefixedData)))
63+
const code = varint.decode(prefixedData)
6464
const name = codeToName[code]
6565
if (name === undefined) {
6666
throw new Error(`Code "${code}" not found`)
@@ -99,7 +99,7 @@ function getCodeFromName (name) {
9999
* @returns {CodecCode}
100100
*/
101101
function getCodeFromData (prefixedData) {
102-
return /** @type {CodecCode} */(varint.decode(/** @type {Buffer} */(prefixedData)))
102+
return varint.decode(prefixedData)
103103
}
104104

105105
/**

src/maps.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
/** @typedef {import('./generated-types').ConstantCodeMap} ConstantCodeMap */
44
/** @typedef {import('./generated-types').NameUint8ArrayMap} NameUint8ArrayMap */
55
/** @typedef {import('./generated-types').CodeNameMap} CodeNameMap */
6-
/** @typedef {import('./generated-types').CodecName} CodecName */
7-
/** @typedef {import('./generated-types').CodecConstant} CodecConstant */
86

97
const { baseTable } = require('./generated-table')
108
const varintEncode = require('./util').varintEncode
@@ -13,17 +11,15 @@ const nameToVarint = /** @type {NameUint8ArrayMap} */ ({})
1311
const constantToCode = /** @type {ConstantCodeMap} */({})
1412
const codeToName = /** @type {CodeNameMap} */({})
1513

16-
// eslint-disable-next-line guard-for-in
1714
for (const name in baseTable) {
18-
const codecName = /** @type {CodecName} */(name)
19-
const code = baseTable[codecName]
20-
nameToVarint[codecName] = varintEncode(code)
15+
const code = baseTable[name]
16+
nameToVarint[name] = varintEncode(code)
2117

22-
const constant = /** @type {CodecConstant} */(codecName.toUpperCase().replace(/-/g, '_'))
18+
const constant = name.toUpperCase().replace(/-/g, '_')
2319
constantToCode[constant] = code
2420

2521
if (!codeToName[code]) {
26-
codeToName[code] = codecName
22+
codeToName[code] = name
2723
}
2824
}
2925

src/util.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@ module.exports = {
1111
varintEncode
1212
}
1313

14-
/**
15-
* @param {Uint8Array} buf
16-
*/
1714
function uint8ArrayToNumber (buf) {
1815
return parseInt(uint8ArrayToString(buf, 'base16'), 16)
1916
}
2017

21-
/**
22-
* @param {number} num
23-
*/
2418
function numberToUint8Array (num) {
2519
let hexString = num.toString(16)
2620
if (hexString.length % 2 === 1) {
@@ -29,16 +23,10 @@ function numberToUint8Array (num) {
2923
return uint8ArrayFromString(hexString, 'base16')
3024
}
3125

32-
/**
33-
* @param {Uint8Array} input
34-
*/
3526
function varintUint8ArrayEncode (input) {
3627
return Uint8Array.from(varint.encode(uint8ArrayToNumber(input)))
3728
}
3829

39-
/**
40-
* @param {number} num
41-
*/
4230
function varintEncode (num) {
4331
return Uint8Array.from(varint.encode(num))
4432
}

test/multicodec.spec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ describe('multicodec', () => {
6161
})
6262

6363
it('returns all codec numbers from names', () => {
64-
// eslint-disable-next-line guard-for-in
6564
for (const name in nameToCode) {
66-
expect(multicodec.getCodeFromName(/** @type {CodecName} */(name))).to.eql(nameToCode[/** @type {CodecName} */(name)])
65+
expect(multicodec.getCodeFromName(/** @type {CodecName} */(name))).to.eql(nameToCode[name])
6766
}
6867
})
6968

tools/update-table.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ const run = async () => {
3232
/**
3333
* Constant names for all available codecs
3434
*/
35-
export type CodecConstant = ${names.map(n => `${n.toUpperCase().replace(/-/g, '_')}`).join(' | ')}
35+
export type CodecConstant = ${names.map(n => `${n.toUpperCase().replace(/-/g, '_')}`).join(' | ')};
3636
3737
/**
3838
* Names for all available codecs
3939
*/
40-
export type CodecName = ${names.join(' | ')}
40+
export type CodecName = ${names.join(' | ')};
4141
4242
/**
4343
* Number for all available codecs
4444
*/
45-
export type CodecCode = ${codes.join(' | ')}
45+
export type CodecCode = ${codes.join(' | ')};
4646
4747
export type ConstantCodeMap = Record<CodecConstant, CodecCode>
4848
export type NameUint8ArrayMap = Record<CodecName, Uint8Array>
@@ -64,7 +64,7 @@ ${processed}
6464
module.exports = { baseTable }
6565
`
6666

67-
fs.writeFileSync(path.join(__dirname, '../src/generated-types.d.ts'), typesTemplate)
67+
fs.writeFileSync(path.join(__dirname, '../src/generated-types.ts'), typesTemplate)
6868
fs.writeFileSync(path.join(__dirname, '../src/generated-table.js'), tableTemplate)
6969
}
7070

0 commit comments

Comments
 (0)