Skip to content

Commit

Permalink
Mark internal properties and methods as private
Browse files Browse the repository at this point in the history
  • Loading branch information
Acconut committed Jan 20, 2025
1 parent 17142b8 commit f508389
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 67 deletions.
12 changes: 6 additions & 6 deletions lib/browser/FetchHttpStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export class FetchHttpStack implements HttpStack {
}

class FetchRequest implements HttpRequest {
_method: string
_url: string
_headers: Record<string, string> = {}
_controller = new AbortController()
private _method: string
private _url: string
private _headers: Record<string, string> = {}
private _controller = new AbortController()

constructor(method: string, url: string) {
this._method = method
Expand Down Expand Up @@ -66,8 +66,8 @@ class FetchRequest implements HttpRequest {
}

class FetchResponse implements HttpResponse {
_res: Response
_body: string
private _res: Response
private _body: string

constructor(res: Response, body: string) {
this._res = res
Expand Down
10 changes: 5 additions & 5 deletions lib/browser/XHRHttpStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export class XHRHttpStack implements HttpStack {
}

class XHRRequest implements HttpRequest {
_xhr = new XMLHttpRequest()
private _xhr = new XMLHttpRequest()

_method: string
private _method: string

_url: string
private _url: string

_headers: Record<string, string> = {}
private _headers: Record<string, string> = {}

constructor(method: string, url: string) {
this._xhr.open(method, url, true)
Expand Down Expand Up @@ -84,7 +84,7 @@ class XHRRequest implements HttpRequest {
}

class XHRResponse implements HttpResponse {
_xhr: XMLHttpRequest
private _xhr: XMLHttpRequest

constructor(xhr: XMLHttpRequest) {
this._xhr = xhr
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/sources/BlobFileSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readAsByteArray } from '../../cordova/readAsByteArray.js'
import type { FileSource, SliceResult } from '../../options.js'

export class BlobFileSource implements FileSource {
_file: Blob
private _file: Blob

size: number

Expand Down
12 changes: 6 additions & 6 deletions lib/browser/sources/StreamFileSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ function concat<T extends StreamFileSource['_buffer']>(a: T, b: T): T {
}

export class StreamFileSource implements FileSource {
_reader: Pick<ReadableStreamDefaultReader<StreamFileSource['_buffer']>, 'read'>
private _reader: Pick<ReadableStreamDefaultReader<StreamFileSource['_buffer']>, 'read'>

_buffer: Blob | Uint8Array | number[] | undefined
private _buffer: Blob | Uint8Array | number[] | undefined

// _bufferOffset defines at which position the content of _buffer (if it is set)
// is located in the view of the entire stream. It does not mean at which offset
// the content in _buffer begins.
_bufferOffset = 0
private _bufferOffset = 0

_done = false
private _done = false

// Setting the size to null indicates that we have no calculation available
// for how much data this stream will emit requiring the user to specify
Expand All @@ -55,7 +55,7 @@ export class StreamFileSource implements FileSource {
return this._readUntilEnoughDataOrDone(start, end)
}

_readUntilEnoughDataOrDone(start: number, end: number) {
private _readUntilEnoughDataOrDone(start: number, end: number) {
const hasEnoughData = end <= this._bufferOffset + len(this._buffer)
if (this._done || hasEnoughData) {
const value = this._getDataFromBuffer(start, end)
Expand All @@ -76,7 +76,7 @@ export class StreamFileSource implements FileSource {
})
}

_getDataFromBuffer(start, end) {
private _getDataFromBuffer(start, end) {
if (this._buffer === undefined) {
throw new Error('cannot _getDataFromBuffer because _buffer is unset')
}
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/urlStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class WebStorageUrlStorage implements UrlStorage {
return Promise.resolve(key)
}

_findEntries(prefix: string): PreviousUpload[] {
private _findEntries(prefix: string): PreviousUpload[] {
const results: PreviousUpload[] = []

for (let i = 0; i < localStorage.length; i++) {
Expand Down
14 changes: 7 additions & 7 deletions lib/node/FileUrlStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class FileUrlStorage implements UrlStorage {
})
}

_setItem(key, value, cb) {
private _setItem(key, value, cb) {
lockfile
.lock(this.path, this._lockfileOptions())
.then((release) => {
Expand All @@ -69,7 +69,7 @@ export class FileUrlStorage implements UrlStorage {
.catch(cb)
}

_getItems(prefix, cb) {
private _getItems(prefix, cb) {
this._getData((err, data) => {
if (err) {
cb(err)
Expand All @@ -88,7 +88,7 @@ export class FileUrlStorage implements UrlStorage {
})
}

_removeItem(key, cb) {
private _removeItem(key, cb) {
lockfile
.lock(this.path, this._lockfileOptions())
.then((release) => {
Expand All @@ -106,7 +106,7 @@ export class FileUrlStorage implements UrlStorage {
.catch(cb)
}

_lockfileOptions() {
private _lockfileOptions() {
return {
realpath: false,
retries: {
Expand All @@ -116,7 +116,7 @@ export class FileUrlStorage implements UrlStorage {
}
}

_releaseAndCb(release, cb) {
private _releaseAndCb(release, cb) {
return (err) => {
if (err) {
release()
Expand All @@ -129,7 +129,7 @@ export class FileUrlStorage implements UrlStorage {
}
}

_writeData(data, cb) {
private _writeData(data, cb) {
writeFile(
this.path,
JSON.stringify(data),
Expand All @@ -142,7 +142,7 @@ export class FileUrlStorage implements UrlStorage {
)
}

_getData(cb) {
private _getData(cb) {
readFile(this.path, 'utf8', (err, data) => {
if (err) {
// return empty data if file does not exist
Expand Down
20 changes: 10 additions & 10 deletions lib/node/NodeHttpStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export class NodeHttpStack implements HttpStack {
}

class Request implements HttpRequest {
_method: string
private _method: string

_url: string
private _url: string

_headers: Record<string, string> = {}
private _headers: Record<string, string> = {}

_request: http.ClientRequest | null = null
private _request: http.ClientRequest | null = null

_progressHandler: HttpProgressHandler = () => {}
private _progressHandler: HttpProgressHandler = () => {}

_requestOptions: http.RequestOptions
private _requestOptions: http.RequestOptions

constructor(method: string, url: string, options: http.RequestOptions) {
this._method = method
Expand Down Expand Up @@ -129,9 +129,9 @@ class Request implements HttpRequest {
}

class Response implements HttpResponse {
_response: http.IncomingMessage
private _response: http.IncomingMessage

_body: string
private _body: string

constructor(res: http.IncomingMessage, body: string) {
this._response = res
Expand Down Expand Up @@ -166,9 +166,9 @@ class Response implements HttpResponse {
// track of the number of bytes which have been piped through it and will
// invoke the `onprogress` function whenever new number are available.
class ProgressEmitter extends Transform {
_onprogress: HttpProgressHandler
private _onprogress: HttpProgressHandler

_position = 0
private _position = 0

constructor(onprogress: HttpProgressHandler) {
super()
Expand Down
4 changes: 2 additions & 2 deletions lib/node/sources/NodeFileSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export async function getFileSource(stream: ReadStream): Promise<NodeFileSource>
export class NodeFileSource implements FileSource {
size: number

_stream: ReadStream
private _stream: ReadStream

_path: string
private _path: string

constructor(stream: ReadStream, path: string, size: number) {
this._stream = stream
Expand Down
Loading

0 comments on commit f508389

Please sign in to comment.