Skip to main content
Home

@std/io@0.225.2
Built and signed on GitHub Actions

UNSTABLE: The utilities for advanced I/O operations using Reader and Writer interfaces.

This package works with DenoIt is unknown whether this package works with Cloudflare Workers, Node.js, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
94%
Published
10 months ago (0.225.2)
function copy
copy(
src: Reader,
dst: Writer,
options?: { bufSize?: number; },
): Promise<number>

Copies from src to dst until either EOF (null) is read from src or an error occurs. It resolves to the number of bytes copied or rejects with the first error encountered while copying.

Examples

Usage

import { copy } from "@std/io/copy";

const source = await Deno.open("my_file.txt");
const bytesCopied1 = await copy(source, Deno.stdout);
const destination = await Deno.create("my_file_2.txt");
const bytesCopied2 = await copy(source, destination);

Parameters

The source to copy from

The destination to copy to

optional
options: { bufSize?: number; }

Can be used to tune size of the buffer. Default size is 32kB

Return Type

Number of bytes copied

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/io

Import symbol

import { copy } from "@std/io/copy";
or

Import directly with a jsr specifier

import { copy } from "jsr:@std/io/copy";

Add Package

pnpm i jsr:@std/io
or (using pnpm 10.8 or older)
pnpm dlx jsr add @std/io

Import symbol

import { copy } from "@std/io/copy";

Add Package

yarn add jsr:@std/io
or (using Yarn 4.8 or older)
yarn dlx jsr add @std/io

Import symbol

import { copy } from "@std/io/copy";

Add Package

vlt install jsr:@std/io

Import symbol

import { copy } from "@std/io/copy";

Add Package

npx jsr add @std/io

Import symbol

import { copy } from "@std/io/copy";

Add Package

bunx jsr add @std/io

Import symbol

import { copy } from "@std/io/copy";