Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit cf9133a

Browse files
authored
deps: update all it-* deps to the latest versions (#57)
1 parent f51c2bf commit cf9133a

File tree

4 files changed

+29
-27
lines changed

4 files changed

+29
-27
lines changed

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@
146146
"@libp2p/interfaces": "^3.2.0",
147147
"@libp2p/logger": "^2.0.0",
148148
"abortable-iterator": "^4.0.2",
149-
"it-first": "^2.0.0",
149+
"it-first": "^3.0.1",
150150
"it-handshake": "^4.1.2",
151-
"it-length-prefixed": "^8.0.3",
151+
"it-length-prefixed": "^9.0.0",
152152
"it-merge": "^3.0.0",
153-
"it-pipe": "^2.0.4",
153+
"it-pipe": "^3.0.0",
154154
"it-pushable": "^3.1.0",
155155
"it-reader": "^6.0.1",
156156
"it-stream-types": "^1.0.4",
@@ -160,10 +160,10 @@
160160
},
161161
"devDependencies": {
162162
"@types/varint": "^6.0.0",
163-
"aegir": "^37.2.0",
163+
"aegir": "^38.1.8",
164164
"iso-random-stream": "^2.0.2",
165165
"it-all": "^3.0.1",
166-
"it-map": "^2.0.0",
166+
"it-map": "^3.0.2",
167167
"it-pair": "^2.0.3",
168168
"p-timeout": "^6.0.0",
169169
"timeout-abort-controller": "^3.0.0",

src/multistream.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function encode (buffer: Uint8Array | Uint8ArrayList): Uint8ArrayList {
2828
/**
2929
* `write` encodes and writes a single buffer
3030
*/
31-
export function write (writer: Pushable<any>, buffer: Uint8Array | Uint8ArrayList, options: MultistreamSelectInit = {}) {
31+
export function write (writer: Pushable<any>, buffer: Uint8Array | Uint8ArrayList, options: MultistreamSelectInit = {}): void {
3232
const encoded = encode(buffer)
3333

3434
if (options.writeBytes === true) {
@@ -41,7 +41,7 @@ export function write (writer: Pushable<any>, buffer: Uint8Array | Uint8ArrayLis
4141
/**
4242
* `writeAll` behaves like `write`, except it encodes an array of items as a single write
4343
*/
44-
export function writeAll (writer: Pushable<any>, buffers: Uint8Array[], options: MultistreamSelectInit = {}) {
44+
export function writeAll (writer: Pushable<any>, buffers: Uint8Array[], options: MultistreamSelectInit = {}): void {
4545
const list = new Uint8ArrayList()
4646

4747
for (const buf of buffers) {
@@ -71,13 +71,13 @@ export async function read (reader: Reader, options?: AbortOptions): Promise<Uin
7171
}
7272

7373
// Once the length has been parsed, read chunk for that length
74-
const onLength = (l: number) => {
74+
const onLength = (l: number): void => {
7575
byteLength = l
7676
}
7777

7878
const buf = await pipe(
7979
input,
80-
lp.decode({ onLength, maxDataLength: MAX_PROTOCOL_LENGTH }),
80+
(source) => lp.decode(source, { onLength, maxDataLength: MAX_PROTOCOL_LENGTH }),
8181
async (source) => await first(source)
8282
)
8383

@@ -93,7 +93,7 @@ export async function read (reader: Reader, options?: AbortOptions): Promise<Uin
9393
return buf.sublist(0, -1) // Remove newline
9494
}
9595

96-
export async function readString (reader: Reader, options?: AbortOptions) {
96+
export async function readString (reader: Reader, options?: AbortOptions): Promise<string> {
9797
const buf = await read(reader, options)
9898

9999
return uint8ArrayToString(buf.subarray())

src/select.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,25 @@ export function lazySelect (stream: Duplex<any>, protocol: string): ProtocolStre
122122
let negotiated = false
123123
return {
124124
stream: {
125-
sink: async source => await stream.sink((async function * () {
126-
let first = true
127-
for await (const chunk of merge(source, negotiateTrigger)) {
128-
if (first) {
129-
first = false
130-
negotiated = true
131-
negotiateTrigger.end()
132-
const p1 = uint8ArrayFromString(PROTOCOL_ID)
133-
const p2 = uint8ArrayFromString(protocol)
134-
const list = new Uint8ArrayList(multistream.encode(p1), multistream.encode(p2))
135-
if (chunk.length > 0) list.append(chunk)
136-
yield * list
137-
} else {
138-
yield chunk
125+
sink: async source => {
126+
await stream.sink((async function * () {
127+
let first = true
128+
for await (const chunk of merge(source, negotiateTrigger)) {
129+
if (first) {
130+
first = false
131+
negotiated = true
132+
negotiateTrigger.end()
133+
const p1 = uint8ArrayFromString(PROTOCOL_ID)
134+
const p2 = uint8ArrayFromString(protocol)
135+
const list = new Uint8ArrayList(multistream.encode(p1), multistream.encode(p2))
136+
if (chunk.length > 0) list.append(chunk)
137+
yield * list
138+
} else {
139+
yield chunk
140+
}
139141
}
140-
}
141-
})()),
142+
})())
143+
},
142144
source: (async function * () {
143145
if (!negotiated) negotiateTrigger.push(new Uint8Array())
144146
const byteReader = reader(stream.source)

test/listener.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('Listener', () => {
120120
// Decode each of the protocols from the reader
121121
const lsProtocols = await pipe(
122122
protocolsReader,
123-
Lp.decode(),
123+
(source) => Lp.decode(source),
124124
// Stringify and remove the newline
125125
(source) => map(source, (buf) => uint8ArrayToString(buf.subarray()).trim()),
126126
async (source) => await all(source)

0 commit comments

Comments
 (0)