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

deprecation(io): move types file #4133

Merged
merged 2 commits into from
Jan 9, 2024
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
2 changes: 1 addition & 1 deletion archive/_common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import { PartialReadError } from "../io/buf_reader.ts";
import type { Reader } from "../io/types.d.ts";
import type { Reader } from "../io/types.ts";

export interface TarInfo {
fileMode?: number;
Expand Down
2 changes: 1 addition & 1 deletion archive/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
type TarOptions,
ustarStructure,
} from "./_common.ts";
import type { Reader } from "../io/types.d.ts";
import type { Reader } from "../io/types.ts";
import { MultiReader } from "../io/multi_reader.ts";
import { Buffer } from "../io/buffer.ts";
import { assert } from "../assert/assert.ts";
Expand Down
2 changes: 1 addition & 1 deletion archive/untar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
ustarStructure,
} from "./_common.ts";
import { readAll } from "../streams/read_all.ts";
import type { Reader } from "../io/types.d.ts";
import type { Reader } from "../io/types.ts";

/**
* Extend TarMeta with the `linkName` property so that readers can access
Expand Down
2 changes: 1 addition & 1 deletion io/_test_common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";

export const MIN_READ_BUFFER_SIZE = 16;
export const bufsizes: number[] = [
Expand Down
2 changes: 1 addition & 1 deletion io/buf_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { assert } from "../assert/assert.ts";
import { copy } from "../bytes/copy.ts";
import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";

const DEFAULT_BUF_SIZE = 4096;
const MIN_BUF_SIZE = 16;
Expand Down
2 changes: 1 addition & 1 deletion io/buf_reader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BufferFullError, BufReader, PartialReadError } from "./buf_reader.ts";
import { StringReader } from "./string_reader.ts";
import { bufsizes, MIN_READ_BUFFER_SIZE } from "./_test_common.ts";
import { Buffer } from "./buffer.ts";
import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";
import { copy } from "../bytes/copy.ts";

/** OneByteReader returns a Reader that implements
Expand Down
2 changes: 1 addition & 1 deletion io/buf_writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { copy } from "../bytes/copy.ts";
import type { Writer, WriterSync } from "./types.d.ts";
import type { Writer, WriterSync } from "./types.ts";

const DEFAULT_BUF_SIZE = 4096;

Expand Down
2 changes: 1 addition & 1 deletion io/buf_writer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { BufWriter, BufWriterSync } from "./buf_writer.ts";
import { Buffer } from "./buffer.ts";
import { StringWriter } from "./string_writer.ts";
import { bufsizes } from "./_test_common.ts";
import type { Writer, WriterSync } from "./types.d.ts";
import type { Writer, WriterSync } from "./types.ts";

Deno.test("bufioWriter", async function () {
const data = new Uint8Array(8192);
Expand Down
2 changes: 1 addition & 1 deletion io/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { assert } from "../assert/assert.ts";
import { copy } from "../bytes/copy.ts";
import type { Reader, ReaderSync } from "./types.d.ts";
import type { Reader, ReaderSync } from "./types.ts";

// MIN_READ is the minimum ArrayBuffer size passed to a read call by
// buffer.ReadFrom. As long as the Buffer has at least MIN_READ bytes beyond
Expand Down
2 changes: 1 addition & 1 deletion io/copy_n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { assert } from "../assert/assert.ts";
import type { Reader, Writer } from "./types.d.ts";
import type { Reader, Writer } from "./types.ts";

const DEFAULT_BUFFER_SIZE = 32 * 1024;

Expand Down
2 changes: 1 addition & 1 deletion io/limited_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* `read` returns `null` when `limit` <= `0` or
* when the underlying `reader` returns `null`.
*/
import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";

/**
* @deprecated (will be removed after 1.0.0) Use the [Web Streams API]{@link https://developer.mozilla.org/en-US/docs/Web/API/Streams_API} instead.
Expand Down
2 changes: 1 addition & 1 deletion io/multi_reader.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";

/**
* Reader utility for combining multiple readers
Expand Down
2 changes: 1 addition & 1 deletion io/read_delim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { concat } from "../bytes/concat.ts";
import type { Reader } from "./types.d.ts";
import type { Reader } from "./types.ts";

/** Generate longest proper prefix which is also suffix array. */
function createLPS(pat: Uint8Array): Uint8Array {
Expand Down
2 changes: 1 addition & 1 deletion io/read_lines.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { type Reader } from "./types.d.ts";
import { type Reader } from "./types.ts";
import { BufReader } from "./buf_reader.ts";
import { concat } from "../bytes/concat.ts";

Expand Down
2 changes: 1 addition & 1 deletion io/read_range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { copy as copyBytes } from "../bytes/copy.ts";
import { assert } from "../assert/assert.ts";
import type { Reader, ReaderSync } from "./types.d.ts";
import type { Reader, ReaderSync } from "./types.ts";

const DEFAULT_BUFFER_SIZE = 32 * 1024;

Expand Down
2 changes: 1 addition & 1 deletion io/read_range_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
assertThrows,
} from "../assert/mod.ts";
import { readRange, readRangeSync } from "./read_range.ts";
import type { Closer, Reader, ReaderSync } from "./types.d.ts";
import type { Closer, Reader, ReaderSync } from "./types.ts";

