Skip to content

Commit a74f1c7

Browse files
committed
fix: make CID#asCID a regular property
1 parent e8def36 commit a74f1c7

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@
157157
"eslintConfig": {
158158
"extends": "ipfs",
159159
"parserOptions": {
160-
"sourceType": "module",
161-
"ecmaVersion": 13
160+
"sourceType": "module"
162161
}
163162
},
164163
"release": {

src/cid.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ const baseCache = cid => {
6161
*/
6262

6363
export class CID {
64-
/** @type {CID} */
65-
#asCID
66-
6764
/**
6865
* @param {Version} version - Version of the CID
6966
* @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
@@ -89,11 +86,7 @@ export class CID {
8986

9087
// Circular reference
9188
/** @readonly */
92-
this.#asCID = this
93-
}
94-
95-
get asCID () {
96-
return this.#asCID
89+
this.asCID = this
9790
}
9891

9992
/**

test/test-cid.spec.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -697,21 +697,15 @@ describe('CID', () => {
697697
assert.throws(() => CID.decode(encoded), 'Invalid CID version 2')
698698
})
699699

700-
it('asCID is non-enumerable', () => {
701-
const cid = CID.parse('bafybeif2pall7dybz7vecqka3zo24irdwabwdi4wc55jznaq75q7eaavvu')
702-
703-
assert.isFalse(Object.prototype.propertyIsEnumerable.call(cid, 'asCID'))
704-
assert.isFalse(Object.keys(cid).includes('asCID'))
705-
assert.equal(cid.asCID, cid)
706-
})
707-
708700
it('CID can be moved across JS realms', async () => {
709701
const cid = CID.parse('bafybeif2pall7dybz7vecqka3zo24irdwabwdi4wc55jznaq75q7eaavvu')
710702
const { port1: sender, port2: receiver } = new MessageChannel()
711703
sender.postMessage(cid)
712704
const cid2 = await new Promise((resolve) => {
713705
receiver.onmessage = (event) => { resolve(event.data) }
714706
})
715-
assert.equal(cid2.asCID, cid2)
707+
assert.strictEqual(cid2.asCID, cid2)
708+
sender.close()
709+
receiver.close()
716710
})
717711
})

0 commit comments

Comments
 (0)