Skip to content

Commit 426b6e3

Browse files
author
Joel Thorstensson
authored
feat: support name in ls
1 parent b1ec205 commit 426b6e3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pin/ls.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { toUrlSearchParams } from '../lib/to-url-search-params.js'
33
import type { PinAPI, PinLsResult } from './index.js'
44
import type { HTTPRPCClient } from '../lib/core.js'
55

6-
function toPin (type: string, cid: string, metadata: Record<string, string>): PinLsResult {
6+
function toPin (type: string, cid: string, metadata: Record<string, string>, name: string): PinLsResult {
77
const pin: PinLsResult = {
88
type,
99
cid: CID.parse(cid)
@@ -12,6 +12,9 @@ function toPin (type: string, cid: string, metadata: Record<string, string>): Pi
1212
if (metadata != null) {
1313
pin.metadata = metadata
1414
}
15+
if (name != null) {
16+
pin.name = name
17+
}
1518

1619
return pin
1720
}
@@ -37,12 +40,12 @@ export function createLs (client: HTTPRPCClient): PinAPI['ls'] {
3740
for await (const pin of res.ndjson()) {
3841
if (pin.Keys != null) { // non-streaming response
3942
for (const cid of Object.keys(pin.Keys)) {
40-
yield toPin(pin.Keys[cid].Type, cid, pin.Keys[cid].Metadata)
43+
yield toPin(pin.Keys[cid].Type, cid, pin.Keys[cid].Metadata, pin.Keys[cid].Name)
4144
}
4245
return
4346
}
4447

45-
yield toPin(pin.Type, pin.Cid, pin.Metadata)
48+
yield toPin(pin.Type, pin.Cid, pin.Metadata, pin.Keys[cid].Name)
4649
}
4750
}
4851
}

0 commit comments

Comments
 (0)