// N controls how many iterations of certain checks are performed.
const N = 100;
Expand Down
2 changes: 1 addition & 1 deletion io/read_string_delim.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import { type Reader } from "./types.d.ts";
import { type Reader } from "./types.ts";
import { readDelim } from "./read_delim.ts";

/**
Expand Down
2 changes: 1 addition & 1 deletion io/string_writer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

import type { Writer, WriterSync } from "./types.d.ts";
import type { Writer, WriterSync } from "./types.ts";

const decoder = new TextDecoder();

Expand Down
14 changes: 6 additions & 8 deletions io/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
/**
* See the Contributing > Types section in the README for an explanation of this file.
*
* @deprecate (will be removed in 1.0.0) Use the
* [Streams API]{@linkcode https://developer.mozilla.org/en-US/docs/Web/API/Streams_API}
* instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/

/**
* An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/
export interface Reader {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
Expand Down Expand Up @@ -43,7 +41,7 @@ export interface Reader {
/**
* An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/
export interface ReaderSync {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
Expand Down Expand Up @@ -73,7 +71,7 @@ export interface ReaderSync {
/**
* An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode WritableStream} instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/
export interface Writer {
/** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
Expand All @@ -90,7 +88,7 @@ export interface Writer {
/**
* An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode WritableStream} instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/
export interface WriterSync {
/** Writes `p.byteLength` bytes from `p` to the underlying data
Expand All @@ -108,7 +106,7 @@ export interface WriterSync {
/**
* An abstract interface which when implemented provides an interface to close files/resources that were previously opened.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} and {@linkcode WritableStream} instead.
* @deprecated (will be removed in 0.214.0) Import from {@link https://deno.land/std/io/types.ts} instead.
*/
export interface Closer {
/** Closes the resource, "freeing" the backing file/resource. */
Expand Down
116 changes: 116 additions & 0 deletions io/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.

/**
* See the Contributing > Types section in the README for an explanation of this file.
*
* @deprecate (will be removed in 1.0.0) Use the
* [Streams API]{@linkcode https://developer.mozilla.org/en-US/docs/Web/API/Streams_API}
* instead.
*/

/**
* An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} instead.
Copy link
Contributor Author

@iuioiua iuioiua Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: remove this and other instances if we bring back std/io.

*/
export interface Reader {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
* bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
* encountered. Even if `read()` resolves to `n` < `p.byteLength`, it may
* use all of `p` as scratch space during the call. If some data is
* available but not `p.byteLength` bytes, `read()` conventionally resolves
* to what is available instead of waiting for more.
*
* When `read()` encounters end-of-file condition, it resolves to EOF
* (`null`).
*
* When `read()` encounters an error, it rejects with an error.
*
* Callers should always process the `n` > `0` bytes returned before
* considering the EOF (`null`). Doing so correctly handles I/O errors that
* happen after reading some bytes and also both of the allowed EOF
* behaviors.
*
* Implementations should not retain a reference to `p`.
*
* Use iterateReader() from https://deno.land/std@$STD_VERSION/streams/iterate_reader.ts to turn a Reader into an
* AsyncIterator.
*/
read(p: Uint8Array): Promise<number | null>;
}

/**
* An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} instead.
*/
export interface ReaderSync {
/** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
* of bytes read (`0` < `n` <= `p.byteLength`) and rejects if any error
* encountered. Even if `read()` returns `n` < `p.byteLength`, it may use
* all of `p` as scratch space during the call. If some data is available
* but not `p.byteLength` bytes, `read()` conventionally returns what is
* available instead of waiting for more.
*
* When `readSync()` encounters end-of-file condition, it returns EOF
* (`null`).
*
* When `readSync()` encounters an error, it throws with an error.
*
* Callers should always process the `n` > `0` bytes returned before
* considering the EOF (`null`). Doing so correctly handles I/O errors that happen
* after reading some bytes and also both of the allowed EOF behaviors.
*
* Implementations should not retain a reference to `p`.
*
* Use iterateReaderSync() from https://deno.land/std@$STD_VERSION/streams/iterate_reader.ts to turn a ReaderSync
* into an Iterator.
*/
readSync(p: Uint8Array): number | null;
}

/**
* An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode WritableStream} instead.
*/
export interface Writer {
/** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
* resolves to the number of bytes written from `p` (`0` <= `n` <=
* `p.byteLength`) or reject with the error encountered that caused the
* write to stop early. `write()` must reject with a non-null error if
* would resolve to `n` < `p.byteLength`. `write()` must not modify the
* slice data, even temporarily.
*
* Implementations should not retain a reference to `p`.
*/
write(p: Uint8Array): Promise<number>;
}
/**
* An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode WritableStream} instead.
*/
export interface WriterSync {
/** Writes `p.byteLength` bytes from `p` to the underlying data
* stream. It returns the number of bytes written from `p` (`0` <= `n`
* <= `p.byteLength`) and any error encountered that caused the write to
* stop early. `writeSync()` must throw a non-null error if it returns `n` <
* `p.byteLength`. `writeSync()` must not modify the slice data, even
* temporarily.
*
* Implementations should not retain a reference to `p`.
*/
writeSync(p: Uint8Array): number;
}

/**
* An abstract interface which when implemented provides an interface to close files/resources that were previously opened.
*
* @deprecated (will be removed in 1.0.0) Use {@linkcode ReadableStream} and {@linkcode WritableStream} instead.
*/
export interface Closer {
/** Closes the resource, "freeing" the backing file/resource. */
close(): void;
}
2 changes: 1 addition & 1 deletion streams/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { DEFAULT_BUFFER_SIZE } from "./_common.ts";
import type { Reader, Writer } from "../io/types.d.ts";
import type { Reader, Writer } from "../io/types.ts";

/**
* Copies from `src` to `dst` until either EOF (`null`) is read from `src` or
Expand Down
2 changes: 1 addition & 1 deletion streams/iterate_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { DEFAULT_BUFFER_SIZE } from "./_common.ts";
import type { Reader, ReaderSync } from "../io/types.d.ts";
import type { Reader, ReaderSync } from "../io/types.ts";

export type { Reader, ReaderSync };

Expand Down
2 changes: 1 addition & 1 deletion streams/iterate_reader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { assertEquals } from "../assert/mod.ts";
import { iterateReader, iterateReaderSync } from "./iterate_reader.ts";
import { readerFromIterable } from "./reader_from_iterable.ts";
import { delay } from "../async/delay.ts";
import type { Reader, ReaderSync } from "../io/types.d.ts";
import type { Reader, ReaderSync } from "../io/types.ts";

Deno.test("iterateReader", async () => {
// ref: https://github.com/denoland/deno/issues/2330
Expand Down
2 changes: 1 addition & 1 deletion streams/read_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { Buffer } from "../io/buffer.ts";
import type { Reader, ReaderSync } from "../io/types.d.ts";
import type { Reader, ReaderSync } from "../io/types.ts";

/**
* Read {@linkcode Reader} `r` until EOF (`null`) and resolve to the content as
Expand Down
2 changes: 1 addition & 1 deletion streams/readable_stream_from_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This module is browser compatible.

import { DEFAULT_CHUNK_SIZE } from "./_common.ts";
import type { Closer, Reader } from "../io/types.d.ts";
import type { Closer, Reader } from "../io/types.ts";
export type { Closer };

function isCloser(value: unknown): value is Closer {
Expand Down
2 changes: 1 addition & 1 deletion streams/readable_stream_from_reader_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { readableStreamFromReader } from "./readable_stream_from_reader.ts";
import { Buffer } from "../io/buffer.ts";
import { concat } from "../bytes/concat.ts";
import { copy } from "../bytes/copy.ts";
import type { Closer, Reader } from "../io/types.d.ts";
import type { Closer, Reader } from "../io/types.ts";

class MockReaderCloser implements Reader, Closer {
chunks: Uint8Array[] = [];
Expand Down
2 changes: 1 addition & 1 deletion streams/reader_from_iterable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { Buffer } from "../io/buffer.ts";
import { writeAll } from "./write_all.ts";
import { Reader } from "../io/types.d.ts";
import { Reader } from "../io/types.ts";

/**
* Create a {@linkcode Reader} from an iterable of {@linkcode Uint8Array}s.
Expand Down
Loading