Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/deno/cli/dts/lib.deno.ns.d.ts>Deno.FsFile#writeSync

A modern runtime for JavaScript and TypeScript.
Go to Latest
method Deno.FsFile.prototype.writeSync
import { Deno } from "https://deno.land/x/deno@v1.28.0/cli/dts/lib.deno.ns.d.ts";
const { FsFile } = Deno;

Synchronously write the contents of the array buffer (p) to the file.

Returns the number of bytes written.

It is not guaranteed that the full buffer will be written in a single call.

const encoder = new TextEncoder();
const data = encoder.encode("Hello world");
const file = Deno.openSync("/foo/bar.txt", { write: true });
const bytesWritten = file.writeSync(data); // 11
file.close();

Parameters

p: Uint8Array

Returns

number