deprecation(io): move types file (#4133)

This commit is contained in:
Asher Gomez 2024-01-09 16:14:28 +11:00 committed by GitHub
parent 8c55d22b2d
commit 22fba79092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 152 additions and 38 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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

View File

@ -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[] = [

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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.

View File

@ -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

View File

@ -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 {

View File

@ -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";

View File

@ -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;

View File

@ -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;

View File

@ -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";
/**

View File

@ -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();

14
io/types.d.ts vendored
View File

@ -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
@ -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
@ -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
@ -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
@ -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. */

116
io/types.ts Normal file
View File

@ -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.
*/
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;
}

View File

@ -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

View File

@ -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 };

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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[] = [];

View File

@ -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.

View File

@ -3,7 +3,7 @@
import { Buffer } from "../io/buffer.ts";
import { writeAll } from "./write_all.ts";
import type { Reader } from "../io/types.d.ts";
import type { Reader } from "../io/types.ts";
/**
* Create a {@linkcode Reader} from a {@linkcode ReadableStreamDefaultReader}.

View File

@ -2,7 +2,7 @@
// This module is browser compatible.
import { writeAll } from "./write_all.ts";
import type { Closer, Writer } from "../io/types.d.ts";
import type { Closer, Writer } from "../io/types.ts";
function isCloser(value: unknown): value is Closer {
return typeof value === "object" && value !== null && value !== undefined &&

View File

@ -2,7 +2,7 @@
import { assertEquals } from "../assert/mod.ts";
import { writableStreamFromWriter } from "./writable_stream_from_writer.ts";
import type { Closer, Writer } from "../io/types.d.ts";
import type { Closer, Writer } from "../io/types.ts";
class MockWriterCloser implements Writer, Closer {
chunks: Uint8Array[] = [];

View File

@ -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 "../io/types.d.ts";
import type { Writer, WriterSync } from "../io/types.ts";
export type { Writer, WriterSync };
/**

View File

@ -1,7 +1,7 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import type { Writer } from "../io/types.d.ts";
import type { Writer } from "../io/types.ts";
/**
* Create a {@linkcode Writer} from a {@linkcode WritableStreamDefaultWriter}.