Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Storage packages to move to @types/node v12 #16020

Merged
merged 2 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdk/storage/storage-blob/src/utils/utils.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function streamToBuffer(
buffer: Buffer,
offset: number,
end: number,
encoding?: string
encoding?: BufferEncoding
): Promise<void> {
let pos = 0; // Position in stream
const count = end - offset; // Total amount of data needed in stream
Expand Down Expand Up @@ -72,7 +72,7 @@ export async function streamToBuffer(
export async function streamToBuffer2(
stream: NodeJS.ReadableStream,
buffer: Buffer,
encoding?: string
encoding?: BufferEncoding
): Promise<number> {
let pos = 0; // Position in stream
const bufferSize = buffer.length;
Expand Down Expand Up @@ -113,7 +113,7 @@ export async function streamToBuffer2(
*/
export async function streamToBuffer3(
readableStream: NodeJS.ReadableStream,
encoding?: string
encoding?: BufferEncoding
): Promise<Buffer> {
return new Promise((resolve, reject) => {
const chunks: Buffer[] = [];
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/storage-common/src/BufferScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class BufferScheduler {
/**
* Encoding of the input Readable stream which has string data type instead of Buffer.
*/
private encoding?: string;
private encoding?: BufferEncoding;

/**
* How many buffers have been allocated.
Expand Down Expand Up @@ -141,7 +141,7 @@ export class BufferScheduler {
maxBuffers: number,
outgoingHandler: OutgoingHandler,
concurrency: number,
encoding?: string
encoding?: BufferEncoding
) {
if (bufferSize <= 0) {
throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class BufferScheduler {
/**
* Encoding of the input Readable stream which has string data type instead of Buffer.
*/
private encoding?: string;
private encoding?: BufferEncoding;

/**
* How many buffers have been allocated.
Expand Down Expand Up @@ -136,7 +136,7 @@ export class BufferScheduler {
maxBuffers: number,
outgoingHandler: OutgoingHandler,
concurrency: number,
encoding?: string
encoding?: BufferEncoding
) {
if (bufferSize <= 0) {
throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);
Expand Down
7 changes: 3 additions & 4 deletions sdk/storage/storage-file-datalake/src/utils/utils.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import * as fs from "fs";
import * as util from "util";
import { isNode } from "@azure/core-http";

/**
* Reads a readable stream into buffer. Fill the buffer from offset to end.
Expand All @@ -19,7 +18,7 @@ export async function streamToBuffer(
buffer: Buffer,
offset: number,
end: number,
encoding?: string
encoding?: BufferEncoding
): Promise<void> {
let pos = 0; // Position in stream
const count = end - offset; // Total amount of data needed in stream
Expand Down Expand Up @@ -73,7 +72,7 @@ export async function streamToBuffer(
export async function streamToBuffer2(
stream: NodeJS.ReadableStream,
buffer: Buffer,
encoding?: string
encoding?: BufferEncoding
): Promise<number> {
let pos = 0; // Position in stream
const bufferSize = buffer.length;
Expand Down Expand Up @@ -110,6 +109,6 @@ export async function streamToBuffer2(
*
* Promisified version of fs.stat().
*/
export const fsStat = util.promisify(isNode ? fs.stat : function stat() {});
export const fsStat = util.promisify(fs.stat);

export const fsCreateReadStream = fs.createReadStream;
4 changes: 2 additions & 2 deletions sdk/storage/storage-file-share/src/utils/BufferScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class BufferScheduler {
/**
* Encoding of the input Readable stream which has string data type instead of Buffer.
*/
private encoding?: string;
private encoding?: BufferEncoding;

/**
* How many buffers have been allocated.
Expand Down Expand Up @@ -136,7 +136,7 @@ export class BufferScheduler {
maxBuffers: number,
outgoingHandler: OutgoingHandler,
concurrency: number,
encoding?: string
encoding?: BufferEncoding
) {
if (bufferSize <= 0) {
throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);
Expand Down
2 changes: 1 addition & 1 deletion sdk/storage/storage-file-share/src/utils/utils.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function streamToBuffer(
buffer: Buffer,
offset: number,
end: number,
encoding?: string
encoding?: BufferEncoding
): Promise<void> {
let pos = 0; // Position in stream
const count = end - offset; // Total amount of data needed in stream
Expand Down