本文目录

Deno.copy

🌙
手机阅读
本文目录结构

copy

  • copy(dst: Writer, src: Reader): Promise<number>

  • src 拷贝文件至 dst,拷贝至 srcEOF 或有异常出现时结束。 copy() 函数返回一个 Promise, 成功时 resolve 并返回拷贝的字节数,失败时 reject 并返回拷贝过程中的首个异常。

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

      const source = await Deno.open("my_file.txt");
      const buffer = new Deno.Buffer()
      const bytesCopied1 = await Deno.copy(Deno.stdout, source);
      const bytesCopied2 = await Deno.copy(buffer, source);
    

    因为 copy() 函数在读到 EOF 时停止,所以不会将 EOF 视为异常(区别于 read() 函数)。

    Because copy() is defined to read from src until EOF, it does not treat an EOF from read() as an error to be reported.

参数

-   ##### dst: [Writer](interfaces/deno.writer.html)

    需要拷贝至的目标位置

    The destination to copy to

-   ##### src: [Reader](interfaces/deno.reader.html)

    拷贝的源位置

    The source to copy from

返回 Promise<number>

AXIHE / 精选资源

浏览全部教程

面试题

学习网站

前端培训
自己甄别

前端书籍

关于朱安邦

我叫 朱安邦,阿西河的站长,在杭州。

以前是一名平面设计师,后来开始接接触前端开发,主要研究前端技术中的JS方向。

业余时间我喜欢分享和交流自己的技术,欢迎大家关注我的 Bilibili

关注我: Github / 知乎

于2021年离开前端领域,目前重心放在研究区块链上面了

我叫朱安邦,阿西河的站长

目前在杭州从事区块链周边的开发工作,机械专业,以前从事平面设计工作。

2014年底脱产在老家自学6个月的前端技术,自学期间几乎从未出过家门,最终找到了满意的前端工作。更多>

于2021年离开前端领域,目前从事区块链方面工作了