Skip to content

Commit 91f677b

Browse files
committed
fix: additional lint items from Link interface work
1 parent c12db2a commit 91f677b

File tree

8 files changed

+18
-23
lines changed

8 files changed

+18
-23
lines changed

src/block.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function * tree (source, base) {
9494
* @template T
9595
* @param {T} source
9696
* @param {string[]} path
97-
* @return {API.BlockCursorView<unknown>}
97+
* @returns {API.BlockCursorView<unknown>}
9898
*/
9999
function get (source, path) {
100100
let node = /** @type {Record<string, any>} */(source)
@@ -153,7 +153,7 @@ class Block {
153153
/**
154154
*
155155
* @param {string} [path]
156-
* @return {API.BlockCursorView<unknown>}
156+
* @returns {API.BlockCursorView<unknown>}
157157
*/
158158
get (path = '/') {
159159
return get(this.value, path.split('/').filter(Boolean))

src/block/interface.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unnecessary-type-constraint */
22
/* eslint-disable no-use-before-define */
33
import { Link, Version } from '../link/interface.js'
4-
import { CID } from "../cid.js"
4+
import { CID } from '../cid.js'
55

66
/**
77
* A byte-encoded representation of some type of `Data`.
@@ -14,6 +14,8 @@ import { CID } from "../cid.js"
1414
*/
1515
export interface ByteView<Data> extends Uint8Array, Phantom<Data> {}
1616

17+
declare const Marker: unique symbol
18+
1719
/**
1820
* A utility type to retain an unused type parameter `T`.
1921
* Similar to [phantom type parameters in Rust](https://doc.rust-lang.org/rust-by-example/generics/phantom.html).
@@ -32,7 +34,6 @@ export interface Phantom<T> {
3234
// type contstraint.
3335
[Marker]?: T
3436
}
35-
declare const Marker: unique symbol
3637

3738
/**
3839
* Represents an IPLD block (including its CID) that can be decoded to data of
@@ -66,7 +67,7 @@ export interface BlockView<
6667
cid: CID<T, C, A, V>
6768
value: T
6869

69-
links(): Iterable<[string, CID]>
70-
tree(): Iterable<string>
71-
get(path:string): BlockCursorView<unknown>
70+
links: () => Iterable<[string, CID]>
71+
tree: () => Iterable<string>
72+
get: (path: string) => BlockCursorView<unknown>
7273
}

src/cid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const format = (link, base) => {
3535
}
3636
}
3737

38-
/** @type {WeakMap<API.UnknownLink, Map<string, string>>} */
38+
/** @type {WeakMap<API.UnknownLink, Map<string, string>>} */
3939
const cache = new WeakMap()
4040

4141
/**
@@ -174,7 +174,7 @@ export class CID {
174174
* @template {API.Version} Version
175175
* @param {API.Link<Data, Format, Alg, Version>} self
176176
* @param {unknown} other
177-
* @returns {other is cid}
177+
* @returns {other is CID}
178178
*/
179179
static equals (self, other) {
180180
const unknown =

src/hashes/digest.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const create = (code, digest) => {
2727
* @param {Uint8Array} multihash
2828
* @returns {MultihashDigest}
2929
*/
30-
export const decode = multihash => {
30+
export const decode = (multihash) => {
3131
const bytes = coerce(multihash)
3232
const [code, sizeOffset] = varint.decode(bytes)
3333
const [size, digestOffset] = varint.decode(bytes.subarray(sizeOffset))
@@ -49,9 +49,7 @@ export const equals = (a, b) => {
4949
if (a === b) {
5050
return true
5151
} else {
52-
const data = /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */ (
53-
b
54-
)
52+
const data = /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */(b)
5553

5654
return (
5755
a.code === data.code &&

src/link/interface.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { MultihashDigest } from '../hashes/interface'
44
import type { MultibaseEncoder, MultibaseDecoder, Multibase } from '../bases/interface'
55
import type { Phantom, ByteView } from '../block/interface'
66

7-
87
export type { MultihashDigest, MultibaseEncoder, MultibaseDecoder }
98
export type Version = 0 | 1
109

@@ -33,14 +32,13 @@ export interface Link<
3332
readonly byteLength: number
3433
readonly bytes: ByteView<Link<Data, Format, Alg, V>>
3534

35+
equals: (other: unknown) => other is Link<Data, Format, Alg, Version>
3636

37-
equals(other: unknown): other is Link<Data, Format, Alg, Version>
38-
39-
toString<Prefix extends string>(base?: MultibaseEncoder<Prefix>): ToString<Link<Data, Format, Alg, Version>, Prefix>
40-
toJSON(): { version: V, code: Format, hash: Uint8Array }
41-
link(): Link<Data, Format, Alg, V>
37+
toString: <Prefix extends string>(base?: MultibaseEncoder<Prefix>) => ToString<Link<Data, Format, Alg, Version>, Prefix>
38+
toJSON: () => { version: V, code: Format, hash: Uint8Array }
39+
link: () => Link<Data, Format, Alg, V>
4240

43-
toV1(): Link<Data, Format, Alg, 1>
41+
toV1: () => Link<Data, Format, Alg, 1>
4442
}
4543

4644
export interface LegacyLink<T extends unknown = unknown> extends Link<T, DAG_PB, SHA_256, 0> {

src/traversal.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { base58btc } from './bases/base58.js'
1616
*/
1717

1818
/**
19-
* @template T
2019
* @param {object} options
2120
* @param {CID} options.cid
2221
* @param {(cid: CID) => Promise<BlockView|null>} options.load
File renamed without changes.

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
],
4040
"multiformats/*": [
4141
"./src/*.js"
42-
],
43-
42+
]
4443
}
4544
},
4645
"include": [

0 commit comments

Comments
 (0)