Skip to content

Instantly share code, notes, and snippets.

@saschanaz
Last active January 24, 2018 13:30
Show Gist options
  • Save saschanaz/31b9a26871ea15057f7c42641a87ac1b to your computer and use it in GitHub Desktop.
Save saschanaz/31b9a26871ea15057f7c42641a87ac1b to your computer and use it in GitHub Desktop.
macOS append mode test
var fs = require("fs");
console.log(process.version);
var f = fs.openSync("testfile", "w");
fs.writeSync(f, "a=1\nb=2\n");
fs.closeSync(f);
f = fs.openSync("testfile", "a");
fs.writeSync(f, new Uint8Array([99, 61, 51]), 0, 3, 8);
fs.closeSync(f);
var result = fs.readFileSync("testfile", { encoding: "utf-8" });
var success = result === "a=1\nb=2\nc=3";
console.log(result, success ? "success" : "failure");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment