Skip to content

Commit 3e4aedd

Browse files
committed
refactor: promisify manually
1 parent da3f42f commit 3e4aedd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/server.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import http from 'node:http'
44
import { tmpdir } from 'node:os'
55
import { dirname, join, relative, resolve, sep } from 'node:path'
66
import { platform } from 'node:process'
7-
import { promises as stream } from 'node:stream'
7+
import stream from 'node:stream'
8+
import { promisify } from 'node:util'
89

910
import { ListResponse } from './backend/list.ts'
1011
import { decodeMetadata, encodeMetadata, METADATA_HEADER_INTERNAL } from './metadata.ts'
@@ -22,6 +23,10 @@ export enum Operation {
2223
SET = 'set',
2324
}
2425

26+
// TODO: Replace with `promises` import of `node:stream` once we can drop
27+
// support for Node 14.
28+
const pipeline = promisify(stream.pipeline)
29+
2530
interface BlobsServerOptions {
2631
/**
2732
* Whether debug-level information should be logged, such as internal errors
@@ -272,7 +277,7 @@ export class BlobsServer {
272277
const tempDataPath = join(tempDirectory, relativeDataPath)
273278

274279
await fs.mkdir(dirname(tempDataPath), { recursive: true })
275-
await stream.pipeline(req, createWriteStream(tempDataPath))
280+
await pipeline(req, createWriteStream(tempDataPath))
276281

277282
await fs.mkdir(dirname(dataPath), { recursive: true })
278283
await fs.copyFile(tempDataPath, dataPath)

0 commit comments

Comments
 (0)